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


C# Configuration.GetString方法代码示例

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


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

示例1: GetStringValueTest

        public void GetStringValueTest()
        {
            var config = new Configuration(_ => ConfigSource);
            config.Read("main");

            Assert.AreEqual("127.0.0.1", config.GetString("ssh_client.connection.host"));
            Assert.AreEqual("http://localhost", config.GetString("ssh_client.connection.url", "http://localhost"));
        }
开发者ID:mujing,项目名称:OGS.HOCON,代码行数:8,代码来源:ConfigurationTests.cs

示例2: Project

 public Project(string file)
 {
     ProjectFilename = file;
     string _ext = Path.GetExtension(ProjectFilename);
     if (_ext == ".lsproj")
     {
         _project = new Configuration(file, false);  // Подгружаем конфигурацию проекта
         ScriptName = _project.GetString("project.scriptname");
         ScriptFilename = _project.GetString("project.scriptfilename");
         ProjectRootFolder = _project.GetString("project.root");
     }
 }
开发者ID:craftersmine,项目名称:litescript,代码行数:12,代码来源:Project.cs

示例3: Load

        public static void Load(string[] args)
        {
            _conf = new Configuration();
            _conf.ReadFile("../../conf/msgr.conf");

            if (args != null)
                _conf.ReadArguments(args, "../../");

            MsgrConf.ConsoleFilter = (LogLevel)_conf.GetInt("msgr.consolefilter", 0);
            #if DEBUG
            // Enable debug regardless of configuration in debug builds.
            MsgrConf.ConsoleFilter &= ~LogLevel.Debug;
            #endif

            MsgrConf.DatabaseHost = _conf.GetString("database.host", "localhost");
            MsgrConf.DatabaseUser = _conf.GetString("database.user", "root");
            MsgrConf.DatabasePass = _conf.GetString("database.pass", "");
            MsgrConf.DatabaseDb = _conf.GetString("database.db", "aura");
        }
开发者ID:Fuhhue,项目名称:aura_legacy,代码行数:19,代码来源:MsgrConf.cs

示例4: Load

        public static void Load(string[] args)
        {
            _conf = new Configuration();
            _conf.ReadFile("../../conf/login.conf");

            if (args != null)
                _conf.ReadArguments(args, "../../");

            LoginConf.ConsoleFilter = (LogLevel)_conf.GetInt("login.consolefilter", 0);
            #if DEBUG
            // Enable debug regardless of configuration in debug builds.
            LoginConf.ConsoleFilter &= ~LogLevel.Debug;
            #endif

            LoginConf.Password = _conf.GetString("inter.password", "aura");

            LoginConf.DataPath = _conf.GetString("data.path", "../../data");
            LoginConf.Localization = _conf.GetString("data.localization", "us");

            LoginConf.DatabaseHost = _conf.GetString("database.host", "localhost");
            LoginConf.DatabaseUser = _conf.GetString("database.user", "root");
            LoginConf.DatabasePass = _conf.GetString("database.pass", "");
            LoginConf.DatabaseDb = _conf.GetString("database.db", "aura");

            LoginConf.Port = _conf.Get<ushort>("login.port", 11000);

            LoginConf.ConsumeCards = _conf.GetBool("login.consumecards", true);
            LoginConf.NewAccounts = _conf.GetBool("login.newaccounts", true);

            LoginConf.DeletionWait = _conf.Get<int>("login.deletewait", 107);
            if (LoginConf.DeletionWait < 0 || (LoginConf.DeletionWait > 23 && LoginConf.DeletionWait < 100) || LoginConf.DeletionWait > 123)
            {
                Logger.Warning("Invalid format for 'login.deletewait', setting to 0.");
                LoginConf.DeletionWait = 0;
            }

            LoginConf.EnableSecondaryPassword = _conf.GetBool("login.enable_sec", true);
        }
开发者ID:Fuhhue,项目名称:aura_legacy,代码行数:38,代码来源:LoginConf.cs

