本文整理汇总了C#中MemberModel.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# MemberModel.Clone方法的具体用法?C# MemberModel.Clone怎么用?C# MemberModel.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberModel
的用法示例。
在下文中一共展示了MemberModel.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsImported
/// <summary>
/// Check if a type is already in the file's imports
/// Throws an Exception if the type name is ambiguous
/// (ie. same name as an existing import located in another package)
/// </summary>
/// <param name="member">Element to search in imports</param>
/// <param name="atLine">Position in the file</param>
public override bool IsImported(MemberModel member, int atLine)
{
int p = member.Name.IndexOf('#');
if (p > 0)
{
member = member.Clone() as MemberModel;
member.Name = member.Name.Substring(0, p);
}
FileModel cFile = ASContext.Context.CurrentModel;
string fullName = member.Type;
string name = member.Name;
foreach (MemberModel import in cFile.Imports)
{
if (import.Name == name)
{
//if (import.Type != fullName) throw new Exception(TextHelper.GetString("Info.AmbiguousType"));
return true;
}
else if (import.Name == "*" && import.Type.Replace("*", name) == fullName)
return true;
else if (fullName.StartsWithOrdinal(import.Type + "."))
return true;
}
return false;
}
示例2: AddAsParameter
private static void AddAsParameter(ClassModel inClass, ScintillaNet.ScintillaControl Sci, MemberModel member, bool detach)
{
if (!RemoveLocalDeclaration(Sci, contextMember)) return;
int posStart = Sci.PositionFromLine(member.LineFrom);
int posEnd = Sci.LineEndPosition(member.LineTo);
Sci.SetSel(posStart, posEnd);
string selectedText = Sci.SelText;
Regex rStart = new Regex(@"\s{1}" + member.Name + @"\s*\(([^\)]*)\)(\s*:\s*([^({{|\n|\r|\s|;)]+))?");
Match mStart = rStart.Match(selectedText);
if (!mStart.Success)
return;
int start = mStart.Index + posStart + 1;
int end = mStart.Index + posStart + mStart.Length;
Sci.SetSel(start, end);
MemberModel memberCopy = (MemberModel) member.Clone();
if (memberCopy.Parameters == null)
memberCopy.Parameters = new List<MemberModel>();
memberCopy.Parameters.Add(contextMember);
string template = TemplateUtils.ToDeclarationString(memberCopy, TemplateUtils.GetTemplate("MethodDeclaration"));
InsertCode(start, template);
int currPos = Sci.LineEndPosition(Sci.CurrentLine);
Sci.SetSel(currPos, currPos);
Sci.CurrentPos = currPos;
}
示例3: IsImported
/// <summary>
/// Check if a type is already in the file's imports
/// Throws an Exception if the type name is ambiguous
/// (ie. same name as an existing import located in another package)
/// </summary>
/// <param name="member">Element to search in imports</param>
/// <param name="atLine">Position in the file</param>
public override bool IsImported(MemberModel member, int atLine)
{
int p = member.Name.IndexOf('#');
if (p > 0)
{
member = member.Clone() as MemberModel;
member.Name = member.Name.Substring(0, p);
}
FileModel cFile = ASContext.Context.CurrentModel;
string fullName = member.Type;
string name = member.Name;
int lineMin = (ASContext.Context.InPrivateSection) ? cFile.PrivateSectionIndex : 0;
int lineMax = atLine;
foreach (MemberModel import in cFile.Imports)
{
if (import.LineFrom >= lineMin && import.LineFrom <= lineMax && import.Name == name)
{
if (import.Type != fullName) throw new Exception(TextHelper.GetString("Info.AmbiguousType"));
return true;
}
else if (import.Name == "*" && import.Type.Replace("*", name) == fullName)
return true;
}
return false;
}