本文整理汇总了C#中ModelElement.ReferenceName方法的典型用法代码示例。如果您正苦于以下问题:C# ModelElement.ReferenceName方法的具体用法?C# ModelElement.ReferenceName怎么用?C# ModelElement.ReferenceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelElement
的用法示例。
在下文中一共展示了ModelElement.ReferenceName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceNonTerminal
/// <summary>
/// Removes the prefix according to the StartRemove and EndRemove values
/// </summary>
/// <param name="treeNode">The tree node to replace</param>
/// <param name="referencedElement">The element that should be replaced</param>
/// <returns>if the replacement has been done</returns>
private bool ReplaceNonTerminal(InterpreterTreeNode treeNode, ModelElement referencedElement)
{
bool retVal;
if (ReplaceAllReferences)
{
// Only do the repleacement for elements defined in a dictionary
retVal = EnclosingFinder<Dictionary>.find(referencedElement) != null;
}
else
{
// Check that the reference corresponds to the specific reference for this visitor
retVal = referencedElement == Ref;
}
if (retVal)
{
// Removes the prefix
if (ShouldRemovePrefix)
{
ReplaceText("", StartRemove, EndRemove);
ResetRemoveIndexes();
}
string replacementValue = referencedElement.ReferenceName(User);
ReplaceText(replacementValue, treeNode.Start, treeNode.End);
}
return retVal;
}
示例2: RefactorTypedElement
/// <summary>
/// Refactors an element which has a type
/// </summary>
/// <param name="element">The element that has been modified</param>
/// <param name="user">The user which references this type</param>
private static void RefactorTypedElement(ModelElement element, ITypedElement user)
{
if (user != null)
{
ModelElement enclosing = EnclosingFinder<NameSpace>.find(user, true);
try
{
Function userFunction = user as Function;
if ((user.Type == element))
{
string newName = element.ReferenceName(enclosing);
user.TypeName = newName;
}
else if (userFunction != null && userFunction.ReturnType == element)
{
userFunction.ReturnType = element as Type;
}
else if (element is NameSpace)
{
string newName;
Function function = user as Function;
if (function != null)
{
newName = function.ReturnType.ReferenceName(user as ModelElement);
user.TypeName = newName;
}
else
{
newName = user.Type.ReferenceName(user as ModelElement);
user.TypeName = newName;
}
}
}
catch (Exception e)
{
((ModelElement) user).AddError("Cannot refactor this element, reason = " + e.Message);
}
}
}