Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Stitch Command Line Compiler {0}", Assembly.GetExecutingAssembly().GetName().Version.ToString());
            Console.WriteLine("Copyright (C) 2011 Nathan Palmer");
            Console.WriteLine("http://github.com/nathanpalmer/stitch-aspnet");
            Console.WriteLine();

            try
            {
                var options = new Options();
                var configuration = new Settings();
                options.Add("r=|root=", "Root path (default is working directory)", v => configuration.Root = v);
                options.Add("p=|paths=", "Comma delimited list of paths that should be compiled", v => configuration.Paths = v.Split(','));
                options.Add("d=|dep=", "Comma delimited list of dependencies that should be included", v => configuration.Dependencies = v.Split(','));
                options.Add("i=|identifier=", "Identifier to use for including other files (default is require)", v => configuration.Identifier = v);
                options.Add("c=|compilers=", "Comma delimited list of compilers to use (default is CoffeeScriptCompiler, JavaScriptCompiler)", v => configuration.Compilers = v.Split(',').Select(compiler => (ICompile) Activator.CreateInstance(Type.GetType("Stitch.Compilers." + compiler + ", Stitch.Core"))).ToArray());

                if (args.Length == 0)
                {
                    ShowHelp(options, "No arguments specified.");
                }
                else
                {
                    var extra = options.Parse(args).ToArray();
                    if (extra.Length > 1)
                    {
                        Console.WriteLine("The following arguments did not parse.\r\n\r\n" + string.Join(",", extra));
                    }
                    else if (extra.Length == 1)
                    {
                        var file = new FileInfo(extra[0]);
                        if (file.Exists)
                        {
                            file.Delete();
                        }

                        Console.WriteLine("Generating {0}", file.Name);

                        var package = new Package(
                            configuration.Root,
                            configuration.Paths,
                            configuration.Dependencies,
                            configuration.Identifier ?? "require",
                            configuration.Compilers);

                        File.WriteAllText(file.FullName, package.Compile());
                    }
                    else
                    {
                        ShowHelp(options, "You must specify a destination.");
                        return;
                    }

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Fatal Exception: " + ex.ToString());
            }
        }
        public static Dictionary<int, Changelist> GetPendingChangelists()
        {
            var repo = GetRepository();

            var options = new Options();
            options.Add("-s", "pending");
            options.Add("-u", AutoDetectP4Setting(P4Setting.P4USER));
            options.Add("-l", ""); // full text description

            return repo.GetChangelists(options).ToDictionary(changelist => changelist.Id);
        }
 public void AddValue()
 {
     var options = new Options();
     options.Add("MyTest", "result");
     Assert.AreEqual(1, options.Count);
     Assert.AreEqual("result", options["MyTest"]);
 }
Beispiel #4
0
        public void ShouldAllowLookupOfAllAddedValuesForEachKey()
        {
            var lookup = new Options();

            lookup.Add("A", "A1");
            lookup.Add("B", "B1");
            lookup.Add("A", "A2");
            lookup.Add("A", "A3");

            lookup.Count.ShouldEqual(2);
            lookup.Keys.ShouldEqual("A", "B");
            lookup.Contains("A").ShouldBeTrue();
            lookup.Contains("B").ShouldBeTrue();
            lookup.Contains("C").ShouldBeFalse();
            lookup["A"].ShouldEqual("A1", "A2", "A3");
            lookup["B"].ShouldEqual("B1");
        }
Beispiel #5
0
        public CommandLineParser(params string[] args)
        {
            var queue = new Queue<string>(args);

            var assemblyPaths = new List<string>();
            var options = new Options();
            var errors = new List<string>();

            while (queue.Any())
            {
                var item = queue.Dequeue();

                if (IsKey(item))
                {
                    if (!queue.Any() || IsKey(queue.Peek()))
                    {
                        errors.Add($"Option {item} is missing its required value.");
                        break;
                    }

                    var key = KeyName(item);
                    var value = queue.Dequeue();

                    options.Add(key, value);
                }
                else
                {
                    assemblyPaths.Add(item);
                }
            }

            if (!errors.Any() && !assemblyPaths.Any())
                errors.Add("Missing required test assembly path(s).");

            foreach (var assemblyPath in assemblyPaths)
            {
                if (!File.Exists(assemblyPath))
                    errors.Add("Specified test assembly does not exist: " + assemblyPath);
                else if (!AssemblyDirectoryContainsFixie(assemblyPath))
                    errors.Add($"Specified assembly {assemblyPath} does not appear to be a test assembly. Ensure that it references Fixie.dll and try again.");
            }

            AssemblyPaths = assemblyPaths.ToArray();
            Options = options;
            Errors = errors.ToArray();
        }
Beispiel #6
0
        public CommandLineParser(params string[] args)
        {
            var queue = new Queue<string>(args);

            var assemblyPaths = new List<string>();
            var options = new Options();
            var errors = new List<string>();

            while (queue.Any())
            {
                var item = queue.Dequeue();

                if (IsKey(item))
                {
                    if (!queue.Any() || IsKey(queue.Peek()))
                    {
                        errors.Add($"Option {item} is missing its required value.");
                        break;
                    }

                    var key = KeyName(item);
                    var value = queue.Dequeue();

                    options.Add(key, value);
                }
                else
                {
                    assemblyPaths.Add(item);
                }
            }

            if (!errors.Any() && !assemblyPaths.Any())
                errors.Add("Missing required test assembly path(s).");

            foreach (var assemblyPath in assemblyPaths)
                if (!File.Exists(assemblyPath))
                    errors.Add("Specified test assembly does not exist: " + assemblyPath);

            AssemblyPaths = assemblyPaths.ToArray();
            Options = options;
            Errors = errors.ToArray();
        }
Beispiel #7
0
        public CommandLineParser(params string[] args)
        {
            var queue = new Queue<string>(args);

            var assemblyPaths = new List<string>();
            var optionList = new Options();
            var errors = new List<string>();

            while (queue.Any())
            {
                var item = queue.Dequeue();

                if (IsKey(item))
                {
                    if (!queue.Any() || IsKey(queue.Peek()))
                    {
                        errors.Add(string.Format("Option {0} is missing its required value.", item));
                        break;
                    }

                    var key = KeyName(item);
                    var value = queue.Dequeue();

                    optionList.Add(key, value);
                }
                else
                {
                    assemblyPaths.Add(item);
                }
            }

            if (!errors.Any() && !assemblyPaths.Any())
                errors.Add("Missing required test assembly path(s).");

            AssemblyPaths = assemblyPaths.ToArray();
            Options = optionList;
            Errors = errors.ToArray();
        }
        /// <summary>
        /// Submit all in the default changelist
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void submitAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CheckConnect())
            {
                using (Connection P4Connection = P4Repository.Connection)
                {
                    try
                    {
                        //revert unchanged files.
                        List<FileSpec> FileSpecsToRevert = new List<FileSpec>();
                        foreach (string File in FilesCheckedOut)
                        {
                            FileSpecsToRevert.Add(new FileSpec(new DepotPath(File), null, null, null));
                        }

                        Options RevertOptions = new Options();

                        //Only files  that are open for edit or integrate and are unchanged or missing
                        RevertOptions.Add("-a", null);

                        P4Connection.Client.RevertFiles(RevertOptions, FileSpecsToRevert.ToArray());

                        // Submit remaining changelist
                        Options SubmitOptions = new Options();

                        //Add a description
                        SubmitOptions.Add("-d", String.Format(Settings.Default.SubmitChangelistDescription, _connectionDetails.UserSavedStatePreferredLanguage));

                        SubmitResults UpdatesInsertsSubmitResults = P4Connection.Client.SubmitFiles(SubmitOptions, null);

                        log.Info(String.Format("Updated and New files submitted in CL# {0}, Files affected:", UpdatesInsertsSubmitResults.ChangeIdAfterSubmit));
                        foreach (var SubmittedFile in UpdatesInsertsSubmitResults.Files)
                        {
                            log.Info(String.Format("\t{0}:\t{1}({2})", SubmittedFile.Action, SubmittedFile.File.DepotPath, SubmittedFile.File.Version));
                        }

                        //Clear checked out files.
                        FilesCheckedOut.Clear();

                        //Mark lines black text
                        foreach (ListViewItem line in FileListView.Items)
                        {
                            line.ForeColor = Color.Black;
                        }
                    }
                    catch (P4Exception ex)
                    {
                        //Swallow No files to submit error
                        if (ex.ErrorCode != 806427698)
                        {
                            log.Error("Error in submitting changelist:");
                            log.Error(ex.Message);
                        }
                    }
                }
            }
        }
