Exemplo n.º 1
0
        private static IEventWriter LoadDatastoreEventWriter()
        {
            IEventWriter provider = null;

            List <string> list = new List <string>()
            {
                AppDomain.CurrentDomain.BaseDirectory,
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"),
            };

            if (Directory.Exists(eXtensibleConfig.ConfigurationProviderPlugins))
            {
                list.Add(eXtensibleConfig.ConfigurationProviderPlugins);
            }
            try
            {
                EventWriterModule module = null;
                ModuleLoader <EventWriterModule> loader = new ModuleLoader <EventWriterModule>()
                {
                    Folderpaths = list
                };
                if (loader.Load(out module) && module.Providers != null && module.Providers.Count > 0)
                {
                    provider = module.Providers.Find(x => !x.GetType().Equals(typeof(DatastoreEventWriter)));
                }
            }
            catch (Exception ex)
            {
                string       message = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                IEventWriter writer  = new EventLogWriter();
                writer.WriteError(message, SeverityType.Critical, "EventWriterModule");
            }

            if (provider == null)
            {
                provider = new DatastoreEventWriter();
            }

            return(provider);
        }
Exemplo n.º 2
0
        private void DiscoverTypes()
        {
            if (eXtensibleConfig.Inform)
            {
                EventWriter.Inform(String.Format("{0}|{1}|Typecache is discovering pluggable types...", System.AppDomain.CurrentDomain.FriendlyName, "type-cache"));
            }
            TypeMapContainer container             = null;
            ModuleLoader <TypeMapContainer> loader = new ModuleLoader <TypeMapContainer>();

            if (folderpaths != null && folderpaths.Count > 0)
            {
                loader.Folderpaths = folderpaths;
            }
            _TypeCache = new Dictionary <string, List <Type> >();
            if (loader.Load(out container))
            {
                foreach (var item in container.TypeMaps)
                {
                    string key = String.IsNullOrWhiteSpace(item.Domain) ? item.KeyType.FullName : item.Domain;

                    if (!_TypeCache.ContainsKey(key))
                    {
                        _TypeCache.Add(key, new List <Type>());
                    }

                    _TypeCache[key].Add(item.TypeResolution);

                    if (eXtensibleConfig.Inform && !item.TypeResolution.ToString().Contains("XF."))
                    {
                        string name    = System.AppDomain.CurrentDomain.FriendlyName;
                        string message = String.Format("{0}|{1}|Typecache associated {2} with {3}", name, "type-cache", key, item.TypeResolution);
                        EventWriter.Inform(message);
                    }
                }
            }
        }