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 diff
     1.1 --- a/Constants.cs	Tue Jun 26 20:09:01 2012 +0100
     1.2 +++ b/Constants.cs	Sat Jul 14 15:24:17 2012 +0100
     1.3 @@ -14,28 +14,55 @@
     1.4  	{
     1.5  		public static readonly char DirectoryChar = Path.DirectorySeparatorChar;
     1.6  		public static readonly string DirectoryString = Path.DirectorySeparatorChar.ToString();
     1.7 -		private static string executablePath = AppDomain.CurrentDomain.BaseDirectory.TrimEnd(DirectoryChar);
     1.8 +		private static string executablePath;        
     1.9 +		private static string userDataPath;
    1.10 +		private static bool initialised;
    1.11  
    1.12  		static Constants()
    1.13  		{
    1.14 -            string appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
    1.15 -			string exe = Environment.GetCommandLineArgs()[0];
    1.16 -			exe = Path.GetFileNameWithoutExtension(exe);
    1.17 -            userDataPath = Path.Combine(Path.Combine(appDataDir, "IBBoard"), exe);
    1.18 +			if (AppDomain.CurrentDomain.BaseDirectory != null && Environment.GetCommandLineArgs() != null)
    1.19 +			{
    1.20 +				string exe = Environment.GetCommandLineArgs()[0];
    1.21 +				Initialise(Path.GetFileNameWithoutExtension(exe), AppDomain.CurrentDomain.BaseDirectory);
    1.22 +			}
    1.23 +		}
    1.24 +
    1.25 +		private static void Initialise(string appName, string baseDir)
    1.26 +		{
    1.27 +			string appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
    1.28 +			userDataPath = Path.Combine(Path.Combine(appDataDir, "IBBoard"), appName);
    1.29 +			executablePath = baseDir;
    1.30 +			initialised = true;
    1.31 +		}
    1.32 +
    1.33 +		public static void Initialise(string appName)
    1.34 +		{
    1.35 +			if (initialised)
    1.36 +			{
    1.37 +				throw new InvalidOperationException("IBBoard.Constants have already been initialised");
    1.38 +			}
    1.39 +
    1.40 +			Initialise(appName, "");
    1.41  		}
    1.42  
    1.43  		/// <summary>
    1.44  		/// Gets the path of the directory that contains the executable.
    1.45  		/// </summary>
    1.46  		/// <value>
    1.47 -		/// The path that the executable is in.
    1.48 +		/// The path that the executable is in, or an empty string if it cannot be determined
    1.49  		/// </value>
    1.50  		public static string ExecutablePath
    1.51  		{
    1.52 -			get { return executablePath; }
    1.53 +			get
    1.54 +			{ 
    1.55 +				if (!initialised)
    1.56 +				{
    1.57 +					throw new InvalidOperationException("IBBoard.Constants have not been initialised");
    1.58 +				}
    1.59 +
    1.60 +				return executablePath; 
    1.61 +			}
    1.62  		}
    1.63 -		
    1.64 -		private static string userDataPath;
    1.65  
    1.66  		/// <summary>
    1.67  		/// Gets the standard user data path for this app. This follows a convention of using the app name for the folder
    1.68 @@ -46,7 +73,15 @@
    1.69  		/// </value>
    1.70  		public static string UserDataPath
    1.71  		{
    1.72 -			get { return userDataPath; }
    1.73 +			get
    1.74 +			{
    1.75 +				if (!initialised)
    1.76 +				{
    1.77 +					throw new InvalidOperationException("IBBoard.Constants have not been initialised");
    1.78 +				}
    1.79 +
    1.80 +				return userDataPath;
    1.81 +			}
    1.82  		}
    1.83  	}
    1.84  }
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/IBBoard-Droid.csproj	Sat Jul 14 15:24:17 2012 +0100
     2.3 @@ -0,0 +1,119 @@
     2.4 +<?xml version="1.0" encoding="utf-8"?>
     2.5 +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     2.6 +  <PropertyGroup>
     2.7 +    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     2.8 +    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     2.9 +    <ProductVersion>10.0.0</ProductVersion>
    2.10 +    <SchemaVersion>2.0</SchemaVersion>
    2.11 +    <ProjectGuid>{A68B7155-DC24-44F7-9AA2-F0DA9229FB6C}</ProjectGuid>
    2.12 +    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    2.13 +    <OutputType>Library</OutputType>
    2.14 +    <RootNamespace>IBBoard</RootNamespace>
    2.15 +    <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
    2.16 +    <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
    2.17 +    <AssemblyName>IBBoard-Droid</AssemblyName>
    2.18 +  </PropertyGroup>
    2.19 +  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    2.20 +    <DebugSymbols>true</DebugSymbols>
    2.21 +    <DebugType>full</DebugType>
    2.22 +    <Optimize>false</Optimize>
    2.23 +    <OutputPath>bin\Debug</OutputPath>
    2.24 +    <DefineConstants>DEBUG;</DefineConstants>
    2.25 +    <ErrorReport>prompt</ErrorReport>
    2.26 +    <WarningLevel>4</WarningLevel>
    2.27 +    <ConsolePause>false</ConsolePause>
    2.28 +    <AndroidLinkMode>None</AndroidLinkMode>
    2.29 +  </PropertyGroup>
    2.30 +  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    2.31 +    <DebugType>none</DebugType>
    2.32 +    <Optimize>true</Optimize>
    2.33 +    <OutputPath>bin\Release</OutputPath>
    2.34 +    <ErrorReport>prompt</ErrorReport>
    2.35 +    <WarningLevel>4</WarningLevel>
    2.36 +    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
    2.37 +    <ConsolePause>false</ConsolePause>
    2.38 +    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
    2.39 +  </PropertyGroup>
    2.40 +  <ItemGroup>
    2.41 +    <Reference Include="System" />
    2.42 +    <Reference Include="System.Xml" />
    2.43 +    <Reference Include="System.Core" />
    2.44 +  </ItemGroup>
    2.45 +  <Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
    2.46 +  <ItemGroup>
    2.47 +    <Compile Include="Collections\Collections.cs" />
    2.48 +    <Compile Include="Collections\DictionaryUtils.cs" />
    2.49 +    <Compile Include="Collections\SimpleSet.cs" />
    2.50 +    <Compile Include="Commands\Command.cs" />
    2.51 +    <Compile Include="Commands\CommandStack.cs" />
    2.52 +    <Compile Include="CustomMath\Comparisons.cs" />
    2.53 +    <Compile Include="CustomMath\IBBMath.cs" />
    2.54 +    <Compile Include="CustomMath\NumberParser.cs" />
    2.55 +    <Compile Include="IO\BinaryReaderBigEndian.cs" />
    2.56 +    <Compile Include="IO\InvalidFileException.cs" />
    2.57 +    <Compile Include="IO\StreamUtil.cs" />
    2.58 +    <Compile Include="IO\UnsupportedFileTypeException.cs" />
    2.59 +    <Compile Include="Lang\AbstractTranslationSet.cs" />
    2.60 +    <Compile Include="Lang\ITranslatable.cs" />
    2.61 +    <Compile Include="Lang\ModifiableTranslationSet.cs" />
    2.62 +    <Compile Include="Lang\StringManipulation.cs" />
    2.63 +    <Compile Include="Lang\Translation.cs" />
    2.64 +    <Compile Include="Lang\TranslationLanguage.cs" />
    2.65 +    <Compile Include="Lang\TranslationLoadException.cs" />
    2.66 +    <Compile Include="Lang\TranslationXmlExtractor.cs" />
    2.67 +    <Compile Include="Lang\TranslationXmlLoader.cs" />
    2.68 +    <Compile Include="Lang\XmlTranslationSet.cs" />
    2.69 +    <Compile Include="Limits\AbsoluteNumericLimit.cs" />
    2.70 +    <Compile Include="Limits\AbstractCompositeLimit.cs" />
    2.71 +    <Compile Include="Limits\AbstractLimit.cs" />
    2.72 +    <Compile Include="Limits\CompositeMaximumLimit.cs" />
    2.73 +    <Compile Include="Limits\CompositeMinimumLimit.cs" />
    2.74 +    <Compile Include="Limits\ILimit.cs" />
    2.75 +    <Compile Include="Limits\INumericLimit.cs" />
    2.76 +    <Compile Include="Limits\IPercentageLimit.cs" />
    2.77 +    <Compile Include="Limits\NumericSizeConstrainedLimit.cs" />
    2.78 +    <Compile Include="Limits\SimpleRoundedPercentageLimit.cs" />
    2.79 +    <Compile Include="Limits\UnlimitedLimit.cs" />
    2.80 +    <Compile Include="Logging\FileLogger.cs" />
    2.81 +    <Compile Include="Logging\Logger.cs" />
    2.82 +    <Compile Include="Logging\LogItem.cs" />
    2.83 +    <Compile Include="Logging\LogNotifier.cs" />
    2.84 +    <Compile Include="Logging\SilentLogger.cs" />
    2.85 +    <Compile Include="Logging\TextFileLogger.cs" />
    2.86 +    <Compile Include="Xml\CustomXmlResolver.cs" />
    2.87 +    <Compile Include="Xml\IBBXmlResolver.cs" />
    2.88 +    <Compile Include="Xml\IXmlElementName.cs" />
    2.89 +    <Compile Include="Xml\XmlParseException.cs" />
    2.90 +    <Compile Include="Xml\XmlTools.cs" />
    2.91 +    <Compile Include="Arrays.cs" />
    2.92 +    <Compile Include="AssemblyInfo.cs" />
    2.93 +    <Compile Include="Constants.cs" />
    2.94 +    <Compile Include="EnumTools.cs" />
    2.95 +    <Compile Include="EqualityChecker.cs" />
    2.96 +    <Compile Include="IBBoard.cs" />
    2.97 +    <Compile Include="IExtendedEnum.cs" />
    2.98 +    <Compile Include="OperationFailedException.cs" />
    2.99 +    <Compile Include="Preferences.cs" />
   2.100 +    <Compile Include="UnixTimestamp.cs" />
   2.101 +    <Compile Include="Xml\XmlResourceResolver.cs" />
   2.102 +  </ItemGroup>
   2.103 +  <ItemGroup>
   2.104 +    <None Include="app.config" />
   2.105 +    <None Include="COPYING.GPL" />
   2.106 +    <None Include="COPYING.LGPL" />
   2.107 +  </ItemGroup>
   2.108 +  <ProjectExtensions>
   2.109 +    <MonoDevelop>
   2.110 +      <Properties>
   2.111 +        <Policies>
   2.112 +          <DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="FileFormatDefault" />
   2.113 +        </Policies>
   2.114 +      </Properties>
   2.115 +    </MonoDevelop>
   2.116 +  </ProjectExtensions>
   2.117 +  <ItemGroup>
   2.118 +    <EmbeddedResource Include="schemas\translation.xsd">
   2.119 +      <DeployService-Deploy>true</DeployService-Deploy>
   2.120 +    </EmbeddedResource>
   2.121 +  </ItemGroup>
   2.122 +</Project>
   2.123 \ No newline at end of file