changeset 117:e9f3a4ddf772

* Add Mono for Android version of .csproj file * Update Constants to allow initialisation where we can't pull defaults (e.g. Mono for Android)
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Jul 2012 15:24:17 +0100
parents 07660ac09a5f
children e53bf3356914
files Constants.cs IBBoard-Droid.csproj
diffstat 2 files changed, 164 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Constants.cs	Tue Jun 26 20:09:01 2012 +0100
+++ b/Constants.cs	Sat Jul 14 15:24:17 2012 +0100
@@ -14,28 +14,55 @@
 	{
 		public static readonly char DirectoryChar = Path.DirectorySeparatorChar;
 		public static readonly string DirectoryString = Path.DirectorySeparatorChar.ToString();
-		private static string executablePath = AppDomain.CurrentDomain.BaseDirectory.TrimEnd(DirectoryChar);
+		private static string executablePath;        
+		private static string userDataPath;
+		private static bool initialised;
 
 		static Constants()
 		{
-            string appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
-			string exe = Environment.GetCommandLineArgs()[0];
-			exe = Path.GetFileNameWithoutExtension(exe);
-            userDataPath = Path.Combine(Path.Combine(appDataDir, "IBBoard"), exe);
+			if (AppDomain.CurrentDomain.BaseDirectory != null && Environment.GetCommandLineArgs() != null)
+			{
+				string exe = Environment.GetCommandLineArgs()[0];
+				Initialise(Path.GetFileNameWithoutExtension(exe), AppDomain.CurrentDomain.BaseDirectory);
+			}
+		}
+
+		private static void Initialise(string appName, string baseDir)
+		{
+			string appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+			userDataPath = Path.Combine(Path.Combine(appDataDir, "IBBoard"), appName);
+			executablePath = baseDir;
+			initialised = true;
+		}
+
+		public static void Initialise(string appName)
+		{
+			if (initialised)
+			{
+				throw new InvalidOperationException("IBBoard.Constants have already been initialised");
+			}
+
+			Initialise(appName, "");
 		}
 
 		/// <summary>
 		/// Gets the path of the directory that contains the executable.
 		/// </summary>
 		/// <value>
-		/// The path that the executable is in.
+		/// The path that the executable is in, or an empty string if it cannot be determined
 		/// </value>
 		public static string ExecutablePath
 		{
-			get { return executablePath; }
+			get
+			{ 
+				if (!initialised)
+				{
+					throw new InvalidOperationException("IBBoard.Constants have not been initialised");
+				}
+
+				return executablePath; 
+			}
 		}
-		
-		private static string userDataPath;
 
 		/// <summary>
 		/// Gets the standard user data path for this app. This follows a convention of using the app name for the folder
@@ -46,7 +73,15 @@
 		/// </value>
 		public static string UserDataPath
 		{
-			get { return userDataPath; }
+			get
+			{
+				if (!initialised)
+				{
+					throw new InvalidOperationException("IBBoard.Constants have not been initialised");
+				}
+
+				return userDataPath;
+			}
 		}
 	}
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IBBoard-Droid.csproj	Sat Jul 14 15:24:17 2012 +0100
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>10.0.0</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{A68B7155-DC24-44F7-9AA2-F0DA9229FB6C}</ProjectGuid>
+    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <OutputType>Library</OutputType>
+    <RootNamespace>IBBoard</RootNamespace>
+    <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
+    <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
+    <AssemblyName>IBBoard-Droid</AssemblyName>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug</OutputPath>
+    <DefineConstants>DEBUG;</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <ConsolePause>false</ConsolePause>
+    <AndroidLinkMode>None</AndroidLinkMode>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
+    <ConsolePause>false</ConsolePause>
+    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Xml" />
+    <Reference Include="System.Core" />
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
+  <ItemGroup>
+    <Compile Include="Collections\Collections.cs" />
+    <Compile Include="Collections\DictionaryUtils.cs" />
+    <Compile Include="Collections\SimpleSet.cs" />
+    <Compile Include="Commands\Command.cs" />
+    <Compile Include="Commands\CommandStack.cs" />
+    <Compile Include="CustomMath\Comparisons.cs" />
+    <Compile Include="CustomMath\IBBMath.cs" />
+    <Compile Include="CustomMath\NumberParser.cs" />
+    <Compile Include="IO\BinaryReaderBigEndian.cs" />
+    <Compile Include="IO\InvalidFileException.cs" />
+    <Compile Include="IO\StreamUtil.cs" />
+    <Compile Include="IO\UnsupportedFileTypeException.cs" />
+    <Compile Include="Lang\AbstractTranslationSet.cs" />
+    <Compile Include="Lang\ITranslatable.cs" />
+    <Compile Include="Lang\ModifiableTranslationSet.cs" />
+    <Compile Include="Lang\StringManipulation.cs" />
+    <Compile Include="Lang\Translation.cs" />
+    <Compile Include="Lang\TranslationLanguage.cs" />
+    <Compile Include="Lang\TranslationLoadException.cs" />
+    <Compile Include="Lang\TranslationXmlExtractor.cs" />
+    <Compile Include="Lang\TranslationXmlLoader.cs" />
+    <Compile Include="Lang\XmlTranslationSet.cs" />
+    <Compile Include="Limits\AbsoluteNumericLimit.cs" />
+    <Compile Include="Limits\AbstractCompositeLimit.cs" />
+    <Compile Include="Limits\AbstractLimit.cs" />
+    <Compile Include="Limits\CompositeMaximumLimit.cs" />
+    <Compile Include="Limits\CompositeMinimumLimit.cs" />
+    <Compile Include="Limits\ILimit.cs" />
+    <Compile Include="Limits\INumericLimit.cs" />
+    <Compile Include="Limits\IPercentageLimit.cs" />
+    <Compile Include="Limits\NumericSizeConstrainedLimit.cs" />
+    <Compile Include="Limits\SimpleRoundedPercentageLimit.cs" />
+    <Compile Include="Limits\UnlimitedLimit.cs" />
+    <Compile Include="Logging\FileLogger.cs" />
+    <Compile Include="Logging\Logger.cs" />
+    <Compile Include="Logging\LogItem.cs" />
+    <Compile Include="Logging\LogNotifier.cs" />
+    <Compile Include="Logging\SilentLogger.cs" />
+    <Compile Include="Logging\TextFileLogger.cs" />
+    <Compile Include="Xml\CustomXmlResolver.cs" />
+    <Compile Include="Xml\IBBXmlResolver.cs" />
+    <Compile Include="Xml\IXmlElementName.cs" />
+    <Compile Include="Xml\XmlParseException.cs" />
+    <Compile Include="Xml\XmlTools.cs" />
+    <Compile Include="Arrays.cs" />
+    <Compile Include="AssemblyInfo.cs" />
+    <Compile Include="Constants.cs" />
+    <Compile Include="EnumTools.cs" />
+    <Compile Include="EqualityChecker.cs" />
+    <Compile Include="IBBoard.cs" />
+    <Compile Include="IExtendedEnum.cs" />
+    <Compile Include="OperationFailedException.cs" />
+    <Compile Include="Preferences.cs" />
+    <Compile Include="UnixTimestamp.cs" />
+    <Compile Include="Xml\XmlResourceResolver.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="app.config" />
+    <None Include="COPYING.GPL" />
+    <None Include="COPYING.LGPL" />
+  </ItemGroup>
+  <ProjectExtensions>
+    <MonoDevelop>
+      <Properties>
+        <Policies>
+          <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="FileFormatDefault" />
+        </Policies>
+      </Properties>
+    </MonoDevelop>
+  </ProjectExtensions>
+  <ItemGroup>
+    <EmbeddedResource Include="schemas\translation.xsd">
+      <DeployService-Deploy>true</DeployService-Deploy>
+    </EmbeddedResource>
+  </ItemGroup>
+</Project>
\ No newline at end of file