/// <summary>
 /// Setups the specified root config.
 /// </summary>
 /// <param name="bootstrap">The bootstrap.</param>
 /// <param name="config">The socket server instance config.</param>
 /// <param name="factories">The factories.</param>
 /// <returns></returns>
 public bool Setup(IBootstrap bootstrap, IServerConfig config, ProviderFactoryInfo[] factories)
 {
     m_Bootstrap = bootstrap;
     m_ServerConfig = config;
     m_Factories = factories;
     return true;
 }
        public ProviderFactoryInfo GetBootstrapLogFactory()
        {
            if (m_DefaultLogFactory != null)
                return m_DefaultLogFactory;

            if (string.IsNullOrEmpty(m_Config.LogFactory))
            {
                m_DefaultLogFactory = new ProviderFactoryInfo(ProviderKey.LogFactory, string.Empty, typeof(Log4NetLogFactory));
                return m_DefaultLogFactory;
            }

            ProviderFactoryInfo factory = null;

            if (m_Config.LogFactories != null && m_Config.LogFactories.Count() > 0)
            {
                var logConfig = m_Config.LogFactories.FirstOrDefault(f =>
                    f.Name.Equals(m_Config.LogFactory, StringComparison.OrdinalIgnoreCase));

                if (logConfig != null)
                {
                    factory = new ProviderFactoryInfo(ProviderKey.LogFactory, m_Config.LogFactory, ValidateProviderType(logConfig.Type));
                }
            }

            if (factory == null)
                throw new Exception(string.Format("the specific log factory '{0}' cannot be found!", m_Config.LogFactory));

            m_DefaultLogFactory = factory;

            return factory;
        }
Example #3
0
        public bool Setup(string serverType, string bootstrapUri, string assemblyImportRoot, IServerConfig config, ProviderFactoryInfo[] factories)
        {
            m_AssemblyImporter = new AssemblyImport(assemblyImportRoot);

            var serviceType = Type.GetType(serverType);
            m_AppServer = (IWorkItem)Activator.CreateInstance(serviceType);

            var bootstrap = (IBootstrap)Activator.GetObject(typeof(IBootstrap), bootstrapUri);

            return m_AppServer.Setup(bootstrap, config, factories);
        }
Example #4
0
        public bool Setup(string serverType, string bootstrapUri, string assemblyImportRoot, IServerConfig config, ProviderFactoryInfo[] factories)
        {
            m_AssemblyImporter = new AssemblyImport(assemblyImportRoot);

            var serviceType = Type.GetType(serverType);
            m_AppServer = (IWorkItem)Activator.CreateInstance(serviceType);

            var bootstrap = (IBootstrap)Activator.GetObject(typeof(IBootstrap), bootstrapUri);

            var ret = m_AppServer.Setup(bootstrap, config, factories);

            if (ret)
            {
                m_Log = ((IAppServer)m_AppServer).Logger;
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            }

            return ret;
        }
Example #5
0
 /// <summary>
 /// Setups the specified root config.
 /// </summary>
 /// <param name="bootstrap">The bootstrap.</param>
 /// <param name="config">The socket server instance config.</param>
 /// <param name="factories">The providers.</param>
 /// <returns></returns>
 public bool Setup(IBootstrap bootstrap, IServerConfig config, ProviderFactoryInfo[] factories)
 {
     return m_AppServer.Setup(bootstrap, config, factories);
 }
 public WorkItemFactoryInfoLoader(IConfigurationSource config, ILogFactory passedInLogFactory)
     : this(config)
 {
     if (passedInLogFactory != null)
         m_DefaultLogFactory = new ProviderFactoryInfo(ProviderKey.LogFactory, string.Empty, passedInLogFactory);
 }
        private List<ProviderFactoryInfo> InitializeProviderFactories(ProviderKey key, IEnumerable<ITypeProvider> providerCollection, ProviderFactoryInfo loadedFactory)
        {
            var loadedFactoryPassedIn = false;

            if(loadedFactory != null && !string.IsNullOrEmpty(loadedFactory.Name))
                loadedFactoryPassedIn = true;

            var factories = new List<ProviderFactoryInfo>();

            if (providerCollection == null || !providerCollection.Any())
            {
                return factories;
            }

            foreach (var provider in providerCollection)
            {
                if (loadedFactoryPassedIn)
                {
                    if (loadedFactory.Name.Equals(provider.Name, StringComparison.OrdinalIgnoreCase))
                    {
                        factories.Add(loadedFactory);
                        continue;
                    }
                }

                factories.Add(new ProviderFactoryInfo(key, provider.Name, ValidateProviderType(provider.Type)));
            }

            return factories;
        }
Example #8
0
        public bool Setup(IBootstrap bootstrap, IServerConfig config, ProviderFactoryInfo[] factories)
        {
            State = ServerState.Initializing;

            Name = config.Name;

            m_Config = config;
            m_Factories = factories;

            State = ServerState.NotStarted;

            return true;
        }