Beispiel #9
0
 /// <inheritdoc/>
 public Central([NotNull] ICommandHandler handler) : base(handler)
 {
     Options.Add("m|machine", () => Resources.OptionMachine, _ => _machineWide = true);
 }
        /// <summary>
        /// Get the FileSpec for a depot file given a changelist
        /// </summary>
        /// <param name="depotFileName">The file name in current depot location</param>
        /// <param name="changelist">The language file's changelist to be used to find an older version of the int file</param>
        /// <param name="checkForRenameMove">Check if the file has changed names due to a move/rename</param>
        /// <returns>FileSpec which may have a different depotfilename than that passed into function if the file has been moved since changelist</returns>
        private FileSpec GetIntFileSpecForFileChangelist(string depotFileName, int changelist, bool checkForRenameMove)
        {
            if (!CheckConnect())
            {
                return null;
            }

            if (checkForRenameMove)
            {
                PathSpec HistoryPathSpec = new DepotPath(depotFileName) as PathSpec;

                FileSpec[] HistoryFiles = new FileSpec[1];
                HistoryFiles[0] = new FileSpec(HistoryPathSpec, VersionSpec.Head);

                Options Opts = new Options();
                Opts.Add("-i", "");
                IList<FileHistory> History = P4Repository.GetFileHistory(Opts, HistoryFiles);

                // walk through history until we find the first changelist older than the specified changelist
                foreach (FileHistory Item in History)
                {
                    if (Item.ChangelistId > changelist)
                    {
                        continue;
                    }

                    // use the depot filename at this revision
                    HistoryPathSpec = Item.DepotPath;
                    break;
                }

                return new FileSpec(HistoryPathSpec, new ChangelistIdVersion(changelist));
            }
            else
            {
                return new FileSpec(new DepotPath(depotFileName) as PathSpec, new ChangelistIdVersion(changelist));
            }
        }
Beispiel #11
0
 public CommandSet Add(string prototype, string description, OptionAction <string, string> action, bool hidden)
 {
     Options.Add(prototype, description, action, hidden);
     return(this);
 }
Beispiel #12
0
 public CommandSet Add <T>(string prototype, string description, Action <T> action)
 {
     Options.Add(prototype, description, action);
     return(this);
 }
 public CommandSet Add(ArgumentSource source)
 {
     Options.Add(source);
     return(this);
 }
        public bool Unpack(MemoryStream stream)
        {
            {
                TDSPreLoginOptionToken option;
                do
                {
                    option = new TDSPreLoginOptionToken();
                    option.Unpack(stream);
                    Options.Add(option);
                }while (option.Type != TDSPreLoginOptionTokenType.Terminator);
            }
            foreach (var option in Options)
            {
                switch (option.Type)
                {
                case TDSPreLoginOptionTokenType.Encryption:
                {
                    Encryption = (TDSEncryptionOption)stream.ReadByte();
                    break;
                }

                case TDSPreLoginOptionTokenType.FedAuthRequired:
                {
                    FedAuthRequired = stream.ReadByte() == 1;
                    break;
                }

                case TDSPreLoginOptionTokenType.InstOpt:
                {
                    throw new NotSupportedException();
                }

                case TDSPreLoginOptionTokenType.MARS:
                {
                    MARS = stream.ReadByte() == 1;
                    break;
                }

                case TDSPreLoginOptionTokenType.NonceOpt:
                {
                    Nonce = BigEndianUtilities.ReadByteArray(stream, 32);
                    break;
                }

                case TDSPreLoginOptionTokenType.ThreadID:
                {
                    ThreadID = BigEndianUtilities.ReadULong(stream);
                    break;
                }

                case TDSPreLoginOptionTokenType.TraceID:
                {
                    TraceID = new TDSClientTraceID();
                    TraceID.Unpack(stream);
                    break;
                }

                case TDSPreLoginOptionTokenType.Version:
                {
                    ClientVersion = new TDSClientVersion();
                    ClientVersion.Unpack(stream);
                    break;
                }

                case TDSPreLoginOptionTokenType.Terminator:
                {
                    break;
                }
                }
            }
            Terminated = true;
            return(true);
        }
Beispiel #15
0
        public int Run(IEnumerable <string> arguments)
        {
            if (arguments == null)
            {
                throw new ArgumentNullException(nameof(arguments));
            }

            showHelp = false;
            if (help == null)
            {
                help = new HelpCommand();
                addCommand(help);
            }

            void setHelp(string v) => showHelp = v != null;

            if (!Options.Contains("help"))
            {
                Options.Add("help", "", setHelp, true);
            }

            if (!Options.Contains("?"))
            {
                Options.Add("?", "", setHelp, true);
            }

            List <string> extra = Options.Parse(arguments);

            if (!extra.Any())
            {
                if (showHelp)
                {
                    return(help.Invoke(extra));
                }

                Out.WriteLine(Options.MessageLocalizer($"Use `{Suite} help` for usage."));
                return(1);
            }

            Command command = GetCommand(extra);

            if (command == null)
            {
                help.WriteUnknownCommand(extra[0]);
                return(1);
            }

            if (showHelp)
            {
                if (command.Options?.Contains("help") ?? true)
                {
                    extra.Add("--help");
                    return(command.Invoke(extra));
                }

                command.Options.WriteOptionDescriptions(Out);
                return(0);
            }

            return(command.Invoke(extra));
        }
Beispiel #16
0
 public void AddOption(MenuOption option)
 {
     Options.Add(option);
 }
Beispiel #17
0
 public GridScenario() : base("grid")
 {
     Options.Add(_gridTypeOption);
 }
