当前位置: 首页>>代码示例>>C#>>正文


C# Args类代码示例

本文整理汇总了C#中Args的典型用法代码示例。如果您正苦于以下问题:C# Args类的具体用法?C# Args怎么用?C# Args使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Args类属于命名空间,在下文中一共展示了Args类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestLiveNamespace1

        public void TestLiveNamespace1()
        {
            Service service = Connect();

            String username = "sdk-user";
            String password = "changeme";
            String savedSearch = "sdk-test1";
            String searchString = "search index=main * | 10";

            // Setup a namespace
            Args splunkNameSpace = new Args();
            splunkNameSpace.Add("owner", username);
            splunkNameSpace.Add("app", "search");

            // Get all users, scrub and make our test user
            UserCollection users = service.GetUsers();
            if (users.ContainsKey(username))
            {
                users.Remove(username);
            }

            Assert.IsFalse(users.ContainsKey(username), "Expected users to not contain: " + username);
            users.Create(username, password, "user");
            Assert.IsTrue(users.ContainsKey(username), "Expected users to contain: " + username);

            // Get saved searches for our new namespace, scrub and make our test saved searches
            SavedSearchCollection savedSearches = service.GetSavedSearches(splunkNameSpace);
            if (savedSearches.ContainsKey(savedSearch))
            {
                savedSearches.Remove(savedSearch);
            }

            Assert.IsFalse(savedSearches.ContainsKey(savedSearch), "Expected the saved search to not contain " + savedSearch);

        }
开发者ID:yonglehou,项目名称:splunk-sdk-csharp,代码行数:35,代码来源:UnitTest1.cs

示例2: ParseCmdType

 private static bool ParseCmdType(string[] strArgs, Args args)
 {
     switch (strArgs[0])
     {
         case "list":
             args.CmdType = CommandType.ListPasses;
             break;
         case "update":
             args.CmdType = CommandType.Update;
             break;
         case "add":
             args.CmdType = CommandType.AddPass;
             args.PassItem = ParsePassItem(strArgs);
             break;
         case "del":
             args.CmdType = CommandType.RemovePass;
             args.FindPassById = ParseId(strArgs);
             break;
         case "edit":
             args.CmdType = CommandType.EditPass;
             args.FindPassById = ParseId(strArgs);//to be sure that i have id
             args.PassItem = ParsePassItem(strArgs);
             break;
         case "info":
             args.CmdType = CommandType.ShowPassInfo;
             args.FindPassById = ParseId(strArgs);
             break;
         case "reset":
             args.CmdType = CommandType.ResetPsd;
             break;
         default:
             return false;
     }
     return true;
 }
开发者ID:pasichnichenko,项目名称:PSD,代码行数:35,代码来源:CmdArgsParser.cs

