Beispiel #1
0
        /// <summary>Clones (makes a copy) of this instance.</summary>
        /// <returns>A copy of this object.</returns>
        public NsqConfig Clone()
        {
            var newConfig = new NsqConfig();

            newConfig.BackoffStrategy = BackoffStrategy;

            var typ = GetType();

            foreach (var field in typ.GetProperties())
            {
                var opt = field.Get <OptAttribute>();
                if (opt != null)
                {
                    newConfig.Set(opt.Name, field.GetValue(this, index: null));
                }
            }

            return(newConfig);
        }
Beispiel #2
0
            public void SetDefaults(NsqConfig c)
            {
                Type typ = c.GetType();

                foreach (var field in typ.GetProperties())
                {
                    var opt          = field.Get <OptAttribute>();
                    var defaultValue = field.Get <DefaultAttribute>();
                    if (opt == null || defaultValue == null)
                    {
                        continue;
                    }

                    c.Set(opt.Name, defaultValue.Value);
                }

                string hostname = OS.Hostname();

                c.ClientID  = hostname.Split(new[] { '.' })[0];
                c.Hostname  = hostname;
                c.UserAgent = string.Format("{0}/{1}", ClientInfo.ClientName, ClientInfo.Version);
            }