Пример #1
0
        public bool EnsureDataStores()
        {
            if (!DataProviderPluginFacade.HasConfiguration())
            {
                Log.LogError(LogTitle, "Failed to load the configuration section '{0}' from the configuration", DataProviderSettings.SectionName);
                return(false);
            }

            var typeDescriptors = new List <DataTypeDescriptor>();

            foreach (Type type in _interfaceTypes)
            {
                try
                {
                    if (!DataProviderRegistry.AllKnownInterfaces.Contains(type))
                    {
                        var dataTypeDescriptor = DynamicTypeManager.BuildNewDataTypeDescriptor(type);

                        dataTypeDescriptor.Validate();

                        typeDescriptors.Add(dataTypeDescriptor);
                    }
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException(string.Format("Failed to validate type '{0}'", type), ex);
                }
            }

            if (typeDescriptors.Any())
            {
                DataProviderPluginFacade.CreateStores(DataProviderRegistry.DefaultDynamicTypeDataProviderName, typeDescriptors);

                string typeNames = string.Join(", ", typeDescriptors.Select(t => t.GetFullInterfaceName()));
                Log.LogVerbose(LogTitle, "Stores for the following data types were created: " + typeNames);
            }

            return(typeDescriptors.Count > 0);
        }
        public void InitializeDataTypes()
        {
            using (TimerProfilerFacade.CreateTimerProfiler())
            {
                _dataProviderNames = new List <string>();
                _interfaceTypeToReadableProviderNames     = new Dictionary <Type, List <string> >();
                _interfaceTypeToWriteableProviderNames    = new Dictionary <Type, List <string> >();
                _knownInterfaceTypeToDynamicProviderNames = new Dictionary <Type, List <string> >();
                _initializationErrors    = new Hashtable <Type, Exception>();
                _generatedInterfaceTypes = new List <Type>();

                if (DataProviderPluginFacade.HasConfiguration())
                {
                    BuildDataProviderNames();
                    BuildDictionaries();
                }
                else if (RuntimeInformation.IsDebugBuild)
                {
                    Log.LogError("DataProviderRegistry", string.Format("Failed to load the configuration section '{0}' from the configuration", DataProviderSettings.SectionName));
                }
            }
        }