Пример #1
0
        private static StorageContext GetStorageContext(string alias, string name, string assemblyName)
        {
            Mapping mapping = GetMapping(name);

            if (mapping == null)
            {
                AssemblyConfig assemblyConfig = GetAssemblyConfig(assemblyName);
                if (assemblyConfig == null)
                {
                    return(StorageService.DefaultStorageContext);
                }

                return(StorageService.GetStorageContext(assemblyConfig.DefaultStorageContext));
            }

            string context = mapping.GetStorageContext(alias);

            if (string.IsNullOrEmpty(context))
            {
                context = mapping.DefaultStorageContext;

                if (string.IsNullOrEmpty(context))
                {
                    context = mapping.Assembly.DefaultStorageContext;
                }
            }

            return(StorageService.GetStorageContext(context));
        }
Пример #2
0
        private static AssemblyConfig AssemblyConfigBuilder(XElement el)
        {
            AssemblyConfig assembly = new AssemblyConfig(el.Attribute("name").Value);

            assembly.DefaultStorageContext = el.Attribute("default") == null ? null : el.Attribute("default").Value;
            return(assembly);
        }
Пример #3
0
        public AssemblyConfig Clone()
        {
            AssemblyConfig ac = new AssemblyConfig(this.Name);

            ac.DefaultStorageContext = this.DefaultStorageContext;

            return(ac);
        }
Пример #4
0
        private static Mapping MappingBuilder(XElement el, AssemblyConfig assembly)
        {
            Mapping mapping = new Mapping(el.Attribute("name").Value, assembly);

            mapping.DefaultStorageContext = el.Attribute("default") == null ? null : el.Attribute("default").Value;

            IEnumerable <XElement>      storageContextList = el.Elements("StorageContext");
            Dictionary <string, string> storageContexts    = LoadStorageContexts(storageContextList);

            mapping.StorageContexts = storageContexts;

            return(mapping);
        }
Пример #5
0
        private static void LoadMappings(IEnumerable <XElement> mappings, AssemblyConfig assembly)
        {
            Mapping mapping;

            foreach (XElement el in mappings)
            {
                try
                {
                    mapping = MappingBuilder(el, assembly);
                    if (string.IsNullOrEmpty(mapping.Name))
                    {
                        LogProxy.Warn(MAPPINGSNAMEISNULL);
                        continue;
                    }

                    Mappings[mapping.Name] = mapping;
                }
                catch (Exception ex)
                {
                    LogProxy.Error(ex, false);
                }
            }
        }
Пример #6
0
 internal Mapping(string name, AssemblyConfig assembly)
 {
     this.Name         = name;
     this.Assembly     = assembly;
     this.AssemblyName = assembly.Name;
 }