本文整理汇总了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);
}
示例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)));
}
}