Beispiel #18
0
        static MySqlConnectionStringBuilder()
        {
            // Server options
            Options.Add(new MySqlConnectionStringOption("pipe", "pipe name,pipename", typeof(string), "MYSQL", false,
                                                        (msb, sender, value) =>
            {
#if NETSTANDARD1_6 || NETSTANDARD2_0 || NETCOREAPP2_0
                throw new PlatformNotSupportedException(string.Format(Resources.OptionNotCurrentlySupported, nameof(PipeName)));
#else
                msb.SetValue("pipe", value);
#endif
            },
                                                        (msb, sender) => msb.PipeName));
            Options.Add(new MySqlConnectionStringOption("compress", "use compression,usecompression", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("compress", value); }, (msb, sender) => msb.UseCompression));
            Options.Add(new MySqlConnectionStringOption("allowbatch", "allow batch", typeof(bool), true, false,
                                                        (msb, sender, value) => { msb.SetValue("allowbatch", value); }, (msb, sender) => msb.AllowBatch));
            Options.Add(new MySqlConnectionStringOption("logging", null, typeof(bool), false, false,
                                                        (msb, sender, value) =>
            {
#if NETSTANDARD1_6
                throw new PlatformNotSupportedException(string.Format(Resources.OptionNotCurrentlySupported, nameof(Logging)));
#else
                msb.SetValue("logging", value);
#endif
            },
                                                        (msb, sender) => msb.Logging));
            Options.Add(new MySqlConnectionStringOption("sharedmemoryname", "shared memory name", typeof(string), "MYSQL", false,
                                                        (msb, sender, value) =>
            {
#if NETSTANDARD1_6 || NETSTANDARD2_0 || NETCOREAPP2_0
                throw new PlatformNotSupportedException(string.Format(Resources.OptionNotCurrentlySupported, nameof(SharedMemoryName)));
#else
                msb.SetValue("sharedmemoryname", value);
#endif
            },
                                                        (msb, sender) => msb.SharedMemoryName));
            Options.Add(new MySqlConnectionStringOption("defaultcommandtimeout", "command timeout,default command timeout", typeof(uint), (uint)30, false,
                                                        (msb, sender, value) => { msb.SetValue("defaultcommandtimeout", value); }, (msb, sender) => msb.DefaultCommandTimeout));
            Options.Add(new MySqlConnectionStringOption("usedefaultcommandtimeoutforef", "use default command timeout for ef", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("usedefaultcommandtimeoutforef", value); }, (msb, sender) => msb.UseDefaultCommandTimeoutForEF));
            Options.Add(new MySqlConnectionStringOption("connectiontimeout", "connection timeout,connect timeout", typeof(uint), (uint)15, false,
                                                        delegate(MySqlConnectionStringBuilder msb, MySqlConnectionStringOption sender, object Value)
            {
                uint value = (uint)Convert.ChangeType(Value, sender.BaseType);
                // Timeout in milliseconds should not exceed maximum for 32 bit
                // signed integer (~24 days). We truncate the value if it exceeds
                // maximum (MySqlCommand.CommandTimeout uses the same technique
                uint timeout = Math.Min(value, Int32.MaxValue / 1000);
                if (timeout != value)
                {
                    MySqlTrace.LogWarning(-1, "Connection timeout value too large ("
                                          + value + " seconds). Changed to max. possible value" +
                                          +timeout + " seconds)");
                }
                msb.SetValue("connectiontimeout", timeout);
            },
                                                        (msb, sender) => (uint)msb.values["connectiontimeout"]
                                                        ));
            Options.Add(new MySqlConnectionStringOption("allowloadlocalinfile", "allow load local infile", typeof(bool), false, false));

            // Authentication options.
            Options.Add(new MySqlConnectionStringOption("persistsecurityinfo", "persist security info", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("persistsecurityinfo", value); }, (msb, sender) => msb.PersistSecurityInfo));
            Options.Add(new MySqlConnectionStringOption("integratedsecurity", "integrated security", typeof(bool), false, false,
                                                        delegate(MySqlConnectionStringBuilder msb, MySqlConnectionStringOption sender, object value)
            {
                if (!Platform.IsWindows())
                {
                    throw new MySqlException("IntegratedSecurity is supported on Windows only");
                }
#if NETSTANDARD1_6 || NETSTANDARD2_0 || NETCOREAPP2_0
                throw new PlatformNotSupportedException(string.Format(Resources.OptionNotCurrentlySupported, nameof(IntegratedSecurity)));
#else
                msb.SetValue("Integrated Security", value.ToString().Equals("SSPI", StringComparison.OrdinalIgnoreCase) ? true : value);
#endif
            },
                                                        delegate(MySqlConnectionStringBuilder msb, MySqlConnectionStringOption sender)
            {
                object val = msb.values["integratedsecurity"];
                return((bool)val);
            }
                                                        ));
            Options.Add(new MySqlConnectionStringOption("allowpublickeyretrieval", null, typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("allowpublickeyretrieval", value); }, (msb, sender) => msb.AllowPublicKeyRetrieval));

            // Other properties.
#if !NETSTANDARD1_6
            Options.Add(new MySqlConnectionStringOption("autoenlist", "auto enlist", typeof(bool), true, false,
                                                        (msb, sender, value) => { msb.SetValue("autoenlist", value); }, (msb, sender) => msb.AutoEnlist));
            Options.Add(new MySqlConnectionStringOption("includesecurityasserts", "include security asserts", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("includesecurityasserts", value); }, (msb, sender) => msb.IncludeSecurityAsserts));
