Пример #1
0
        void LoadExtensionElement(TreeNode tnode, string addin, ExtensionNodeDescriptionCollection extension, ModuleDescription module, ref int curPos, BaseCondition parentCondition, bool inComplextCondition, ArrayList addedNodes)
        {
            foreach (ExtensionNodeDescription elem in extension) {

                if (inComplextCondition) {
                    parentCondition = ReadComplexCondition (elem, parentCondition);
                    inComplextCondition = false;
                    continue;
                }

                if (elem.NodeName == "ComplexCondition") {
                    LoadExtensionElement (tnode, addin, elem.ChildNodes, module, ref curPos, parentCondition, true, addedNodes);
                    continue;
                }

                if (elem.NodeName == "Condition") {
                    Condition cond = new Condition (AddinEngine, elem, parentCondition);
                    LoadExtensionElement (tnode, addin, elem.ChildNodes, module, ref curPos, cond, false, addedNodes);
                    continue;
                }

                var pnode = tnode;
                ExtensionPoint extensionPoint = null;
                while (pnode != null && (extensionPoint = pnode.ExtensionPoint) == null)
                    pnode = pnode.Parent;

                string after = elem.GetAttribute ("insertafter");
                if (after.Length == 0 && extensionPoint != null && curPos == -1)
                    after = extensionPoint.DefaultInsertAfter;
                if (after.Length > 0) {
                    int i = tnode.Children.IndexOfNode (after);
                    if (i != -1)
                        curPos = i+1;
                }
                string before = elem.GetAttribute ("insertbefore");
                if (before.Length == 0 && extensionPoint != null && curPos == -1)
                    before = extensionPoint.DefaultInsertBefore;
                if (before.Length > 0) {
                    int i = tnode.Children.IndexOfNode (before);
                    if (i != -1)
                        curPos = i;
                }

                // If node position is not explicitly set, add the node at the end
                if (curPos == -1)
                    curPos = tnode.Children.Count;

                // Find the type of the node in this extension
                ExtensionNodeType ntype = addinEngine.FindType (tnode.ExtensionNodeSet, elem.NodeName, addin);

                if (ntype == null) {
                    addinEngine.ReportError ("Node '" + elem.NodeName + "' not allowed in extension: " + tnode.GetPath (), addin, null, false);
                    continue;
                }

                string id = elem.GetAttribute ("id");
                if (id.Length == 0)
                    id = AutoIdPrefix + (++internalId);

                TreeNode cnode = new TreeNode (addinEngine, id);

                ExtensionNode enode = ReadNode (cnode, addin, ntype, elem, module);
                if (enode == null)
                    continue;

                cnode.Condition = parentCondition;
                cnode.ExtensionNodeSet = ntype;
                tnode.InsertChildNode (curPos, cnode);
                addedNodes.Add (cnode);

                if (cnode.Condition != null)
                    Context.RegisterNodeCondition (cnode, cnode.Condition);

                // Load children
                if (elem.ChildNodes.Count > 0) {
                    int cp = 0;
                    LoadExtensionElement (cnode, addin, elem.ChildNodes, module, ref cp, parentCondition, false, addedNodes);
                }

                curPos++;
            }
            if (Context.FireEvents)
                tnode.NotifyChildrenChanged ();
        }
