void AddFeatureBlock(XmlDocument doc, FeatureBlock block, FeatureTarget target, IDefaultContainer[] defaults,
                             IConfigBlockContainer[] configBlocks)
        {
            if (target != FeatureTarget.Any && block.Target != target)
            {
                return;
            }

            ConfigBlockBlock configBlock = Helpers.FindConfigBlock(configBlocks, block.Name);

            if (configBlock == null)
            {
                throw new ApplicationException(String.Format("Config block '{0}' cannot be found", block.Name));
            }

            XmlNode attachPoint = null;

            ProcessSections(doc, doc, "/", configBlock.Requires, defaults, configBlock.Name, ref attachPoint);
            if (attachPoint == null)
            {
                attachPoint = FindDefaultAttachPoint(doc, configBlock.Requires);
            }
            if (attachPoint == null)
            {
                throw new ApplicationException(
                          String.Format("Missing attachment point for block '{0}'", configBlock.Name));
            }

            XmlDocument contents = new XmlDocument();

            contents.LoadXml(String.Format("<{0}>{1}</{0}>", Helpers.FakeRootName, configBlock.Contents));
            AddFeatureRecursively(doc, attachPoint, contents.DocumentElement);
        }
Esempio n. 2
0
		public void StoreConfiguration ()
		{
			AssertStorage ();
			
			ConfigBlockBlock block = new ConfigBlockBlock (name, requirements, contents);
			if (storage.ContainsKey (name))
				storage [name] = block; // allow for silent override
			else
				storage.Add (name, block);

			// Prepare to handle more sections
			requirements = new Section ();
			contents = null;
		}
        public void StoreConfiguration()
        {
            AssertStorage();

            ConfigBlockBlock block = new ConfigBlockBlock(name, requirements, contents);

            if (storage.ContainsKey(name))
            {
                storage [name] = block; // allow for silent override
            }
            else
            {
                storage.Add(name, block);
            }

            // Prepare to handle more sections
            requirements = new Section();
            contents     = null;
        }
Esempio n. 4
0
        public static ConfigBlockBlock FindConfigBlock(IConfigBlockContainer[] configBlocks, string name)
        {
            int len;

            if (configBlocks == null || (len = configBlocks.Length) == 0)
            {
                return(null);
            }

            IConfigBlockContainer cur;
            ConfigBlockBlock      ret = null;

            for (int i = 0; i < len; i++)
            {
                cur = configBlocks [i];
                ret = cur.FindConfigBlock(name);
                if (ret != null)
                {
                    break;
                }
            }

            return(ret);
        }