#endif
            Options.Add(new MySqlConnectionStringOption("allowzerodatetime", "allow zero datetime", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("allowzerodatetime", value); }, (msb, sender) => msb.AllowZeroDateTime));
            Options.Add(new MySqlConnectionStringOption("convertzerodatetime", "convert zero datetime", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("convertzerodatetime", value); }, (msb, sender) => msb.ConvertZeroDateTime));
            Options.Add(new MySqlConnectionStringOption("useusageadvisor", "use usage advisor,usage advisor", typeof(bool), false, false,
                                                        (msb, sender, value) =>
            {
#if NETSTANDARD1_6
                throw new PlatformNotSupportedException(string.Format(Resources.OptionNotCurrentlySupported, nameof(UseUsageAdvisor)));
#else
                msb.SetValue("useusageadvisor", value);
#endif
            },
                                                        (msb, sender) => msb.UseUsageAdvisor));
            Options.Add(new MySqlConnectionStringOption("procedurecachesize", "procedure cache size,procedure cache,procedurecache", typeof(uint), (uint)25, false,
                                                        (msb, sender, value) => { msb.SetValue("procedurecachesize", value); }, (msb, sender) => msb.ProcedureCacheSize));
            Options.Add(new MySqlConnectionStringOption("useperformancemonitor", "use performance monitor,useperfmon,perfmon", typeof(bool), false, false,
                                                        (msb, sender, value) =>
            {
#if NETSTANDARD1_6 || NETSTANDARD2_0 || NETCOREAPP2_0
                throw new PlatformNotSupportedException(string.Format(Resources.OptionNotCurrentlySupported, nameof(UsePerformanceMonitor)));
#else
                msb.SetValue("useperformancemonitor", value);
#endif
            },
                                                        (msb, sender) => msb.UsePerformanceMonitor));
            Options.Add(new MySqlConnectionStringOption("ignoreprepare", "ignore prepare", typeof(bool), true, false,
                                                        (msb, sender, value) => { msb.SetValue("ignoreprepare", value); }, (msb, sender) => msb.IgnorePrepare));
            Options.Add(new MySqlConnectionStringOption("respectbinaryflags", "respect binary flags", typeof(bool), true, false,
                                                        (msb, sender, value) => { msb.SetValue("respectbinaryflags", value); }, (msb, sender) => msb.RespectBinaryFlags));
            Options.Add(new MySqlConnectionStringOption("treattinyasboolean", "treat tiny as boolean", typeof(bool), true, false,
                                                        (msb, sender, value) => { msb.SetValue("treattinyasboolean", value); }, (msb, sender) => msb.TreatTinyAsBoolean));
            Options.Add(new MySqlConnectionStringOption("allowuservariables", "allow user variables", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("allowuservariables", value); }, (msb, sender) => msb.AllowUserVariables));
            Options.Add(new MySqlConnectionStringOption("interactivesession", "interactive session,interactive", typeof(bool), false, false,
                                                        (msb, sender, value) =>
            {
#if NETSTANDARD1_6
                throw new PlatformNotSupportedException(string.Format(Resources.OptionNotCurrentlySupported, nameof(InteractiveSession)));
#else
                msb.SetValue("interactivesession", value);
#endif
            },
                                                        (msb, sender) => msb.InteractiveSession));
            Options.Add(new MySqlConnectionStringOption("functionsreturnstring", "functions return string", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("functionsreturnstring", value); }, (msb, sender) => msb.FunctionsReturnString));
            Options.Add(new MySqlConnectionStringOption("useaffectedrows", "use affected rows", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("useaffectedrows", value); }, (msb, sender) => msb.UseAffectedRows));
            Options.Add(new MySqlConnectionStringOption("oldguids", "old guids", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("oldguids", value); }, (msb, sender) => msb.OldGuids));
            Options.Add(new MySqlConnectionStringOption("sqlservermode", "sql server mode", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("sqlservermode", value); }, (msb, sender) => msb.SqlServerMode));
            Options.Add(new MySqlConnectionStringOption("tablecaching", "table cache,tablecache", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("tablecaching", value); }, (msb, sender) => msb.TableCaching));
            Options.Add(new MySqlConnectionStringOption("defaulttablecacheage", "default table cache age", typeof(int), (int)60, false,
                                                        (msb, sender, value) => { msb.SetValue("defaulttablecacheage", value); }, (msb, sender) => msb.DefaultTableCacheAge));
            Options.Add(new MySqlConnectionStringOption("checkparameters", "check parameters", typeof(bool), true, false,
                                                        (msb, sender, value) => { msb.SetValue("checkparameters", value); }, (msb, sender) => msb.CheckParameters));
            Options.Add(new MySqlConnectionStringOption("replication", null, typeof(bool), false, false,
                                                        (msb, sender, value) =>
            {
#if NETSTANDARD1_6
                throw new PlatformNotSupportedException(string.Format(Resources.OptionNotCurrentlySupported, nameof(Replication)));
#else
                msb.SetValue("replication", value);
#endif
            },
                                                        (msb, sender) => msb.Replication));
            Options.Add(new MySqlConnectionStringOption("exceptioninterceptors", "exception interceptors", typeof(string), null, false,
                                                        (msb, sender, value) => { msb.SetValue("exceptioninterceptors", value); }, (msb, sender) => msb.ExceptionInterceptors));
            Options.Add(new MySqlConnectionStringOption("commandinterceptors", "command interceptors", typeof(string), null, false,
                                                        (msb, sender, value) => { msb.SetValue("commandinterceptors", value); }, (msb, sender) => msb.CommandInterceptors));

            // Pooling options.
            Options.Add(new MySqlConnectionStringOption("connectionlifetime", "connection lifetime", typeof(uint), (uint)0, false,
                                                        (msb, sender, value) => { msb.SetValue("connectionlifetime", value); }, (msb, sender) => msb.ConnectionLifeTime));
            Options.Add(new MySqlConnectionStringOption("pooling", null, typeof(bool), true, false,
                                                        (msb, sender, value) => { msb.SetValue("pooling", value); }, (msb, sender) => msb.Pooling));
            Options.Add(new MySqlConnectionStringOption("minpoolsize", "minimumpoolsize,min pool size,minimum pool size", typeof(uint), (uint)0, false,
                                                        (msb, sender, value) => { msb.SetValue("minpoolsize", value); }, (msb, sender) => msb.MinimumPoolSize));
            Options.Add(new MySqlConnectionStringOption("maxpoolsize", "maximumpoolsize,max pool size,maximum pool size", typeof(uint), (uint)100, false,
                                                        (msb, sender, value) => { msb.SetValue("maxpoolsize", value); }, (msb, sender) => msb.MaximumPoolSize));
            Options.Add(new MySqlConnectionStringOption("connectionreset", "connection reset", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("connectionreset", value); }, (msb, sender) => msb.ConnectionReset));
            Options.Add(new MySqlConnectionStringOption("cacheserverproperties", "cache server properties", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("cacheserverproperties", value); }, (msb, sender) => msb.CacheServerProperties));

            // Language and charset options.
            Options.Add(new MySqlConnectionStringOption("treatblobsasutf8", "treat blobs as utf8", typeof(bool), false, false,
                                                        (msb, sender, value) => { msb.SetValue("treatblobsasutf8", value); }, (msb, sender) => msb.TreatBlobsAsUTF8));
            Options.Add(new MySqlConnectionStringOption("blobasutf8includepattern", null, typeof(string), "", false,
                                                        (msb, sender, value) => { msb.SetValue("blobasutf8includepattern", value); }, (msb, sender) => msb.BlobAsUTF8IncludePattern));
            Options.Add(new MySqlConnectionStringOption("blobasutf8excludepattern", null, typeof(string), "", false,
                                                        (msb, sender, value) => { msb.SetValue("blobasutf8excludepattern", value); }, (msb, sender) => msb.BlobAsUTF8ExcludePattern));
        }
Beispiel #19
0
 /// <inheritdoc/>
 public AddApp([NotNull] ICommandHandler handler) : base(handler)
 {
     Options.Add("no-download", () => Resources.OptionNoDownload, _ => NoDownload = true);
 }
 /// <summary>
 /// Adds the element to the options collection.
 /// </summary>
 /// <param name="element">The group element to add.</param>
 /// <param name="before">The following element.</param>
 public void AddOption(IHtmlOptionsGroupElement element, IHtmlElement before = null)
 {
     Options.Add(element, before);
 }
        public void AddOption(TDSPreLoginOptionTokenType type, Object data)
        {
            if (Terminated)
            {
                throw new InvalidOperationException();
            }

            switch (type)
            {
            case TDSPreLoginOptionTokenType.Version:
            {
                if (data is TDSClientVersion && ClientVersion == null)
                {
                    ClientVersion = (TDSClientVersion)data;

                    LoggingUtilities.WriteLogVerboseOnly($" Adding PreLogin option {type.ToString()}.");
                }
                else
                {
                    throw new ArgumentException();
                }
                break;
            }

            case TDSPreLoginOptionTokenType.Encryption:
            {
                if (data is TDSEncryptionOption)
                {
                    Encryption = (TDSEncryptionOption)data;

                    LoggingUtilities.WriteLogVerboseOnly($" Adding PreLogin option {type.ToString()} [{Encryption.ToString()}].");
                }
                else
                {
                    throw new ArgumentException();
                }
                break;
            }

            case TDSPreLoginOptionTokenType.FedAuthRequired | TDSPreLoginOptionTokenType.MARS:
            {
                if (data is bool)
                {
                    if (type == TDSPreLoginOptionTokenType.FedAuthRequired)
                    {
                        FedAuthRequired = (bool)data;
                    }
                    else
                    {
                        MARS = (bool)data;
                    }

                    LoggingUtilities.WriteLogVerboseOnly($" Adding PreLogin option {type.ToString()} [{(bool)data}].");
                }
                else
                {
                    throw new ArgumentException();
                }
                break;
            }

            case TDSPreLoginOptionTokenType.ThreadID:
            {
                if (data is ulong)
                {
                    ThreadID = (ulong)data;

                    LoggingUtilities.WriteLogVerboseOnly($" Adding PreLogin option {type.ToString()} [{ThreadID}].");
                }
                else
                {
                    throw new ArgumentException();
                }
                break;
            }

            case TDSPreLoginOptionTokenType.TraceID:
            {
                if (data is TDSClientTraceID)
                {
                    TraceID = (TDSClientTraceID)data;

                    LoggingUtilities.WriteLogVerboseOnly($" Adding PreLogin option {type.ToString()}.");
                }
                else
                {
                    throw new ArgumentException();
                }
                break;
            }

            case TDSPreLoginOptionTokenType.NonceOpt:
            {
                if (data is byte[])
                {
                    Nonce = (byte[])data;

                    LoggingUtilities.WriteLogVerboseOnly($" Adding PreLogin option {type.ToString()}.");
                }
                else
                {
                    throw new ArgumentException();
                }
                break;
            }

            default:
            {
                throw new NotSupportedException();
            }
            }

            Options.Add(new TDSPreLoginOptionToken(type));
        }
