AcManager.AppArguments.Initialize C# (CSharp) Method

Initialize() public static method

public static Initialize ( IEnumerable args ) : void
args IEnumerable
return void
        public static void Initialize(IEnumerable<string> args) {
            var list = args.ToList();

            _args = list.TakeWhile(x => x != "-")
                .Where(x => x.StartsWith("--"))
                .Select(x => x.Split(new[] { '=' }, 2))
                .Select(x => new {
                    Key = ArgStringToFlag(x[0]),
                    Value = x.Length == 2 ? x[1] : null
                })
                .Where(x => x.Key != null)
                .ToDictionary(x => x.Key.Value, x => x.Value);

            Values = list.Where(x => !x.StartsWith("-"))
                         .Union(list.SkipWhile(x => x != "-").Skip(1).Where(x => x.StartsWith("-"))).ToList();
        }

Usage Example

Exemplo n.º 1
0
        private static void MainReal(string[] a)
        {
            if (!Debugger.IsAttached)
            {
                SetUnhandledExceptionHandler();
            }

            AppArguments.Initialize(a);
            var data = AppArguments.Get(AppFlag.StorageLocation);

            if (!string.IsNullOrWhiteSpace(data))
            {
                ApplicationDataDirectory = Path.GetFullPath(data);
            }
            else
            {
                var exe = Assembly.GetEntryAssembly().Location;
                ApplicationDataDirectory = Path.GetFileName(exe).IndexOf("local", StringComparison.OrdinalIgnoreCase) != -1
                        ? Path.Combine(Path.GetDirectoryName(exe) ?? Path.GetFullPath("."), "Data")
                        : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AcTools Content Manager");
            }

            if (AppArguments.GetBool(AppFlag.VisualStyles, true))
            {
                Application.EnableVisualStyles();
            }

            AppArguments.AddFromFile(Path.Combine(ApplicationDataDirectory, "Arguments.txt"));
            RenameContentToData();

#if COSTURA
            CosturaUtility.Initialize();
#else
            var logFilename = AppArguments.GetBool(AppFlag.LogPacked) ? GetLogName("Packed Log") : null;
            AppArguments.Set(AppFlag.DirectAssembliesLoading, ref PackedHelper.OptionDirectLoading);

            var packedHelper = new PackedHelper("AcTools_ContentManager", "References", logFilename);
            packedHelper.PrepareUnmanaged("LevelDB");
            AppDomain.CurrentDomain.AssemblyResolve += packedHelper.Handler;
#endif

            MainInner(a);
        }