本文整理汇总了C#中Path.ItemAtPath方法的典型用法代码示例。如果您正苦于以下问题:C# Path.ItemAtPath方法的具体用法?C# Path.ItemAtPath怎么用?C# Path.ItemAtPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.ItemAtPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Evaluate
internal override OpenEhr.Paths.AssertionContext Evaluate(OpenEhr.Paths.AssertionContext obj)
{
switch (this.ReferenceType.ToLower(System.Globalization.CultureInfo.InvariantCulture))
{
case "constraint":
case "pattern":
return new OpenEhr.Paths.AssertionContext(this.Item, obj);
case "path":
string path = this.item.ToString();
Path pathProcessor = new Path(path);
object objectAtPath = pathProcessor.ItemAtPath(obj.Data);
return new OpenEhr.Paths.AssertionContext(objectAtPath, obj);
default:
throw new ApplicationException(string.Format(
AmValidationStrings.UnsupportedExprLeafReferenceType, this.ReferenceType));
}
}
示例2: ItemAtPathUtil
private object ItemAtPathUtil(string path)
{
DesignByContract.Check.Require(!string.IsNullOrEmpty(path), "Path must not be null or empty.");
object itemAtPath;
if (path == "/")
{
Pathable pathableObject = this;
while (pathableObject.Parent != null)
pathableObject = pathableObject.Parent;
itemAtPath = pathableObject;
}
else
{
Path pathProcessor = new Path(path);
//// The itemAtPath can be a single item which is a pathable, a locatable
//// or a non-pathable item.
//// The itemAtPath can be an IList instance when the path points to
//// a locatable collection with multiple items or a single item;
//// or it can be an IList with one or more
//// locatables when the path looks like //*[archetype ID] (i.e. the path is not
//// named and is terminal)
//// The itemAtPath can be null when the path doesn't exist.
//object itemAtPath = this.ItemAtPathPathProcessorUtil(pathProcessor);
itemAtPath = pathProcessor.ItemAtPath(this);
if (this.itemAtPathDictionary == null)
itemAtPathDictionary = new System.Collections.Generic.Dictionary<string, object>();
// this function is called only when the itemAtPathDictionary doesn't have the key - path,
// therefore, don't need to check whether the dictionary has the key or not before
// adding the key-value pair.
Check.Assert(!this.itemAtPathDictionary.ContainsKey(path), "itemAtPathDiction must not contain path");
if (itemAtPath != null)
this.itemAtPathDictionary.Add(path, itemAtPath);
}
return itemAtPath;
}