Beispiel #22
0
        static int Main(string[] args)
        {
            try
            {
                var directories = new List <string>();
                var files       = new List <string>();

                var programCommand = Command.None;
                Func <CompositionContractInfo, bool>             contractPredicate = c => false;
                Func <CompositionInfo, PartDefinitionInfo, bool> partPredicate     = (ci, p) => false;
                var verbose   = false;
                var whitelist = new RejectionWhitelist();

                var opts = new Options();

                opts.Add <string>("dir", @"C:\MyApp\Parts", "Specify directories to search for parts.",
                                  d => directories.Add(d));
                opts.Add <string>("file", "MyParts.dll", "Specify assemblies to search for parts.",
                                  f => files.Add(f));
                opts.AddSwitch("verbose", "Print verbose information on each part.",
                               () => verbose = true);

                var programCommandGroup = new ExclusiveGroup();

                opts.Add <string>("type", "MyNamespace.MyType", "Print details of the given part type.", t => {
                    programCommand = Command.PrintParts;
                    partPredicate  = AddToPredicate(partPredicate, (ci, p) => p == ci.GetPartDefinitionInfo(t));
                },
                                  programCommandGroup);

                opts.Add <string>("importers", "MyContract", "List importers of the given contract.", i => {
                    programCommand = Command.PrintParts;
                    partPredicate  = AddToPredicate(partPredicate, (ci, p) => p.ImportsContract(i));
                },
                                  programCommandGroup);

                opts.Add <string>("exporters", "MyContract", "List exporters of the given contract.", e => {
                    programCommand = Command.PrintParts;
                    partPredicate  = AddToPredicate(partPredicate, (ci, p) => p.ExportsContract(e));
                },
                                  programCommandGroup);

                opts.AddSwitch("rejected", "List all rejected parts.", () => {
                    programCommand = Command.PrintParts;
                    partPredicate  = AddToPredicate(partPredicate, (ci, p) => p.IsRejected);
                },
                               programCommandGroup);

                opts.AddSwitch("causes", "List root causes - parts with errors not related to the rejection of other parts.", () => {
                    programCommand = Command.PrintParts;
                    partPredicate  = AddToPredicate(partPredicate, (ci, p) => p.IsPrimaryRejection);
                },
                               programCommandGroup);

                opts.Add <string>("whitelist", "RejectionWhitelist.txt", "Specify parts that may be validly rejected; requres the /rejected or /causes commands.",
                                  w => whitelist = new RejectionWhitelist(w));

                opts.AddSwitch("parts", "List all parts found in the source assemblies.", () => {
                    programCommand = Command.PrintParts;
                    partPredicate  = AddToPredicate(partPredicate, (ci, p) => true);
                },
                               programCommandGroup);

                opts.AddSwitch("?", "Print usage.",
                               () => programCommand = Command.PrintUsage, programCommandGroup);

                var contractsSubgroup = new InclusiveSubroup(programCommandGroup);
                opts.AddSwitch("imports", "Find imported contracts.", () => {
                    programCommand    = Command.PrintContracts;
                    contractPredicate = AddToPredicate(contractPredicate, c => c.Importers.Any());
                },
                               contractsSubgroup);

                opts.AddSwitch("exports", "Find exported contracts.", () => {
                    programCommand    = Command.PrintContracts;
                    contractPredicate = AddToPredicate(contractPredicate, c => c.Exporters.Any());
                },
                               contractsSubgroup);

                opts.Parse(args);

                return(Run(directories, files, programCommand, contractPredicate, partPredicate, verbose, whitelist, opts));
            }
            catch (Exception ex)
            {
                Console.Write("Error: ");
                Console.WriteLine(ex.Message);
                return(1);
            }
        }
 private void SaveAsset(Option option)
 {
     Options.Add(option);
     SaveChanges();
 }
 public CommandSet Add <TKey, TValue>(string prototype, string description, OptionAction <TKey, TValue> action)
 {
     Options.Add(prototype, description, action);
     return(this);
 }
Beispiel #25
0
 public CommandSet Add(Option option)
 {
     Options.Add(option);
     return(this);
 }
Beispiel #26
0
 public ImportCertificateCommand()
 {
     Options.Add("variables=", "Path to a JSON file containing variables.", v => variablesFile = Path.GetFullPath(v));
     Options.Add("sensitiveVariables=", "Password protected JSON file containing sensitive-variables.", v => sensitiveVariablesFile = v);
     Options.Add("sensitiveVariablesPassword="******"Password used to decrypt sensitive-variables.", v => sensitiveVariablesPassword    = v);
 }
Beispiel #27
0
 public ClusterCommand() : base(names, help, helpHeaders)
 {
     Options.Add("write-all-fields", "Writes all the fields.", s => writeAllFields = s != null);
 }
Beispiel #28
0
 /// <inheritdoc/>
 public UpdateApps([NotNull] ICommandHandler handler) : base(handler)
 {
     Options.Add("c|clean", () => Resources.OptionClean, _ => _clean = true);
 }
Beispiel #29
0
 public Select <T> Add(SelectOption <T> option)
 {
     Options.Add(option);
     return(this);
 }
Beispiel #30
0
 public CommandSet Add(string header)
 {
     Options.Add(header);
     return(this);
 }
Beispiel #31
0
 public void Add(TextViewGroupOption option) => Options.Add(option);
