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);
        }
Exemple #2
0
		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);
		}