本文整理汇总了C#中Path.NextStep方法的典型用法代码示例。如果您正苦于以下问题:C# Path.NextStep方法的具体用法?C# Path.NextStep怎么用?C# Path.NextStep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.NextStep方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToLogicalPath
/// <summary>
/// Convert physicalPath to a logical path
/// </summary>
/// <param name="aLanguage"></param>
/// <param name="physicalPath"></param>
/// <returns></returns>
private string ToLogicalPath(string aLanguage, string physicalPath)
{
Path pathProcessor = new Path(physicalPath);
string logicalPath = null;
do
{
logicalPath += "/" + pathProcessor.CurrentAttribute;
if (pathProcessor.IsCurrentIdentified)
{
ArchetypeTerm archetypeTerm = this.Ontology.TermDefinition(aLanguage, pathProcessor.CurrentNodeId);
string name = archetypeTerm.Items.Item("text");
if (string.IsNullOrEmpty(name))
throw new ApplicationException(string.Format(CommonStrings.XIsNullOrEmpty, name));
logicalPath += "[" + name + "]";
}
} while (pathProcessor.NextStep());
Check.Ensure(!string.IsNullOrEmpty(logicalPath), "logicalPath must not be null or empty.");
return logicalPath;
}
示例2: BuildPath
protected void BuildPath(Path path)
{
Check.Require(path != null, "path must not be null");
Check.Require(path.Current != null, "current path step must not be null");
string attributeName = path.Current.Attribute;
object value = GetAttributeValue(attributeName);
if (value == null)
{
CComplexObject complexObjectConstraint = this.Constraint as CComplexObject;
if (complexObjectConstraint == null)
throw new NotImplementedException();
CAttribute attributeConstraint = complexObjectConstraint.GetAttribute(attributeName);
if (attributeConstraint == null)
throw new ApplicationException("constraint for attribute not found");
CMultipleAttribute multipleAttributeConstraint = attributeConstraint as CMultipleAttribute;
if (multipleAttributeConstraint == null)
{
if (attributeConstraint.Children.Count != 1)
throw new ApplicationException("Single attribute constraint must have exactly one children");
CObject objectConstraint = attributeConstraint.Children[0];
CDefinedObject definedObjectConstraint = objectConstraint as CDefinedObject;
if (definedObjectConstraint == null)
throw new NotImplementedException();
value = definedObjectConstraint.DefaultValue;
SetAttributeValue(attributeName, value);
}
else
{
Type itemType = null;
value = multipleAttributeConstraint.CreateAggregate(itemType);
SetAttributeValue(attributeName, value);
}
}
if (path.NextStep())
{
IRmType rmType = value as IRmType;
if (rmType == null)
{
AssumedTypes.IAggregate container = value as AssumedTypes.IAggregate;
if (container != null)
container.BuildPath(path);
else
throw new ApplicationException("expected IRmType");
}
else
rmType.BuildPath(path);
}
}
示例3: GetCObjectAtTargetPath
/// <summary>
/// an internal static method returning the targetPath corresponding CObject.
/// Returns null if the targetPath doesn't have any associated CObject
/// </summary>
/// <param name="archetypeDefinition"></param>
/// <param name="targetPath"></param>
/// <returns></returns>
internal static CObject GetCObjectAtTargetPath(CComplexObject archetypeDefinition, string targetPath)
{
CComplexObject cObj = archetypeDefinition;
CAttribute attribute = null;
Path pathProcessor = new Path(targetPath);
do
{
foreach (CAttribute cAttri in cObj.Attributes)
{
if (cAttri.RmAttributeName == pathProcessor.CurrentAttribute)
{
attribute = cAttri;
break;
}
}
Check.Assert(attribute != null, string.Format(CommonStrings.XMustNotBeNull, "attribute"));
if (attribute.RmAttributeName != pathProcessor.CurrentAttribute)
return null;
foreach (CObject obj in attribute.Children)
{
if (obj.NodeId == pathProcessor.CurrentNodeId)
{
cObj = obj as CComplexObject;
break;
}
}
Check.Assert(cObj != null, string.Format(CommonStrings.XMustNotBeNull, "cObj"));
if (cObj.NodeId != pathProcessor.CurrentNodeId)
return null;
} while (pathProcessor.NextStep());
Check.Ensure(cObj.Path == targetPath, "cObj.Path must be the same as this.TargetPath");
return cObj;
}