Пример #2
0
        void LoadExtensionElement(TreeNode tnode, string addin, ExtensionNodeDescriptionCollection extension, ref int curPos, BaseCondition parentCondition, bool inComplextCondition, ArrayList addedNodes)
        {
            foreach (ExtensionNodeDescription elem in extension)
            {
                if (inComplextCondition)
                {
                    parentCondition     = ReadComplexCondition(elem, parentCondition);
                    inComplextCondition = false;
                    continue;
                }

                if (elem.NodeName == "ComplexCondition")
                {
                    LoadExtensionElement(tnode, addin, elem.ChildNodes, ref curPos, parentCondition, true, addedNodes);
                    continue;
                }

                if (elem.NodeName == "Condition")
                {
                    Condition cond = new Condition(elem, parentCondition);
                    LoadExtensionElement(tnode, addin, elem.ChildNodes, ref curPos, cond, false, addedNodes);
                    continue;
                }

                string after = elem.GetAttribute("insertafter");
                if (after.Length > 0)
                {
                    int i = tnode.Children.IndexOfNode(after);
                    if (i != -1)
                    {
                        curPos = i + 1;
                    }
                }
                string before = elem.GetAttribute("insertbefore");
                if (before.Length > 0)
                {
                    int i = tnode.Children.IndexOfNode(before);
                    if (i != -1)
                    {
                        curPos = i;
                    }
                }

                // Find the type of the node in this extension
                ExtensionNodeType ntype = AddinManager.SessionService.FindType(tnode.ExtensionNodeSet, elem.NodeName, addin);

                if (ntype == null)
                {
                    AddinManager.ReportError("Node '" + elem.NodeName + "' not allowed in extension: " + tnode.GetPath(), addin, null, false);
                    continue;
                }

                string id = elem.GetAttribute("id");
                if (id.Length == 0)
                {
                    id = AutoIdPrefix + (++internalId);
                }

                TreeNode cnode = new TreeNode(id);

                ExtensionNode enode = ReadNode(cnode, addin, ntype, elem);
                if (enode == null)
                {
                    continue;
                }

                cnode.Condition        = parentCondition;
                cnode.ExtensionNodeSet = ntype;
                tnode.InsertChildNode(curPos, cnode);
                addedNodes.Add(cnode);

                if (cnode.Condition != null)
                {
                    Context.RegisterNodeCondition(cnode, cnode.Condition);
                }

                // Load children
                if (elem.ChildNodes.Count > 0)
                {
                    int cp = 0;
                    LoadExtensionElement(cnode, addin, elem.ChildNodes, ref cp, parentCondition, false, addedNodes);
                }

                curPos++;
            }
            if (Context.FireEvents)
            {
                tnode.NotifyChildrenChanged();
            }
        }
