当前位置: 首页>>代码示例>>C#>>正文


C# Controller.AddChildAtXPath方法代码示例

本文整理汇总了C#中Controller.AddChildAtXPath方法的典型用法代码示例。如果您正苦于以下问题:C# Controller.AddChildAtXPath方法的具体用法?C# Controller.AddChildAtXPath怎么用?C# Controller.AddChildAtXPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Controller的用法示例。


在下文中一共展示了Controller.AddChildAtXPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddComponentToCache

        public void AddComponentToCache(Controller c, AME.Model.Model model, int topID, int parentID, int id, string type, string baseType, int linkID, string name, string linkType, string desc, Component.eComponentType eType, String lastValidateAddParentXPath, List<ComponentFunction> lastSchemaValuesValidateAdd)
        {
            String key = CreateCacheKey(topID, topID, linkType);
            if (!this.Contains(model, key))
            {
                ComponentOptions full = new ComponentOptions();
                full.CompParams = true;
                full.ClassInstanceInfo = true;
                full.SubclassInstanceInfo = true;
                full.LinkParams = true;
                XmlDocument doc2 = c._GetComponentsXmlDoc(topID, topID, linkType, full);
                AddCacheDocument(model, key, doc2);
                // This occurs at the -end- of a connect that would normally cause a cache add.
                // However, we haven't seen the document before, and the connect has already gone through to the DB.
                // This means the document we just retrieved above to initially populate the cache (c_.GetCompnentsXmlDoc)
                // already contains the item we're looking to add with this call.  So we should actually just return.
                // If we continue as below we will see doubles for the first items added under a linktype.
                // Because the cache is similarly populated (outside of this call) when a linktype is fetched, this side effect usually occurs with programmatic creation
                // where no data has been fetched / used yet, but links are being created and items are being added to the cache.

                // grab the element we're interested in (including children)
                XmlElement alreadyPresent = (XmlElement)doc2.SelectSingleNode(lastValidateAddParentXPath + createComponentXPath(id).Substring(1)); // remove the first slash in the //Component

                // bug fix - add to other link types as well
                addToOtherLinkTypes(key, c, model, alreadyPresent, id, linkID, linkType, lastValidateAddParentXPath);

                return;
            }
            XmlDocument doc = documentCache[model][key];
            XmlElement createForCache;
            DataTable childCheck = model.GetChildComponentLinks(id, linkType);
            if (childCheck.Rows.Count > 0)
            {
                ComponentOptions full = new ComponentOptions();
                full.CompParams = true;
                full.ClassInstanceInfo = true;
                full.SubclassInstanceInfo = true;
                full.LinkParams = true;
                XmlDocument thisCompDoc = (XmlDocument)c._GetComponentsXmlDoc(topID, id, linkType, full);
                XmlNode findChild = thisCompDoc.SelectSingleNode("/Components/Component");
                // set the link ID - the get call doesn't have enough information to do this for the top component
                int lID = c.GetLinkID(parentID, id, linkType);
                XmlAttribute attrLinkID = thisCompDoc.CreateAttribute(XmlSchemaConstants.Display.Component.LinkID);
                attrLinkID.Value = ""+lID;
                findChild.Attributes.Append(attrLinkID);

                // link parameters?
                IXPathNavigable linkParameters = c.GetParametersForLink(lID);

                if (linkParameters != null)
                {
                    XmlNode insert = ((XmlNode)linkParameters).SelectSingleNode(XmlSchemaConstants.Display.sLinkParameters);
                    insert = thisCompDoc.ImportNode(insert, true);
                    findChild.AppendChild(insert);
                }
   
                findChild = doc.ImportNode(findChild, true);
                createForCache = (XmlElement)findChild;
            }
            else
            {
                createForCache = CreateCacheElement(c, doc, id, linkID, type, baseType, name, desc, eType, lastSchemaValuesValidateAdd);
            }
 
            c.AddChildAtXPath(doc, lastValidateAddParentXPath, createForCache, false);
            
            // find other documents with the same linktype = e.g. display ID based
            addToOtherLinkTypes(key, c, model, createForCache, id, linkID, linkType, lastValidateAddParentXPath);
        }
开发者ID:wshanshan,项目名称:DDD,代码行数:69,代码来源:XMLCache.cs

示例2: addToOtherLinkTypes

        private void addToOtherLinkTypes(String key, Controller c, AME.Model.Model model, XmlElement createForCache, int id, int linkID, string linkType, string lastValidateAddParentXPath)
        {
            XmlDocument doc;
            // find other documents with the same linktype = e.g. display ID based
            foreach (String documentKey in documentCache[model].Keys)
            {
                String parsedLinkType = parseLinkType(documentKey);
                if (parsedLinkType.Equals(linkType) && documentKey != key)
                {
                    doc = documentCache[model][documentKey];
                    try
                    {
                        createForCache = (XmlElement)doc.ImportNode(createForCache, true);
                        c.AddChildAtXPath(doc, lastValidateAddParentXPath, createForCache, false);
                    }
                    catch (Exception) { } // parent didn't exist - ok to skip
                }
            }

            if (!componentXPaths[model].ContainsKey(id))
            {
                componentXPaths[model].Add(id, XPathExpression.Compile(createComponentXPath(id)));
            }

            if (!linkXPaths[model].ContainsKey(linkID))
            {
                linkXPaths[model].Add(linkID, XPathExpression.Compile(createLinkXPath(linkID)));
            }
        }
开发者ID:wshanshan,项目名称:DDD,代码行数:29,代码来源:XMLCache.cs


注:本文中的Controller.AddChildAtXPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。