public static void Serialize(AsmInfo asm, string path, object obj) { path = asm.InAppDir(path); using (Stream stream = File.OpenWrite(path)) { BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, obj); } }
public static object Deserialize(AsmInfo asm, string path) { path = asm.InAppDir(path); object obj = null; using (Stream stream = File.OpenRead(path)) { BinaryFormatter formatter = new BinaryFormatter(); obj = formatter.Deserialize(stream); } return obj; }
public LocationsSource(AsmInfo asminfo) { this.asminfo = asminfo; this.file = asminfo.GetSerializePath(Constants.LocationListFilename); try { list = GetStoredList(); } catch { Controller.SplashQueue.Enqueue("Building location list"); // report fallthrough list = LocationListData.GetStandardList(); } // sort keys List<string> keylist = new List<string>(); foreach (string name in list.Keys) { keylist.Add(name); } keylist.Sort(); locations_list = keylist; }
public ShortcutInstaller(AsmInfo asminfo) { this.asminfo = asminfo; }
static Controller() { Controller.AsmInfo = new AsmInfo(Assembly.GetExecutingAssembly()); }
static MapBitmap() { AsmInfo asminfo = new AsmInfo(Assembly.GetExecutingAssembly()); MapBitmap.bitmap_map = asminfo.GetBitmap("worldmap.png"); }
public static void Main(string[] args) { bool verbose = false; bool help = false; bool bench = false; // calc defaults string latitude = null; string longitude = null; string timezone = null; string date = null; string time = null; // generate image, set to negative dimensions int imgsz = -1; // bench defaults int step = 1; bool timebased = true; OptionSet p = new OptionSet () .Add ("lat=", "Latitude position: (N/S).00.00.00", delegate (string v) { latitude = v; }) .Add ("lon=", "Longitude position: (E/W).000.00.00", delegate (string v) { longitude = v; }) .Add ("tz=", "Timezone offset from UTC: [-12,14]", delegate (string v) { timezone = v; }) .Add ("dt=", "Date: dd.mm.yyyy", delegate (string v) { date = v; }) .Add ("tm=", "Time: hh:mm:ss", delegate (string v) { time = v; }) .Add ("img=", "Generate diagram image: 500", delegate (int v) { imgsz = v; }) .Add ("benchtime-5", "Benchmark all times with 5sec increments", delegate (string v) { bench = true; timebased = true; step = 5; }) .Add ("benchpos-5", "Benchmark all positions with 5° increments", delegate (string v) { bench = true; timebased = false; step = 5; }) .Add ("v|verbose", "Display benchmark results", delegate (string v) { verbose = true; }) .Add ("h|help", "Display this message", delegate (string v) { help = true; }); p.Parse(args); if ((help) || (args.Length == 0)) { AsmInfo asminfo = new AsmInfo(Assembly.GetExecutingAssembly()); Console.Error.WriteLine("{0} {1} {2}", asminfo.GetAtt("Title"), asminfo.GetAtt("Version"), Platform.GetRuntimePlatformString()); Console.Error.WriteLine("Usage:"); Console.Error.Write(" console.exe"); Console.Error.Write(" -lat N.63.25.47"); Console.Error.Write(" -lon E.10.23.36"); Console.Error.Write(" -dt 21.06.2009"); Console.Error.Write(" -tm 12:00:00"); Console.Error.Write(" -tz 1"); Console.Error.WriteLine("\nOptions:"); p.WriteOptionDescriptions(Console.Error); return; } if (bench) { Bench(step, timebased, verbose); return; } try { Calc(imgsz, longitude, latitude, timezone, date, time); } catch (ArgumentException e) { Console.WriteLine(e.Message); } }