Пример #3
0
        void LoadExtensionElement(TreeNode tnode, string addin, ExtensionNodeDescriptionCollection extension, ModuleDescription module, ref int curPos, BaseCondition parentCondition, bool inComplextCondition, List <TreeNode> addedNodes)
        {
            foreach (ExtensionNodeDescription elem in extension)
            {
                if (inComplextCondition)
                {
                    parentCondition     = ReadComplexCondition(elem, parentCondition);
                    inComplextCondition = false;
                    continue;
                }

                if (elem.NodeName == "ComplexCondition")
                {
                    LoadExtensionElement(tnode, addin, elem.ChildNodes, module, ref curPos, parentCondition, true, addedNodes);
                    continue;
                }

                if (elem.NodeName == "Condition")
                {
                    Condition cond = new Condition(AddinEngine, elem, parentCondition);
                    LoadExtensionElement(tnode, addin, elem.ChildNodes, module, ref curPos, cond, false, addedNodes);
                    continue;
                }

                var            pnode          = tnode;
                ExtensionPoint extensionPoint = null;
                while (pnode != null && (extensionPoint = pnode.ExtensionPoint) == null)
                {
                    pnode = pnode.Parent;
                }

                string after = elem.GetAttribute("insertafter");
                if (after.Length == 0 && extensionPoint != null && curPos == -1)
                {
                    after = extensionPoint.DefaultInsertAfter;
                }
                if (after.Length > 0)
                {
                    int i = tnode.Children.IndexOfNode(after);
                    if (i != -1)
                    {
                        curPos = i + 1;
                    }
                }
                string before = elem.GetAttribute("insertbefore");
                if (before.Length == 0 && extensionPoint != null && curPos == -1)
                {
                    before = extensionPoint.DefaultInsertBefore;
                }
                if (before.Length > 0)
                {
                    int i = tnode.Children.IndexOfNode(before);
                    if (i != -1)
                    {
                        curPos = i;
                    }
                }

                // If node position is not explicitly set, add the node at the end
                if (curPos == -1)
                {
                    curPos = tnode.Children.Count;
                }

                // Find the type of the node in this extension
                ExtensionNodeType ntype = addinEngine.FindType(tnode.ExtensionNodeSet, elem.NodeName, addin);

                if (ntype == null)
                {
                    addinEngine.ReportError("Node '" + elem.NodeName + "' not allowed in extension: " + tnode.GetPath(), addin, null, false);
                    continue;
                }

                string id = elem.GetAttribute("id");
                if (id.Length == 0)
                {
                    id = AutoIdPrefix + (++internalId);
                }

                TreeNode cnode = new TreeNode(addinEngine, id);

                ExtensionNode enode = ReadNode(cnode, addin, ntype, elem, module);
                if (enode == null)
                {
                    continue;
                }

                cnode.Condition        = parentCondition;
                cnode.ExtensionNodeSet = ntype;
                tnode.InsertChildNode(curPos, cnode);
                addedNodes.Add(cnode);

                if (cnode.Condition != null)
                {
                    Context.RegisterNodeCondition(cnode, cnode.Condition);
                }

                // Load children
                if (elem.ChildNodes.Count > 0)
                {
                    int cp = 0;
                    LoadExtensionElement(cnode, addin, elem.ChildNodes, module, ref cp, parentCondition, false, addedNodes);
                }

                curPos++;
            }
            if (Context.FireEvents)
            {
                tnode.NotifyChildrenChanged();
            }
        }
		void LoadExtensionElement (TreeNode tnode, string addin, ExtensionNodeDescriptionCollection extension, ref int curPos, BaseCondition parentCondition, bool inComplextCondition, ArrayList addedNodes)
		{
			foreach (ExtensionNodeDescription elem in extension) {
					
				if (inComplextCondition) {
					parentCondition = ReadComplexCondition (elem, parentCondition);
					inComplextCondition = false;
					continue;
				}

				if (elem.NodeName == "ComplexCondition") {
					LoadExtensionElement (tnode, addin, elem.ChildNodes, ref curPos, parentCondition, true, addedNodes);
					continue;
				}
					
				if (elem.NodeName == "Condition") {
					Condition cond = new Condition (elem, parentCondition);
					LoadExtensionElement (tnode, addin, elem.ChildNodes, ref curPos, cond, false, addedNodes);
					continue;
				}
					
				string after = elem.GetAttribute ("insertafter");
				if (after.Length > 0) {
					int i = tnode.Children.IndexOfNode (after);
					if (i != -1)
						curPos = i+1;
				}
				string before = elem.GetAttribute ("insertbefore");
				if (before.Length > 0) {
					int i = tnode.Children.IndexOfNode (before);
					if (i != -1)
						curPos = i;
				}
				
				// Find the type of the node in this extension
				ExtensionNodeType ntype = AddinManager.SessionService.FindType (tnode.ExtensionNodeSet, elem.NodeName, addin);
				
				if (ntype == null) {
					AddinManager.ReportError ("Node '" + elem.NodeName + "' not allowed in extension: " + tnode.GetPath (), addin, null, false);
					continue;
				}
				
				string id = elem.GetAttribute ("id");
				if (id.Length == 0)
					id = AutoIdPrefix + (++internalId);

				TreeNode cnode = new TreeNode (id);
				
				ExtensionNode enode = ReadNode (cnode, addin, ntype, elem);
				if (enode == null)
					continue;

				cnode.Condition = parentCondition;
				cnode.ExtensionNodeSet = ntype;
				tnode.InsertChildNode (curPos, cnode);
				addedNodes.Add (cnode);
				
				if (cnode.Condition != null)
					Context.RegisterNodeCondition (cnode, cnode.Condition);

				// Load children
				if (elem.ChildNodes.Count > 0) {
					int cp = 0;
					LoadExtensionElement (cnode, addin, elem.ChildNodes, ref cp, parentCondition, false, addedNodes);
				}
				
				curPos++;
			}
			if (Context.FireEvents)
				tnode.NotifyChildrenChanged ();
		}