示例5: Load

        public static void Load()
        {
            const string serverSetup = "ServerSetup";
            const string loggingSetup = "LoggingSetup";
            const string folderSetup = "FolderSetup";
            const string generalSetup = "GeneralSetup";

            _config = new Configuration("Chraft.config");

            //ServerSetup
            Port = _config.GetInt(serverSetup, "Port", 25565);
            IPAddress = _config.GetString(serverSetup, "IPAddress", "0.0.0.0");
            MOTD = _config.GetString(serverSetup, "MOTD", "Welcome to c#raft");
            UseOfficalAuthentication = _config.GetBoolean(serverSetup, "UseOfficalAuthentication", true);
            EncryptionEnabled = _config.GetBoolean(serverSetup, "EncryptionEnabled", true);
            MaxPlayers = _config.GetInt(serverSetup, "MaxPlayers", 100);
            ServerName = _config.GetString(serverSetup, "ServerName", "C#raft");
            MaxSightRadius = _config.GetInt(serverSetup, "MaxSightRadius", 8);
            WorldSeed = _config.GetString(serverSetup, "WorldSeed", "1419875491758983");
            SpawnX = _config.GetInt(serverSetup, "SpawnX", 0);
            SpawnY = _config.GetInt(serverSetup, "SpawnY", 128);
            SpawnZ = _config.GetInt(serverSetup, "SpawnZ", 0);
            DefaultWorldName = _config.GetString(serverSetup, "DefaultWorldName", "Default");
            AnimalSpawnInterval = _config.GetInt(serverSetup, "AnimalSpawnInterval", 3000);
            LoadFromSave = _config.GetBoolean(serverSetup, "LoadFromSave", true);
            WeatherChangeFrequency = _config.GetInt(serverSetup, "WeatherChangeFrequency", 1);
            ServerTextureUrl = _config.GetString(serverSetup, "ServerTextureUrl", "");

            //logging setup
            LogFileFormat = _config.GetString(loggingSetup, "LogfileFormat", "{0:yyyy-MM-dd HH:mm:ss} [{1}] {2}");
            LogConsoleFormat = _config.GetString(loggingSetup, "LogConsoleFormat", "{0:HH:mm:ss} [{1}] {2}");
            LogFile = _config.GetString(loggingSetup, "LogFile", "server.log");
            LogFileLevel = _config.GetInt(loggingSetup, "LogFileLevel", -1);
            LogConsoleLevel = _config.GetInt(loggingSetup, "LogConsoleLevel", 3);

            //folder setup
            PluginFolder = _config.GetString(folderSetup, "PluginFolder", "Plugins");
            WorldsFolder = _config.GetString(folderSetup, "WorldsFolder", "Worlds");
            PlayersFolder = _config.GetString(folderSetup, "PlayersFolder", "Players");
            ContainersFolder = _config.GetString(folderSetup, "ContainersFolder", "Containers");

            //general setup
            AllowedChatChars = _config.GetString(generalSetup, "AllowedChatChars",
                                                 @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV_ [email protected]#$%^&amp;*()1234567890\[]{}|;':"",./&lt;&gt;?áéíóúäëïöüÁÉÍÓÚÄËÏÖÜÆæ");
            SmeltingRecipesFile = _config.GetString(generalSetup, "SmeltingRecipesFile", "Resources/Smelting.dat");
            ItemsFile = _config.GetString(generalSetup, "ItemsFile", "Resources/Items.csv");
            DefaultStackSize = (sbyte)_config.GetInt(generalSetup, "DefaultStackSize", 64);
            RecipesFile = _config.GetString(generalSetup, "RecipesFile", "Resources/Recipes.dat");
        }
开发者ID:Nirad,项目名称:c-raft,代码行数:49,代码来源:ChraftConfig.cs

示例6: Load

        public static void Load(string[] args)
        {
            _conf = new Configuration();
            _conf.ReadFile("../../conf/world.conf");

            if (args != null)
                _conf.ReadArguments(args, "../../");

            WorldConf.ConsoleFilter = (LogLevel)_conf.GetInt("world.consolefilter", 0);
            #if DEBUG
            // Enable debug regardless of configuration in debug builds.
            WorldConf.ConsoleFilter &= ~LogLevel.Debug;
            #endif

            WorldConf.Password = _conf.GetString("inter.password", "aura");

            WorldConf.DataPath = _conf.GetString("data.path", "../../data");
            WorldConf.Localization = _conf.GetString("data.localization", "us");

            WorldConf.DatabaseHost = _conf.GetString("database.host", "localhost");
            WorldConf.DatabaseUser = _conf.GetString("database.user", "root");
            WorldConf.DatabasePass = _conf.GetString("database.pass", "");
            WorldConf.DatabaseDb = _conf.GetString("database.db", "aura");

            WorldConf.ServerName = _conf.GetString("world.servername", "Dummy");
            WorldConf.ChannelName = _conf.GetString("world.channelname", "Ch1");
            WorldConf.ChannelHost = _conf.GetString("world.channelhost", "127.0.0.1");
            WorldConf.ChannelPort = (ushort)_conf.GetInt("world.channelport", 11020);
            WorldConf.CachePath = _conf.GetString("world.cache", "../../cache");

            WorldConf.LoginHost = _conf.GetString("world.loginhost", "127.0.0.1");
            WorldConf.LoginPort = (ushort)_conf.GetInt("world.loginport", 11000);

            WorldConf.CommandPrefix = _conf.GetString("commands.prefix", ">")[0];

            WorldConf.ScriptPath = _conf.GetString("script.path", "../../scripts");
            WorldConf.DisableScriptCaching = _conf.GetBool("script.disable_cache", false);
            WorldConf.ScriptStrictMode = _conf.GetBool("script.strict_mode", false);

            WorldConf.SightRange = _conf.Get<uint>("world.sightrange", 3000);

            WorldConf.AutoSendGMCP = _conf.GetBool("world.auto_gmcp", false);
            WorldConf.MinimumGMCP = _conf.Get<byte>("world.minimum_gmcp", 50);
            WorldConf.MinimumGMCPSummon = _conf.Get<byte>("world.minimum_gmcp_summon", 50);
            WorldConf.MinimumGMCPCharWarp = _conf.Get<byte>("world.minimum_gmcp_char_warp", 50);
            WorldConf.MinimumGMCPMove = _conf.Get<byte>("world.minimum_gmcp_move", 50);
            WorldConf.MinimumGMCPRevive = _conf.Get<byte>("world.minimum_gmcp_revive", 50);
            WorldConf.MinimumGMCPInvisible = _conf.Get<byte>("world.minimum_gmcp_invisible", 50);
            WorldConf.MinimumGMCPExpel = _conf.Get<byte>("world.minimum_gmcp_expel", 50);
            WorldConf.MinimumGMCPBan = _conf.Get<byte>("world.minimum_gmcp_ban", 50);

            WorldConf.ExpRate = _conf.Get<float>("world.exp_rate", 100f) / 100.0f;

            WorldConf.DropRate = _conf.Get<float>("world.drop_rate", 100f) / 100.0f;
            WorldConf.GoldDropRate = _conf.Get<float>("world.gold_drop_rate", 30f) / 100.0f;
            WorldConf.PropDropRate = _conf.Get<float>("world.prop_drop_rate", 30f) / 100.0f;

            WorldConf.EnableItemShop = _conf.GetBool("world.enable_itemshop", false);
            WorldConf.MailExpires = _conf.GetInt("world.mail_expires", 30);
            WorldConf.EnableVisual = _conf.GetBool("world.enable_visual", true);
            WorldConf.SafeDye = _conf.GetBool("world.safe_dye", false);

            WorldConf.BunshinSouls = _conf.GetBool("world.bunshinsouls", true);
            WorldConf.PerfectPlay = _conf.GetBool("world.perfectplay", false);
            WorldConf.DkSoundFix = _conf.GetBool("world.dk_sound_fix", true);

            WorldConf.ColorChange = _conf.GetBool("world.colorchange", true);

            WorldConf.DynamicCombat = _conf.GetBool("world.dynamic_combat", true);

            WorldConf.TimeBeforeAncient = _conf.GetInt("world.time_before_ancient", 300);
            WorldConf.AncientRate = _conf.Get<float>("world.ancient_rate", .33f);

            WorldConf.NpcIntroOnce = _conf.GetBool("world.npc_intro_once", true);

            try
            {
                WorldConf.Motd = File.ReadAllText("../../conf/motd.txt");
            }
            catch (FileNotFoundException)
            {
                Logger.Warning("'motd.txt' not found.");
                WorldConf.Motd = string.Empty;
            }
        }
开发者ID:pjm0616,项目名称:aura,代码行数:85,代码来源:WorldConf.cs

示例7: NegativeCase1Test

        public void NegativeCase1Test()
        {
            var config = new Configuration(_ => ConfigSource);
            config.Read("main");

            config.GetString("sources.o_array");
        }
开发者ID:mujing,项目名称:OGS.HOCON,代码行数:7,代码来源:ConfigurationTests.cs


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