Esempio n. 1
0
        public void ReadConfiguration(XPathNavigator nav)
        {
            name     = Helpers.GetRequiredNonEmptyAttribute(nav, "name");
            target   = Helpers.ConvertEnum <FeatureTarget> (Helpers.GetRequiredNonEmptyAttribute(nav, "target"), "target");
            fileName = Helpers.GetOptionalAttribute(nav, "fileName");

            if (String.IsNullOrEmpty(fileName))
            {
                fileName = name;
            }

            sections = new Section();
            Helpers.BuildSectionTree(nav.Select("./section[string-length (@name) > 0]"), sections);
        }
        public void ReadConfiguration(XPathNavigator nav)
        {
            name   = Helpers.GetRequiredNonEmptyAttribute(nav, "name");
            target = Helpers.ConvertEnum <FeatureTarget> (Helpers.GetRequiredNonEmptyAttribute(nav, "target"), "target");

            XPathNodeIterator iter = nav.Select("blocks/block[string-length (@name) > 0]");

            while (iter.MoveNext())
            {
                blocks.Add(new FeatureBlock(iter.Current, target));
            }

            iter = nav.Select("description/text()");
            string val;

            while (iter.MoveNext())
            {
                val = iter.Current.Value;
                if (String.IsNullOrEmpty(val))
                {
                    continue;
                }
                description.Append(val);
            }

            FeatureAction action;

            iter = nav.Select("actions/action[string-length (@type) > 0 and string-length (@when) > 0]");
            while (iter.MoveNext())
            {
                action = new FeatureAction(iter.Current);
                switch (action.When)
                {
                case ActionWhen.Before:
                    actionsBefore.Add(action);
                    break;

                case ActionWhen.After:
                    actionsAfter.Add(action);
                    break;

                default:
                    throw new ApplicationException(
                              String.Format("Unknown 'when' attribute: {0}", action.When));
                }
            }
        }
Esempio n. 3
0
        public void ReadConfiguration(XPathNavigator nav)
        {
            section = Helpers.GetRequiredNonEmptyAttribute(nav, "section");
            target  = Helpers.ConvertEnum <FeatureTarget>  (Helpers.GetRequiredNonEmptyAttribute(nav, "target"), "target");

            XPathNodeIterator iter = nav.Select("./text()");
            StringBuilder     sb   = new StringBuilder();

            while (iter.MoveNext())
            {
                sb.Append(iter.Current.Value);
            }
            if (sb.Length > 0)
            {
                contents = sb.ToString();
            }
        }
Esempio n. 4
0
        public Section(XPathNavigator nav)
        {
            if (nav != null)
            {
                name = Helpers.GetRequiredNonEmptyAttribute(nav, "name");

                string val = Helpers.GetOptionalAttribute(nav, "attachPoint");
                if (!String.IsNullOrEmpty(val))
                {
                    attachPoint = true;
                }

                val = Helpers.GetOptionalAttribute(nav, "defaultBlockName");
                if (!String.IsNullOrEmpty(val))
                {
                    defaultBlockName = val;
                }
            }
        }
        public void ReadConfiguration(XPathNavigator nav)
        {
            name = Helpers.GetRequiredNonEmptyAttribute(nav, "name");

            requirements = new Section();
            Helpers.BuildSectionTree(nav.Select("requires/section[string-length(@name) > 0]"), requirements);

            XPathNodeIterator iter = nav.Select("contents/text()");
            StringBuilder     sb   = new StringBuilder();

            while (iter.MoveNext())
            {
                sb.Append(iter.Current.Value);
            }
            if (sb.Length > 0)
            {
                contents = sb.ToString();
            }
        }
Esempio n. 6
0
        void AddSectionHandler(XPathNavigator nav, List <HandlerDescription> handlers)
        {
            string             section = Helpers.GetRequiredNonEmptyAttribute(nav, "section");
            HandlerDescription hd      = new HandlerDescription(Helpers.GetRequiredNonEmptyAttribute(nav, "type"),
                                                                Helpers.GetRequiredNonEmptyAttribute(nav, "storageType"),
                                                                section);

            if (section_handlers.ContainsKey(section))
            {
                HandlerDescription old = section_handlers [section];
                section_handlers [section] = hd;

                handlers.Remove(old);
                handlers.Add(hd);
            }
            else
            {
                section_handlers.Add(section, hd);
                handlers.Add(hd);
            }
        }
        public FeatureAction(XPathNavigator nav)
        {
            string val = Helpers.GetRequiredNonEmptyAttribute(nav, "type");

            type = Helpers.ConvertEnum <ActionType> (val, "type");

            val  = Helpers.GetRequiredNonEmptyAttribute(nav, "when");
            when = Helpers.ConvertEnum <ActionWhen> (val, "when");

            XPathNodeIterator iter;
            StringBuilder     sb = new StringBuilder();

            switch (type)
            {
            case ActionType.Message:
            case ActionType.ShellScript:
                iter = nav.Select("./text()");
                while (iter.MoveNext())
                {
                    sb.Append(iter.Current.Value);
                }
                if (type == ActionType.Message)
                {
                    message = sb.ToString();
                }
                else
                {
                    script = sb.ToString();
                }
                break;

            case ActionType.Exec:
                command          = Helpers.GetRequiredNonEmptyAttribute(nav, "command");
                commandArguments = Helpers.GetOptionalAttribute(nav, "commndArguments");
                break;
            }
        }
 public FeatureBlock (XPathNavigator node, FeatureTarget target)
 {
     this.name = Helpers.GetRequiredNonEmptyAttribute (node, "name");
     this.target = target;
 }