Beispiel #32
0
 public CommandSet Add(string prototype, OptionAction <string, string> action)
 {
     Options.Add(prototype, action);
     return(this);
 }
		/// <summary>
		/// Query the server for multiple changelists in a range specified by the query parameter
		/// </summary>
		/// <param name="InQuery">Changelist query representing a start and end changelist number to query the Perforce server for changelists between</param>
		/// <return>Returns a list of changelists</return>
        public IList<Changelist> QueryChangelists(P4ChangelistSpanQuery InQuery)
		{
            IList<Changelist> ChangelistRecordSet = null;

			// Only attempt to query if actually connected
			if (ConnectionStatus == EP4ConnectionStatus.P4CS_Connected)
			{
				try
				{
                    Options options = new Options();
                    
                    //Extended descriptions
                    options.Add("-l",null);

                    //Only submitted changelists
                    options.Add("-s", "submitted");

                    //Filter by user
                    if (!string.IsNullOrWhiteSpace(InQuery.FilterUser))
                    {
                        options.Add("-u", InQuery.FilterUser);
                    }

                    ChangelistRecordSet = mP4Repository.GetChangelists(options, InQuery.FileFilter);
				}
				catch (P4Exception E)
				{
					Console.WriteLine("Error running Perforce command!\n{0}", E.Message);
				}
			}
            return ChangelistRecordSet;
		}
Beispiel #34
0
 public CommandSet Add <T>(string prototype, Action <T> action)
 {
     Options.Add(prototype, null, action);
     return(this);
 }
Beispiel #35
0
        /// <summary>
        /// Gets list of workspaces for a given server and user</summary>
        /// <param name="serverAddress">Server address</param>
        /// <param name="userId">User ID</param>
        /// <returns>List of workspaces</returns>
        public IEnumerable<string> GetWorkspaces(string serverAddress, string userId)
        {
            var result = new List<string>();
            try
            {
                var server = new Server(new ServerAddress(serverAddress));
                var repository = new Repository(server);
                
                // This call ensures internal P4Server is set for repository.Connection,
                //  otherwise GetUsers() call will fail.
                repository.Connection.Connect(ConnectionOptions);

                if (CheckLogin(repository.Connection))
                {
                    var opts = new Options();
                    opts.Add("-u", userId); //The -u user flag lists client workspaces that are owned by the  specified user. 

                    foreach (var client in repository.GetClients(opts))
                        result.Add(client.Name);
                }

            }
            catch (P4Exception ex)
            {
                switch (ex.ErrorLevel)
                {
                    case ErrorSeverity.E_WARN:
                        Outputs.WriteLine(OutputMessageType.Warning, ex.Message);
                        break;
                    case ErrorSeverity.E_FAILED:
                        Outputs.WriteLine(OutputMessageType.Error, ex.Message);
                        break;
                    case ErrorSeverity.E_INFO:
                        Outputs.WriteLine(OutputMessageType.Info, ex.Message);
                        break;
                }
                if (ThrowExceptions)
                    throw;
            }
          
            return result;
        }
 public void AddOption(String pOption)
 {
     Options.Add(new PollOption(pOption.ToLower()));
 }
        public override IEnumerable<string> SelectFeatures(Prediction prediction)
        {
            _libLinear.LoadClassificationModelFiles();

            string logPath = Path.Combine(Model.ModelDirectory, "feature_selection_log.txt");
            System.IO.File.Delete(logPath);

            int nullClass = -1;
            foreach (string unmappedLabel in _libLinear.Labels)
                if (unmappedLabel == PointPrediction.NullLabel)
                    if (nullClass == -1)
                        nullClass = int.Parse(_libLinear.GetMappedLabel(unmappedLabel));
                    else
                        throw new Exception("Multiple null classes in label map");

            if (nullClass == -1)
                throw new Exception("Failed to find null class");

            string featureSelectionTrainingPath = Path.GetTempFileName();

            using (FileStream compressedTrainingInstancesFile = new FileStream(CompressedTrainingInstancesPath, FileMode.Open, FileAccess.Read))
            using (GZipStream compressedTrainingInstancesGzip = new GZipStream(compressedTrainingInstancesFile, CompressionMode.Decompress))
            using (StreamReader trainingInstancesFile = new StreamReader(compressedTrainingInstancesGzip))
            using (FileStream compressedTrainingInstanceLocationsFile = new FileStream(CompressedTrainingInstanceLocationsPath, FileMode.Open, FileAccess.Read))
            using (GZipStream compressedTrainingInstanceLocationsGzip = new GZipStream(compressedTrainingInstanceLocationsFile, CompressionMode.Decompress))
            using (StreamReader trainingInstanceLocationsFile = new StreamReader(compressedTrainingInstanceLocationsGzip))
            using (StreamWriter featureSelectionTrainingFile = new StreamWriter(featureSelectionTrainingPath))
            {
                try
                {
                    string instance;
                    while ((instance = trainingInstancesFile.ReadLine()) != null)
                    {
                        string location = trainingInstanceLocationsFile.ReadLine();
                        if (location == null)
                            throw new Exception("Missing location for training instance");

                        featureSelectionTrainingFile.WriteLine(instance + " # " + location);
                    }

                    if ((instance = trainingInstanceLocationsFile.ReadToEnd()) != null && (instance = instance.Trim()) != "")
                        throw new Exception("Extra training instance locations:  " + instance);

                    trainingInstancesFile.Close();
                    trainingInstanceLocationsFile.Close();
                    featureSelectionTrainingFile.Close();
                }
                catch (Exception ex)
                {
                    throw new Exception("Failed to read training instances:  " + ex.Message);
                }
            }

            string groupNamePath = Path.GetTempFileName();
            Dictionary<string, string> groupNameFeatureId = new Dictionary<string, string>();
            using (StreamWriter groupNameFile = new StreamWriter(groupNamePath))
            {
                foreach (PTL.ATT.Models.Feature feature in Model.Features)
                {
                    int featureNumber;
                    if (_libLinear.TryGetFeatureNumber(feature.Id, out featureNumber))
                    {
                        string groupName = feature.ToString().ReplacePunctuation(" ").RemoveRepeatedWhitespace().Replace(' ', '_').Trim('_');
                        groupNameFile.WriteLine(featureNumber + " " + groupName);
                        groupNameFeatureId.Add(groupName, feature.Id);
                    }
                }
                groupNameFile.Close();
            }

            Options featureSelectionOptions = new Options();
            featureSelectionOptions.Add(FeatureSelector.Option.ExitOnErrorAction, FeatureSelector.ExitOnErrorAction.ThrowException.ToString());
            featureSelectionOptions.Add(FeatureSelector.Option.FeatureFilters, typeof(ZeroVectorFeatureFilter).FullName + "," + typeof(CosineSimilarityFeatureFilter).FullName);
            featureSelectionOptions.Add(FeatureSelector.Option.FloatingSelection, false.ToString());
            featureSelectionOptions.Add(FeatureSelector.Option.GroupNamePath, groupNamePath);
            featureSelectionOptions.Add(FeatureSelector.Option.LogPath, logPath);
            featureSelectionOptions.Add(FeatureSelector.Option.MaxThreads, Configuration.ProcessorCount.ToString());
            featureSelectionOptions.Add(FeatureSelector.Option.PerformanceIncreaseRequirement, float.Epsilon.ToString());
            featureSelectionOptions.Add(FeatureSelector.Option.Scorer, typeof(SurveillancePlotScorer).FullName);
            featureSelectionOptions.Add(FeatureSelector.Option.TrainingInstancesInMemory, true.ToString());
            featureSelectionOptions.Add(FeatureSelector.Option.TrainingInstancesPath, featureSelectionTrainingPath);
            featureSelectionOptions.Add(FeatureSelector.Option.Verbosity, FeatureSelector.Verbosity.Debug.ToString());
            featureSelectionOptions.Add(SurveillancePlotScorer.Option.IgnoredSurveillanceClasses, nullClass.ToString());
            featureSelectionOptions.Add(CommonWrapper.Option.ClassifyExePath, Configuration.ClassifierTypeOptions[GetType()]["predict"]);
            featureSelectionOptions.Add(CommonWrapper.Option.TrainExePath, Configuration.ClassifierTypeOptions[GetType()]["train"]);
            featureSelectionOptions.Add(LibLinearWrapper.Option.IgnoredProbabilisticClasses, nullClass.ToString());
            featureSelectionOptions.Add(LibLinearWrapper.Option.SumInstanceProbabilities, true.ToString());
            featureSelectionOptions.Add(CrossFoldValidator.Option.RandomizeInstanceBlocks, true.ToString());
            featureSelectionOptions.Add(CrossFoldValidator.Option.InstanceBlockRandomizationSeed, (498734983).ToString());
            featureSelectionOptions.Add(CrossFoldValidator.Option.NumFolds, (2).ToString());
            featureSelectionOptions.Add(CosineSimilarityFeatureFilter.Option.Threshold, (0.98).ToString());

            if (_positiveClassWeighting == PositiveClassWeighting.NegativePositiveRatio)
            {
                using (FileStream compressedTrainingInstancesFile = new FileStream(CompressedTrainingInstancesPath, FileMode.Open, FileAccess.Read))
                using (GZipStream compressedTrainingInstancesGzip = new GZipStream(compressedTrainingInstancesFile, CompressionMode.Decompress))
                using (StreamReader compressedTrainingInstancesReader = new StreamReader(compressedTrainingInstancesGzip))
                {
                    Dictionary<int, float> classWeight = GetPerClassWeights(compressedTrainingInstancesReader);
                    foreach (int classNum in classWeight.Keys)
                        featureSelectionOptions.Add((LibLinearWrapper.Option)Enum.Parse(typeof(LibLinearWrapper.Option), "W" + classNum), classWeight[classNum].ToString());
                }
            }
            else if (_positiveClassWeighting != PositiveClassWeighting.None)
                throw new Exception("Unrecognized positive class weighting scheme:  " + _positiveClassWeighting);

            FeatureSelector.Run(_libLinear, featureSelectionOptions);

            float score;
            Dictionary<string, Tuple<int, float>> featureRankContribution;
            FeatureSelector.GetResults(logPath, out score, out featureRankContribution);

            System.IO.File.Delete(featureSelectionTrainingPath);
            System.IO.File.Delete(groupNamePath);

            return featureRankContribution.Keys.Select(groupName => groupNameFeatureId[groupName]);
        }
		/// <summary>
		/// Query the server for a single changelist specified by the query parameter
		/// </summary>
        /// <param name="ChangelistNumber">The changelist number to query for</param>
		/// <returns>P4Changelist object representing the queried changelist, if it exists; otherwise, P4Changelist.InvalidChangelist</returns>
        public Changelist QueryChangelist(int ChangelistNumber)
		{
            Changelist ChangelistRecordSet = null;

			// Can only query if currently connected to the server!
			if (ConnectionStatus == EP4ConnectionStatus.P4CS_Connected)
			{
				try
				{
                    //do not include file diffs in this operation.
                    Options options = new Options();
                    options.Add("-s","");

					// Attempt to run a describe query on the changelist specified by the InQuery
                    ChangelistRecordSet = mP4Repository.GetChangelist(ChangelistNumber, options);
    			}
                catch (P4Exception E)
				{
					Console.WriteLine("Error running Perforce command!\n{0}", E.Message);
				}
			}

			return ChangelistRecordSet;
		}
 public void Add(HexViewGroupOption option) => Options.Add(option);
