# HG changeset patch # User IBBoard # Date 1342275857 -3600 # Node ID e9f3a4ddf7725f5ba2ecdf80384183d49206d92b # Parent 07660ac09a5f1888d33030812f7d733b7c1c9f83 * Add Mono for Android version of .csproj file * Update Constants to allow initialisation where we can't pull defaults (e.g. Mono for Android) diff -r 07660ac09a5f -r e9f3a4ddf772 Constants.cs --- 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, ""); } /// /// Gets the path of the directory that contains the executable. /// /// - /// The path that the executable is in. + /// The path that the executable is in, or an empty string if it cannot be determined /// 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; /// /// 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 @@ /// public static string UserDataPath { - get { return userDataPath; } + get + { + if (!initialised) + { + throw new InvalidOperationException("IBBoard.Constants have not been initialised"); + } + + return userDataPath; + } } } } diff -r 07660ac09a5f -r e9f3a4ddf772 IBBoard-Droid.csproj --- /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 @@ + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {A68B7155-DC24-44F7-9AA2-F0DA9229FB6C} + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + IBBoard + Assets + Resources + IBBoard-Droid + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + None + + + none + true + bin\Release + prompt + 4 + false + false + SdkOnly + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + \ No newline at end of file