Пример #1
0
        public static IProvider GetProvider(string providerName)
        {
            if (!ProviderCache.ContainsKey(providerName))
            {
                throw new Exception("Unknown Provider. (See Provider Configuration)");
            }

            ProviderSetting setting = ProviderCache[providerName];

            if (setting.ProviderType == null)
            {
                Type type = Type.GetType(setting.ProviderTypeName);
                if (type == null)
                {
                    throw new Exception(string.Format("Unknown Type {0}", setting.ProviderTypeName));
                }
                setting.ProviderType = type;
            }
            IProvider provider = CreateIProviderInstance(setting.ProviderType);

            string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings[setting.ConnectionString].ConnectionString;

            if (!string.IsNullOrEmpty(connectionString))
            {
                provider.ConnectionString = connectionString;
            }

            if (typeof(ProviderBase).IsAssignableFrom(provider.GetType()))
            {
                (provider as ProviderBase).SetProviderName(providerName);
            }

            return(provider);
        }
Пример #2
0
        private static void InitConfiguration()
        {
            var section = System.Configuration.ConfigurationManager.GetSection("AnitoProviderConfiguration");

            if (section == null)
            {
                throw new Exception("Default Anito Provider Configuration Section doesn't exist (AnitoProviderConfiguration)");
            }
            m_configuration = section as ProviderConfiguration;

            foreach (ProviderConfigurationElement element in m_configuration.Providers)
            {
                ProviderSetting setting = new ProviderSetting();
                setting.Name             = element.Name;
                setting.ConnectionString = element.ConnectionString;
                setting.ProviderTypeName = element.Type;

                ProviderCache.Add(element.Name, setting);

                TypeSchemaSource source = new TypeSchemaSource();
                foreach (SchemaSourceElement schemaElement in element.SchemaSourceCollection)
                {
                    XmlReader reader = new XmlTextReader(schemaElement.SourceFile);
                    (source as IXmlSerializable).ReadXml(reader);
                    reader.Close();
                }
                CacheManager.SchemaCache.Add(element.Name, source);
            }
        }
 public void Config(ProviderSetting setting)
 {
     _logger = new LoggerConfiguration()
               .MinimumLevel.Debug()
               .WriteTo.RollingFile(new FastJsonTextFormatter(), string.Concat(setting.FilePath, setting.FileName))
               .CreateLogger();
 }
 public void Config(ProviderSetting setting)
 {
     _logger = new LoggerConfiguration()
               .MinimumLevel.Debug()
               .WriteTo.RollingFile(new FastJsonTextFormatter(),
                                    string.Concat(setting.FilePath, setting.FileName),
                                    restrictedToMinimumLevel: LogEventLevel.Information,
                                    fileSizeLimitBytes: 8589934592)
               .CreateLogger();
 }
Пример #5
0
        public static Configuration UseSerilog(this Configuration configuration)
        {
            ObjectContainer.Register <ILoggerProvider, SerilogLoggerProvider>(LifeScope.Transient);
            ObjectContainer.Register <ILoggerFactory, SerilogLoggerFactory>();

            var providerSetting = new ProviderSetting()
            {
                FileName = $"normal-{ProviderSetting.FileNameDateSymbol}.log",
                FilePath = "logs/"
            };

            ProviderSetting.SetDefault(providerSetting);

            return(configuration);
        }
Пример #6
0
        private static void InitConfiguration()
        {
            var section = System.Configuration.ConfigurationManager.GetSection("AnitoProviderConfiguration");
            if (section == null)
                throw new Exception("Default Anito Provider Configuration Section doesn't exist (AnitoProviderConfiguration)");
            m_configuration = section as ProviderConfiguration;

            foreach (ProviderConfigurationElement element in m_configuration.Providers)
            {
                ProviderSetting setting = new ProviderSetting();
                setting.Name = element.Name;
                setting.ConnectionString = element.ConnectionString;
                setting.ProviderTypeName = element.Type;

                ProviderCache.Add(element.Name, setting);

                TypeSchemaSource source = new TypeSchemaSource();
                foreach (SchemaSourceElement schemaElement in element.SchemaSourceCollection)
                {
                    XmlReader reader = new XmlTextReader(schemaElement.SourceFile);
                    (source as IXmlSerializable).ReadXml(reader);
                    reader.Close();
                }
                CacheManager.SchemaCache.Add(element.Name, source);
            }
        }
Пример #7
0
        private static void InitConfiguration()
        {
            var section = System.Configuration.ConfigurationManager.GetSection("AnitoProviderConfiguration");
            if (section == null)
                throw new Exception("Default Anito Provider Configuration Section doesn't exist (AnitoProviderConfiguration)");
            s_configuration = section as ProviderConfiguration;

            if(Equals(s_configuration, null))
                throw new NullReferenceException("s_configuration");

            foreach (ProviderConfigurationElement element in s_configuration.Providers)
            {
                var setting = new ProviderSetting{
                    Name = element.Name
                    , ConnectionString = element.ConnectionString
                    , ProviderTypeName = element.Type};

                ProviderCache.Add(element.Name, setting);

                var source = new TypeSchemaSource();
                foreach (SchemaSourceElement schemaElement in element.SchemaSourceCollection)
                {
                    if(!File.Exists(schemaElement.SourceFile))
                        throw new FileNotFoundException(schemaElement.SourceFile);
                    XmlReader reader = new XmlTextReader(schemaElement.SourceFile);
                    (source as IXmlSerializable).ReadXml(reader);
                    reader.Close();
                }
                CacheManager.SchemaCache.Add(element.Name, source);
            }    
        }
Пример #8
0
 public Provider(ProviderSettingFactory factory)
 {
     providerSetting = factory("someClientId", "someAppKey");
 }