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


C# Config.attr方法代码示例

本文整理汇总了C#中Config.attr方法的典型用法代码示例。如果您正苦于以下问题:C# Config.attr方法的具体用法?C# Config.attr怎么用?C# Config.attr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Config的用法示例。


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

示例1: Comments

        public void Comments()
        {
            Config config = new Config(files[1]);

            Assert.AreEqual<int>(1, config.attr<List<string>>("array").Count);
            Assert.AreEqual<int>(1, config.attr<string[]>("array").Length);

            Assert.AreEqual<int>(25, config.attr<int>("number"));

            Assert.AreEqual<string>(@"; comments can be any line starting with a # or semi-colon
            also any line that does not have an equal sign are considered a comment.", config.comment("number"));

            Assert.AreEqual<string>("# comments shoudl be rewritten in the correct spot every time..", config.comment("array"));
        }
开发者ID:kodybrown,项目名称:cheats,代码行数:14,代码来源:ConfigTests.cs

示例2: Main

        static int Main( string[] args )
        {
            Config config = new Config();
            string site = "",
                password = "",
                username = "",
                cachefile = "";
            //bool allowalpha = true,
            //	allowdigits = true,
            //	allowsymbols = true;
            bool addsymbols = true;
            bool setclip = true;
            bool fl_config = false;
            int passlen = 26;

            config.read(true);
            if (config.contains("cachefile")) {
                cachefile = config.attr<string>("cachefile");
            } else {
                cachefile = "createpw.enc";
            }

            for (int i = 0; i < args.Length; i++) {
                string a = args[i];

                if (a.Length == 0) {
                    continue;
                }

                if (a.StartsWith("/") || a.StartsWith("-") || a.StartsWith("!")) {
                    while (a.StartsWith("/") || a.StartsWith("-")) {
                        a = a.Substring(1);
                    }

                    string al = a.ToLowerInvariant();

                    if (al == "?" || al.StartsWith("h")) {
                        usage();
                        return 0;

                    } else if (al.Equals("pause") || al.Equals("!pause") || al.Equals("nopause") || al.Equals("no-pause")) {
                        pause = al.Equals("pause");
                    } else if (al.StartsWith("q") || al.StartsWith("!q") || al.StartsWith("noq") || al.StartsWith("no-q")) {
                        quiet = al.StartsWith("q");
                    } else if (al.StartsWith("v") || al.StartsWith("!v") || al.StartsWith("nov") || al.StartsWith("no-v")) {
                        verbose = al.StartsWith("v");

                    } else if (al.Equals("config")) {
                        fl_config = true;

                    } else if (al.StartsWith("cache") || al.StartsWith("!cache") || al.Equals("nocache") || al.Equals("no-cache")) {
                        useCache = al.StartsWith("cache");

                    } else if (al.StartsWith("p")) {
                        int j = al.IndexOfAny(new char[] { ':', '=' });
                        if (j > -1) {
                            password = a.Substring(j + 1).Trim();
                        } else {
                            if (args.Length > i) {
                                password = args[i + 1];
                            } else {
                                Console.WriteLine("Missing master password argument.");
                            }
                        }

                    } else if (al.StartsWith("len") || al.StartsWith("passlen") || al.StartsWith("pass-len")) {
                        int j = al.IndexOfAny(new char[] { ':', '=' });
                        if (j > -1) {
                            if (!int.TryParse(al.Substring(j + 1).Trim(), out passlen)) {
                                Console.WriteLine("Could not parse the password length: " + args[i + 1]);
                            }
                        } else {
                            if (args.Length > i) {
                                if (!int.TryParse(args[i + 1], out passlen)) {
                                    Console.WriteLine("Could not parse the password length: " + args[i + 1]);
                                }
                            } else {
                                Console.WriteLine("Missing new password length argument.");
                            }
                        }

                    } else if (al == "clip" || al == "noclip" || al == "no-clip") {
                        setclip = (al == "clip");

                        //} else if (al.StartsWith("a") || al.StartsWith("!a") || al.StartsWith("noa") || al.StartsWith("no-a")) {
                        //	allowalpha = al.StartsWith("a");
                        //} else if (al.StartsWith("d") || al.StartsWith("!d") || al.StartsWith("nod") || al.StartsWith("no-d")) {
                        //	allowdigits = al.StartsWith("d");
                    } else if (al.StartsWith("s") || al.StartsWith("adds") || al.StartsWith("add-s")
                            || al.StartsWith("!s") || al.StartsWith("nos") || al.StartsWith("no-s")) {
                        addsymbols = al.StartsWith("s") || al.StartsWith("adds") || al.StartsWith("add-s");

                    } else if (al.StartsWith("l")) {
                        //int pos;
                        //if ((pos = a.IndexOf(":")) > -1 || (pos = a.IndexOf("=")) > -1) {
                        //	if (!int.TryParse(a.Substring(pos), out passlen)) {
                        //		Console.WriteLine("Error in length argument: " + a);
                        //		return 2;
                        //	}
                        //} else {
//.........这里部分代码省略.........
开发者ID:kodybrown,项目名称:createpw,代码行数:101,代码来源:Program.cs

示例3: ConstructorVsRead

        public void ConstructorVsRead()
        {
            Config config = new Config(files[1]);

            Assert.AreEqual<int>(1, config.attr<List<string>>("array").Count);
            Assert.AreEqual<int>(1, config.attr<string[]>("array").Length);

            Assert.AreEqual<int>(25, config.attr<int>("number"));

            config = new Config();
            config.read(files[1]);

            Assert.AreEqual<int>(1, config.attr<List<string>>("array").Count);
            Assert.AreEqual<int>(1, config.attr<string[]>("array").Length);

            Assert.AreEqual<short>(25, config.attr<short>("number"));
            Assert.AreEqual<int>(25, config.attr<int>("number"));
            Assert.AreEqual<long>(25, config.attr<long>("number"));
            Assert.AreEqual<ulong>(25, config.attr<ulong>("number"));
        }
开发者ID:kodybrown,项目名称:cheats,代码行数:20,代码来源:ConfigTests.cs

示例4: TheBasics

        public void TheBasics()
        {
            Config config = new Config();

            config.read(files[0]);

            Assert.AreEqual<int>(1, config.attr<List<string>>("array").Count);
            Assert.AreEqual<int>(1, config.attr<string[]>("array").Length);

            Assert.AreEqual<int>(25, config.attr<int>("number"));
        }
开发者ID:kodybrown,项目名称:cheats,代码行数:11,代码来源:ConfigTests.cs


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