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


C# Config.Clone方法代码示例

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


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

示例1: TestClone

        public void TestClone()
        {
            var c = new Config();

            var backoffStrategy = new FullJitterStrategy();
            var tlsConfig = new TlsConfig();
            c.Set("dial_timeout", "50ms");
            c.Set("read_timeout", "5m");
            c.Set("heartbeat_interval", "2s");
            c.Set("rdy_redistribute_interval", "3s");
            c.Set("backoff_strategy", backoffStrategy);
            c.Set("rdy_redistribute_on_idle", true);
            c.Set("tls_config", tlsConfig);
            c.Validate();

            var c2 = c.Clone();

            Assert.AreEqual(TimeSpan.FromMilliseconds(50), c2.DialTimeout, "dial_timeout");
            Assert.AreEqual(TimeSpan.FromMinutes(5), c2.ReadTimeout, "read_timeout");
            Assert.AreEqual(TimeSpan.FromSeconds(10), c2.WriteTimeout, "write_timeout");
            Assert.AreEqual(TimeSpan.FromSeconds(60), c2.LookupdPollInterval, "lookupd_poll_interval");
            Assert.AreEqual(0.3, c2.LookupdPollJitter, "lookupd_poll_jitter");
            Assert.AreEqual(TimeSpan.FromMinutes(15), c2.MaxRequeueDelay, "max_requeue_delay");
            Assert.AreEqual(TimeSpan.FromSeconds(90), c2.DefaultRequeueDelay, "default_requeue_delay");
            Assert.AreEqual(backoffStrategy, c2.BackoffStrategy, "backoff_strategy");
            Assert.AreEqual(TimeSpan.FromMinutes(2), c2.MaxBackoffDuration, "max_backoff_duration");
            Assert.AreEqual(TimeSpan.FromSeconds(1), c2.BackoffMultiplier, "backoff_multiplier");
            Assert.AreEqual(5, c2.MaxAttempts, "max_attempts");
            Assert.AreEqual(TimeSpan.FromSeconds(10), c2.LowRdyIdleTimeout, "low_rdy_idle_timeout");
            Assert.AreEqual(TimeSpan.FromSeconds(3), c2.RDYRedistributeInterval, "rdy_redistribute_interval");
            Assert.AreEqual(true, c2.RDYRedistributeOnIdle, "rdy_redistribute_on_idle");
            Assert.AreEqual(OS.Hostname().Split('.')[0], c2.ClientID, "client_id");
            Assert.AreEqual(OS.Hostname(), c2.Hostname, "hostname");
            Assert.AreEqual(string.Format("{0}/{1}", ClientInfo.ClientName, ClientInfo.Version), c2.UserAgent, "user_agent");
            Assert.AreEqual(TimeSpan.FromSeconds(2), c2.HeartbeatInterval, "heartbeat_interval");
            Assert.AreEqual(0, c2.SampleRate, "sample_rate");
            Assert.AreEqual(tlsConfig, c2.TlsConfig, "tls_config");
            //Assert.AreEqual(false, c2.Deflate, "deflate"); // TODO: Deflate
            //Assert.AreEqual(6, c2.DeflateLevel, "deflate_level"); // TODO: Deflate
            //Assert.AreEqual(false, c2.Snappy, "snappy"); // TODO: Snappy
            Assert.AreEqual(16384, c2.OutputBufferSize, "output_buffer_size");
            Assert.AreEqual(TimeSpan.FromMilliseconds(250), c2.OutputBufferTimeout, "output_buffer_timeout");
            Assert.AreEqual(1, c2.MaxInFlight, "max_in_flight");
            Assert.AreEqual(TimeSpan.Zero, c2.MessageTimeout, "msg_timeout");
            Assert.IsNull(c2.AuthSecret, "auth_secret");
        }
开发者ID:crazybert,项目名称:NsqSharp,代码行数:46,代码来源:ConfigTest.cs

示例2: FrmDBExportConfig_Load

        private void FrmDBExportConfig_Load(object sender, EventArgs e)
        {
            // локализация модуля
            string errMsg;
            if (!Localization.UseRussian)
            {
                if (Localization.LoadDictionaries(appDirs.LangDir, "ModDBExport", out errMsg))
                    Translator.TranslateForm(this, "Scada.Server.Modules.DBExport.FrmDBExportConfig");
                else
                    ScadaUiUtils.ShowError(errMsg);
            }

            // настройка элементов управления
            lblInstruction.Top = treeView.Top;

            // загрузка конфигурации
            config = new Config(appDirs.ConfigDir);
            if (File.Exists(config.FileName) && !config.Load(out errMsg))
                ScadaUiUtils.ShowError(errMsg);

            // создание копии конфигурации
            configCopy = config.Clone();

            // отображение конфигурации
            ConfigToControls();

            // снятие признака изменения конфигурации
            Modified = false;
        }
开发者ID:LoganDing,项目名称:scada,代码行数:29,代码来源:FrmDBExportConfig.cs

示例3: btnCancel_Click

 private void btnCancel_Click(object sender, EventArgs e)
 {
     // отмена изменений конфигурации
     config = configCopy;
     configCopy = config.Clone();
     ConfigToControls();
     Modified = false;
 }
开发者ID:LoganDing,项目名称:scada,代码行数:8,代码来源:FrmDBExportConfig.cs

示例4: Conn

        /// <summary>
        /// Initializes a new instance of the <see cref="Conn"/> class.
        /// </summary>
        public Conn(string addr, Config config, IConnDelegate connDelegate)
        {
            if (string.IsNullOrEmpty(addr))
                throw new ArgumentNullException("addr");
            if (config == null)
                throw new ArgumentNullException("config");
            if (connDelegate == null)
                throw new ArgumentNullException("connDelegate");

            _addr = addr;

            _config = config.Clone();
            _delegate = connDelegate;

            _maxRdyCount = 2500;
            _lastMsgTimestamp = DateTime.Now.UnixNano();

            _cmdChan = new Chan<Command>();
            _msgResponseChan = new Chan<msgResponse>();
            _exitChan = new Chan<int>();
            _drainReady = new Chan<int>();
        }
开发者ID:yonglehou,项目名称:NsqSharp,代码行数:25,代码来源:Conn.cs


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