示例3: Execute

        protected override void Execute(Args args)
        {
            var entries = ScriptLogEntry.Load(Database);
            var version = VersionNumber.Parse(args.GetValue("version"));

            if (entries.Any(x => x.Version == version.ToString() && !x.ScriptNumber.HasValue))
            {
                switch (args.GetValueOrDefault("conflict", ConflictStrategy.Fail))
                {
                    case ConflictStrategy.Fail:
                        throw new ApplicationException("Version already exists.");
                    case ConflictStrategy.Notify:
                        using (TemporaryConsoleColorWarning())
                            Console.WriteLine("Version already exists.");
                        return;
                    case ConflictStrategy.Ignore:
                        return;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }

            const string sql = "insert [dbo].[ScriptLog] ([Version], [User], [Date]) values (@version, @user, @date)";
            var entry = new
                                {
                                    Date = DateTimeOffset.UtcNow,
                                    User = Environment.UserName,
                                    Version = version.ToString()
                                };
            Database.Execute(sql, entry);
        }
开发者ID:CAB-Group,项目名称:DbMigrator,代码行数:31,代码来源:InsertCommand.cs

示例4: Resource

        /// <summary>
        /// Initializes a new instance of the <see cref="Resource"/> class, 
        /// adding optional arguments for namespace and other endpoint 
        /// arguments.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="path">The path of this resource.</param>
        /// <param name="args">The variable arguments.</param>
        public Resource(Service service, string path, Args args)
        {
            this.Service = service;
            /* Pull out namespace items (app, owner, sharing) from the args, and
             * then use to create the full path.
             */
            Args clonedArgs = new Args(args);
            Args splunkNamespace = new Args();
            if (args.ContainsKey("app"))
            {
                splunkNamespace.Set("app", args["app"].ToString());
                clonedArgs.Remove("app");
            }
            if (args.ContainsKey("owner"))
            {
                splunkNamespace.Set("owner", args["owner"].ToString());
                clonedArgs.Remove("owner");
            }
            if (args.ContainsKey("sharing"))
            {
                splunkNamespace.Set(
                    "sharing", args["sharing"].ToString());
                clonedArgs.Remove("sharing");
            }
            if (!clonedArgs.ContainsKey("count"))
            {
                clonedArgs.Set("count", "-1");
            }

            this.RefreshArgs = clonedArgs;
            this.Path = service.Fullpath(
                path, splunkNamespace.Count == 0 ? null : splunkNamespace);
            this.MaybeValid = false;
        }
开发者ID:ravibeta,项目名称:csharpexamples,代码行数:42,代码来源:Resource.cs

示例5: FillUserPassword

 private static void FillUserPassword(Args args)
 {
     if (args.UserPassword != null)
         return;
     Console.WriteLine("Enter user password:");
     args.UserPassword = Console.ReadLine();
 }
开发者ID:pasichnichenko,项目名称:PSD,代码行数:7,代码来源:ConsoleArgsParser.cs

示例6: ParseArgs

 private static Args ParseArgs(string[] argArray)
 {
     var args = new Args{Repeat = 1};
     Action<string> nextArg = null;
     foreach (var a in argArray)
     {
         if (nextArg != null)
         {
             nextArg(a);
             nextArg = null;
             continue;
         }
         if (a.StartsWith("-") || a.StartsWith("/"))
         {
             switch (a.Substring(1))
             {
                 case "r":
                     nextArg = s => args.Repeat = int.Parse(s);
                     break;
                 default:
                     throw new ArgumentOutOfRangeException("unknown arg: " + a);
             }
         }
     }
     return args;
 }
开发者ID:adamhathcock,项目名称:log4net-loggly,代码行数:26,代码来源:Program.cs

示例7: Test_Creating

 public void Test_Creating()
 {
     var args = new Args("path", "mask", ProgramAction.FileRename);
     Assert.AreEqual(args.Path, "path");
     Assert.AreEqual(args.Mask, "mask");
     Assert.AreEqual(args.Action, ProgramAction.FileRename);
 }
开发者ID:Confirmit,项目名称:Students,代码行数:7,代码来源:ArgsClassTests.cs

示例8: SimpleIntPresent

 public void SimpleIntPresent()
 {
     var args = new Args("x#", "-x", "42");
     args.Has('x').ShouldBeTrue();
     args.Get<int>('x').ShouldBe(42);
     args.NextArgument().ShouldBe(2);
 }
开发者ID:mmozuras,项目名称:NArgs,代码行数:7,代码来源:ArgsTests.cs

示例9: GetActionKey

        public static NamedAction GetActionKey(Args arguments, NamedAction defaultAction)
        {
            NamedAction actionKey = arguments.IsDefault ?
                                                            defaultAction : arguments.GetActionKey();

            return actionKey;
        }
开发者ID:agglerithm,项目名称:EDIDocsProcessing,代码行数:7,代码来源:Parser.cs

示例10: TestUsge

 public void TestUsge()
 {
     var args = new Args(1, "abc", new DateTime(2013, 10, 15), this);
       Assert.That(args.Get<int>(0), Is.EqualTo(1));
       Assert.That(args.Get<string>(1), Is.EqualTo("abc"));
       Assert.That(args.Get<DateTime>(2), Is.EqualTo(new DateTime(2013, 10, 15)));
       Assert.That(args.Get<ArgsTest>(3), Is.SameAs(this));
 }
开发者ID:asipe,项目名称:SupaCharge,代码行数:8,代码来源:ArgsTest.cs

示例11: FillPcPath

        private static void FillPcPath(Args args)
        {
            if (args.PcPath != null)
                return;

            Console.WriteLine("Enter path to PC base:");
            args.PcPath = Console.ReadLine();
        }
开发者ID:pasichnichenko,项目名称:PSD,代码行数:8,代码来源:ConsoleArgsParser.cs

示例12: BotChatConnection_ChatMessageReceived

 private static void BotChatConnection_ChatMessageReceived(object o, Args.ChatMessageReceivedEventArgs e)
 {
     if(e.Message.Message == Command)
     {
         StartRaidGame();
         enteredViewers.Add(new Viewer(e.Message.Author));
     }
 }
开发者ID:ocgineer,项目名称:OakBot,代码行数:8,代码来源:GroupMinigame.cs

示例13: ExtraArguments

 public void ExtraArguments()
 {
     var args = new Args("x,y*", "-x", "-y", "alpha", "beta");
     args.Has('x').ShouldBeTrue();
     args.Has('y').ShouldBeTrue();
     args.Get<bool>('x').ShouldBeTrue();
     args.Get<string>('y').ShouldBe("alpha");
     args.NextArgument().ShouldBe(3);
 }
开发者ID:mmozuras,项目名称:NArgs,代码行数:9,代码来源:ArgsTests.cs

示例14: CreateNamespace

        /// <summary>
        /// Establishes and returns a namespace.
        /// </summary>
        public Args CreateNamespace(String username, String appname)
        {
            Args splunkNamespace = new Args();

            splunkNamespace.Add("owner", username);
            splunkNamespace.Add("app", appname);

            return splunkNamespace;
        }
开发者ID:yonglehou,项目名称:splunk-sdk-csharp,代码行数:12,代码来源:NameSpaceTest.cs

示例15: Execute

        protected override void Execute(Args args)
        {
            var count = int.Parse(args.GetValueOrDefault("count", "10"));
            var entries = ScriptLogEntry.Load(Database, count).ToList();

            Console.WriteLine();
            Console.WriteLine(ScriptLogEntry.Format(entries));
            Console.WriteLine();
        }
开发者ID:CAB-Group,项目名称:DbMigrator,代码行数:9,代码来源:HistoryCommand.cs


注:本文中的Args类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。