Example #1
0
        public ConfigElement Import(IConfigNavigationSourceAdapter <string, ConfigElement> source, string key)
        {
            //Add as an element as long as it doesnt already exist. If it exists, just return existing element.
            if (ConfigSource.Elements(key).Count() > 0)
            {
                if (cachedElements.ContainsKey(key))
                {
                    return(cachedElements[key]);
                }
                var exitingElement = new ConfigElement(new XMLPropertyConfigSource(ConfigSource.Elements(key).First()), new XMLElementConfigSource(ConfigSource.Elements(key).First()));
                cachedElements.Add(key, exitingElement);
                return(exitingElement);
            }


            ConfigSource.Add(((XMLElementConfigSource)source).ConfigSource);

            var newElement = ConfigSource.Elements(key).First();

            if (newElement.Attribute("ID") == null)
            {
                newElement.Add(new XAttribute("ID", key));
            }
            else
            {
                newElement.Attribute("ID").SetValue(key);
            }

            var configElement = new ConfigElement(new XMLPropertyConfigSource(newElement), new XMLElementConfigSource(newElement));

            cachedElements.Add(key, configElement);
            return(configElement);
        }
Example #2
0
        public bool Load(string uri)
        {
            cachedElements = new Dictionary <string, ConfigElement>();
            IConfigPropertySourceAdapter <string, string>          propertySourceAdapter = null;
            IConfigNavigationSourceAdapter <string, ConfigElement> elementSourceAdapter  = null;

            ConfigSourceFactory.Load(uri, out propertySourceAdapter, out elementSourceAdapter);

            this.propertiesSource = propertySourceAdapter;
            Elements = new ConfigElements(elementSourceAdapter);

            //Walk structure and build cache



            return(false);
        }
Example #3
0
        public ConfigElement Append(string Id, IConfigNavigationSourceAdapter <string, ConfigElement> element)
        {
            var newConfigSource = ((XMLElementConfigSource)element).ConfigSource;

            //Append to the collection...make sure the ConfigSource is a collection of the thing we are trying to add
            if (ConfigSource.Attributes("CollectionOf").Count() > 0 &&
                ConfigSource.Attributes("CollectionOf").First().Value == newConfigSource.Name.ToString())
            {
                ConfigSource.Add(((XMLElementConfigSource)element).ConfigSource);
                if (newConfigSource.Attribute("ID") == null)
                {
                    newConfigSource.Add(new XAttribute("ID", Id));
                }
                else
                {
                    newConfigSource.Attribute("ID").SetValue(Id);
                }
                var configElement = new ConfigElement(new XMLPropertyConfigSource(newConfigSource), new XMLElementConfigSource(newConfigSource));
                cachedElements.Add(Id, configElement);
                return(configElement);
            }
            return(null);
        }
Example #4
0
 public ConfigElement(IConfigPropertySourceAdapter <string, string> propertySourceAdapter, IConfigNavigationSourceAdapter <string, ConfigElement> elementSourceAdapter)
 {
     this.propertiesSource = propertySourceAdapter;
     Elements = new ConfigElements(elementSourceAdapter);
 }
Example #5
0
 public ConfigElements(IConfigNavigationSourceAdapter <string, ConfigElement> elementSourceAdapter)
 {
     this.elementSource = elementSourceAdapter;
 }
Example #6
0
        public bool Load(string uri, out IConfigPropertySourceAdapter <string, string> configPropertySourceAdapter, out IConfigNavigationSourceAdapter <string, ConfigElement> configNavigationSourceAdapter)
        {
            XElement element = XElement.Load(uri);

            configPropertySourceAdapter   = new XMLPropertyConfigSource(element);
            configNavigationSourceAdapter = new XMLElementConfigSource(element);

            foreach (var coll in element.Elements().Where(e => e.Attributes().Any(a => a.Name == "CollectionOf")))
            {
                var e = configNavigationSourceAdapter.Get(coll.Name.ToString());
                BuildCache(e);
            }
            return(false);
        }
Example #7
0
 public ConfigElement Append(string key, IConfigNavigationSourceAdapter <string, ConfigElement> element)
 {
     throw new NotImplementedException();
 }
Example #8
0
 ConfigElement IConfigNavigationSourceAdapter <string, ConfigElement> .Import(IConfigNavigationSourceAdapter <string, ConfigElement> source, string key)
 {
     throw new NotImplementedException();
 }