Beispiel #40
0
        public CommandLineParser(params string[] args)
        {
            var queue = new Queue<string>(args);

            var assemblyPaths = new List<string>();
            var optionList = new Options();
            var errors = new List<string>();

            while (queue.Any())
            {
                var item = queue.Dequeue();

                if (IsKey(item))
                {
                    var key = KeyName(item);

                    key = CorrectlyCasedKey(key);

                    if (key == null)
                    {
                        errors.Add(string.Format("Option {0} is not recognized.", item));
                        break;
                    }

                    if (!queue.Any() || IsKey(queue.Peek()))
                    {
                        errors.Add(string.Format("Option {0} is missing its required value.", item));
                        break;
                    }

                    var value = queue.Dequeue();

                    if (key == CommandLineOption.Parameter)
                    {
                        if (value.Contains("="))
                        {
                            var equalSignIndex = value.IndexOf('=');

                            if (equalSignIndex == 0)
                            {
                                errors.Add(string.Format("Custom parameter {0} is missing its required key.", value));
                                break;
                            }

                            key = value.Substring(0, equalSignIndex);
                            value = value.Substring(equalSignIndex + 1);
                        }
                        else
                        {
                            key = value;
                            value = "on";
                        }
                    }

                    optionList.Add(key, value);
                }
                else
                {
                    assemblyPaths.Add(item);
                }
            }

            if (!errors.Any() && !assemblyPaths.Any())
                errors.Add("Missing required test assembly path(s).");

            AssemblyPaths = assemblyPaths.ToArray();
            Options = optionList;
            Errors = errors.ToArray();
        }
        public void analyzeCommands()
        {
            string currentFlag     = "";
            bool   processingFiles = false;

            foreach (string word in words)
            {
                if (word.StartsWith("/") || word.StartsWith("-"))
                {
                    if (word.Contains(flag_dll) || word.Contains(flag_dll.ToUpper()))
                    {
                        isDll = true;
                    }
                    else if (word.Contains(flag_exe) || word.Contains(flag_exe.ToUpper()))
                    {
                        isExe = true;
                    }
                    else if (word.Contains(flag_out) || word.Contains(flag_out.ToUpper()))
                    {
                        Output = word.Substring(flag_out.Length + 1);
                        Options.Add(new KeyValuePair <string, string>(flag_out, Output));
                        currentFlag = flag_out;
                    }
                    else if (word.Contains(flag_def) || word.Contains(flag_def.ToUpper()))
                    {
                        Def = word.Substring(flag_def.Length + 1);
                        Options.Add(new KeyValuePair <string, string>(flag_def, Def));
                        currentFlag = flag_def;
                    }
                    else if (word.Contains(flag_entry) || word.Contains(flag_entry.ToUpper()))
                    {
                        Entry = word.Substring(flag_entry.Length + 1);
                        Options.Add(new KeyValuePair <string, string>(flag_entry, Entry));
                        currentFlag = flag_entry;
                    }
                    else
                    {
                        Options.Add(new KeyValuePair <string, string>(word, Entry));
                    }
                }
                else if (word.Contains(".obj"))
                {
                    Objs.Add(word);
                    processingFiles = true;
                }
                else if (word.Contains(".lib"))
                {
                    Libs.Add(word);
                    processingFiles = true;
                }
                else if (word.Contains(".res"))
                {
                }
                else if (currentFlag != "")
                {
                }
                else
                {
                    //Unrecognized command
                }

                if (word.ToLower().Equals("link") || word.ToLower().Equals("link.exe"))
                {
                }
                else if (!processingFiles)
                {
                    if (!word.Equals(""))
                    {
                        LinkOptionsLiteral += word + " ";
                        LinkOptionsLiteral_Words.Add(word);
                    }
                }
            }
            LinkOptionsLiteral = LinkOptionsLiteral.Trim();
        }
