Ejemplo n.º 1
0
        public override bool Setup(IRootConfig rootConfig, IServerConfig config, ISocketServerFactory socketServerFactory, SocketBase.Protocol.ICustomProtocol <SocketBase.Command.StringCommandInfo> protocol)
        {
            if (!base.Setup(rootConfig, config, socketServerFactory, protocol))
            {
                return(false);
            }

            var childrenConfig = config.GetChildConfig <ChildConfigCollection>("children");

            ChildConfigGlobalValue = childrenConfig.GlobalValue;

            var sum = 0;
            var pro = 1;

            foreach (var c in childrenConfig.OfType <ChildConfig>())
            {
                sum += c.Value;
                pro *= c.Value;
            }

            ChildConfigValueSum             = sum;
            ChildConfigValueMultiplyProduct = pro;

            var childConfig = config.GetChildConfig <ChildConfig>("child");

            ChildConfigValue = childConfig.Value;

            return(true);
        }
        /// <summary>
        /// Setups the specified root config.
        /// </summary>
        /// <param name="rootConfig">The root config.</param>
        /// <param name="config">The config.</param>
        /// <returns></returns>
        protected override bool Setup(IRootConfig rootConfig, IServerConfig config)
        {
            if (!base.Setup(rootConfig, config))
            {
                return(false);
            }

            var users = config.GetChildConfig <UserConfigCollection>("users");

            if (users == null || users.Count <= 0)
            {
                Logger.Error("No user defined");
                return(false);
            }

            m_UsersDict = new Dictionary <string, UserConfig>(StringComparer.OrdinalIgnoreCase);

            foreach (var u in users)
            {
                m_UsersDict.Add(u.Name, u);
            }

            m_ExcludedServers = config.Options
                                .GetValue("excludedServers", string.Empty)
                                .Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
                                .ToList().Union(new string[] { this.Name }).Distinct().ToArray();

            return(true);
        }
        protected override bool Setup(IRootConfig rootConfig, IServerConfig config)
        {
            var childConfig = config.GetChildConfig <ChildConfig>("child");

            ChildConfigValue = childConfig.Value;
            return(true);
        }
        protected override bool Setup(IRootConfig rootConfig, IServerConfig config)
        {
            var childrenConfig = config.GetChildConfig <ChildConfigCollection>("children");

            ChildConfigGlobalValue = childrenConfig.GlobalValue;

            var sum = 0;
            var pro = 1;

            foreach (var c in childrenConfig.OfType <ChildConfig>())
            {
                sum += c.Value;
                pro *= c.Value;
            }

            ChildConfigValueSum             = sum;
            ChildConfigValueMultiplyProduct = pro;

            return(true);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Setups with the specified parameters.
        /// </summary>
        /// <param name="rootConfig">The root config.</param>
        /// <param name="config">The config.</param>
        /// <param name="socketServerFactory">The socket server factory.</param>
        /// <param name="protocol">The protocol.</param>
        /// <returns></returns>
        protected override bool Setup(IRootConfig rootConfig, IServerConfig config, ISocketServerFactory socketServerFactory, IRequestFilterFactory <IWebSocketFragment> protocol)
        {
            if (!base.Setup(rootConfig, config, socketServerFactory, protocol))
            {
                return(false);
            }

            var users = config.GetChildConfig <UserConfigCollection>("users");

            if (users == null || users.Count <= 0)
            {
                Logger.Error("No user defined");
                return(false);
            }

            m_UsersDict = new Dictionary <string, UserConfig>(StringComparer.OrdinalIgnoreCase);

            foreach (var u in users)
            {
                m_UsersDict.Add(u.Name, u);
            }

            return(true);
        }