Beispiel #42
0
        static int Main(string[] args)
        {
            try
            {
                var directories = new List<string>();
                var files = new List<string>();

                var programCommand = Command.None;
                Func<CompositionContractInfo, bool> contractPredicate = c => false;
                Func<CompositionInfo, PartDefinitionInfo, bool> partPredicate = (ci, p) => false;
                var verbose = false;
                var whitelist = new RejectionWhitelist();

                var opts = new Options();
                
                opts.Add<string>("dir", @"C:\MyApp\Parts", "Specify directories to search for parts.",
                    d => directories.Add(d));
                opts.Add<string>("file", "MyParts.dll", "Specify assemblies to search for parts.",
                    f => files.Add(f));
                opts.AddSwitch("verbose", "Print verbose information on each part.",
                    () => verbose = true);

                var programCommandGroup = new ExclusiveGroup();

                opts.Add<string>("type", "MyNamespace.MyType", "Print details of the given part type.", t => {
                        programCommand = Command.PrintParts;
                        partPredicate = AddToPredicate(partPredicate, (ci, p) => p == ci.GetPartDefinitionInfo(t));
                    },
                    programCommandGroup);

                opts.Add<string>("importers", "MyContract", "List importers of the given contract.", i => {
                        programCommand = Command.PrintParts;
                        partPredicate = AddToPredicate(partPredicate, (ci, p) => p.ImportsContract(i));
                    },
                    programCommandGroup);

                opts.Add<string>("exporters", "MyContract", "List exporters of the given contract.", e => {
                        programCommand = Command.PrintParts;
                        partPredicate = AddToPredicate(partPredicate, (ci, p) => p.ExportsContract(e));
                    },
                    programCommandGroup);

                opts.AddSwitch("rejected", "List all rejected parts.", () => {
                        programCommand = Command.PrintParts;
                        partPredicate = AddToPredicate(partPredicate, (ci, p) => p.IsRejected);
                    },
                    programCommandGroup);

                opts.AddSwitch("causes", "List root causes - parts with errors not related to the rejection of other parts.", () => {
                        programCommand = Command.PrintParts;
                        partPredicate = AddToPredicate(partPredicate, (ci, p) => p.IsPrimaryRejection);
                    },
                    programCommandGroup);

                opts.Add<string>("whitelist", "RejectionWhitelist.txt", "Specify parts that may be validly rejected; requres the /rejected or /causes commands.",
                    w => whitelist = new RejectionWhitelist(w));

                opts.AddSwitch("parts", "List all parts found in the source assemblies.", () => {
                        programCommand = Command.PrintParts;
                        partPredicate = AddToPredicate(partPredicate, (ci, p) => true);
                    },
                    programCommandGroup);

                opts.AddSwitch("?", "Print usage.",
                    () => programCommand = Command.PrintUsage, programCommandGroup);

                var contractsSubgroup = new InclusiveSubroup(programCommandGroup);
                opts.AddSwitch("imports", "Find imported contracts.", () => {
                        programCommand = Command.PrintContracts;
                        contractPredicate = AddToPredicate(contractPredicate, c => c.Importers.Any());
                    },
                    contractsSubgroup);

                opts.AddSwitch("exports", "Find exported contracts.", () => {
                        programCommand = Command.PrintContracts;
                        contractPredicate = AddToPredicate(contractPredicate, c => c.Exporters.Any());
                    },
                    contractsSubgroup);

                opts.Parse(args);

                return Run(directories, files, programCommand, contractPredicate, partPredicate, verbose, whitelist, opts);
            }
            catch (Exception ex)
            {
                Console.Write("Error: ");
                Console.WriteLine(ex.Message);
                return 1;
            }
        }
Beispiel #43
0
        public NoteResult(Note note) : base(note.Content)
        {
            Subtitle = $"Created at {note.CreatedAt.ToShortDateString()}";

            Options.Add(new DeleteNoteOptionResult(note));
        }
        /// <summary>
        /// Perform actions which can be automated, such as moving and deleting files.
        /// </summary>
        private void PerformDefaultActions()
        {
            if (CheckConnect())
            {
                using (Connection P4Connection = P4Repository.Connection)
                {
                    AddDeleteFilesToDefaultChangeList(P4Connection);
                    AddMoveFilesToDefaultChangeList(P4Connection);

                    //if there are files to move or delete submit them otherwise delete the changelist
                    try
                    {
                        Options SubmitOptions = new Options();

                        //Add a description
                        SubmitOptions.Add("-d", String.Format(Settings.Default.MoveDeleteChangelistDescription, _connectionDetails.UserSavedStatePreferredLanguage));

                        SubmitResults DeleteMoveSubmitResults = P4Connection.Client.SubmitFiles(SubmitOptions, null);

                        log.Info(String.Format("Delete and move files submitted in CL# {0}, Files affected:", DeleteMoveSubmitResults.ChangeIdAfterSubmit));
                        foreach (var SubmittedFile in DeleteMoveSubmitResults.Files)
                        {
                            log.Info(String.Format("\t{0}:\t{1}({2})", SubmittedFile.Action, SubmittedFile.File.DepotPath, SubmittedFile.File.Version));
                        }
                    }
                    catch (P4Exception ex)
                    {
                        //Swallow No files to submit error
                        if (ex.ErrorCode != 806427698)
                        {
                            log.Error("Error in submitting move delete changelist:");
                            log.Error(ex.Message);
                        }
                    }
                }
            }
        }
Beispiel #45
0
 public void AddMenuItem(MenuItem menuItem)
 {
     Options.Add(menuItem);
 }
        private void BuildChangeListsDescriptionMapping()
        {
            //Build filespec list of all files to get changelists for
            List<FileSpec> ListOfFiles = new List<FileSpec>();

            foreach (var LangFile in LangFileToCreateProcessingList)
            {
                ListOfFiles.Add(new FileSpec(new DepotPath(LangFile.DepotFile), null, null, VersionSpec.Head));
            }
            foreach (var LangFile in LangFileToUpdateProcessingList)
            {
                ListOfFiles.Add(new FileSpec(new DepotPath(LangFile.DepotFile), null, null, VersionSpec.Head));
            }
            foreach (var LangFile in LangFileTranslatedProcessingList)
            {
                ListOfFiles.Add(new FileSpec(new DepotPath(LangFile.DepotFile), null, null, VersionSpec.Head));
            }

            if (CheckConnect())
            {
                Options options = new Options();

                //Extended descriptions
                options.Add("-l", null);

                IList<Changelist> Changelists = P4Repository.GetChangelists(options, ListOfFiles.ToArray());

                foreach (Changelist ChangelistDetails in Changelists)
                {
                    if (!ChangelistIdDescriptionMapping.ContainsKey(ChangelistDetails.Id))
                    {
                        ChangelistIdDescriptionMapping.Add(ChangelistDetails.Id, new ChangelistDescription(ChangelistDetails.Description));
                    }
                }
            }
        }
Beispiel #47
0
 public void AddMenuItem(Func <Menu> func)
 {
     Refresher = func;
     Options.Add(func());
 }