本文整理汇总了C#中MemberList.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# MemberList.Sort方法的具体用法?C# MemberList.Sort怎么用?C# MemberList.Sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberList
的用法示例。
在下文中一共展示了MemberList.Sort方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllProjectClasses
/// <summary>
/// Return the full project classes list
/// </summary>
/// <returns></returns>
public override MemberList GetAllProjectClasses()
{
// from cache
if (!completionCache.IsDirty && completionCache.AllTypes != null)
return completionCache.AllTypes;
MemberList fullList = new MemberList();
MemberModel item;
// public & internal classes
string package = CurrentModel.Package;
foreach (PathModel aPath in classPath) if (aPath.IsValid && !aPath.Updating)
{
aPath.ForeachFile((aFile) =>
{
if (!aFile.HasPackage)
return true; // skip
foreach(ClassModel aClass in aFile.Classes)
if (!aClass.IsVoid() && aClass.IndexType == null)
{
if (aClass.Access == Visibility.Public
|| (aClass.Access == Visibility.Internal && aFile.Package == package))
{
item = aClass.ToMemberModel();
item.Name = item.Type;
fullList.Add(item);
}
}
if (aFile.Package.Length > 0 && aFile.Members.Count > 0)
{
foreach (MemberModel member in aFile.Members)
{
item = member.Clone() as MemberModel;
item.Name = aFile.Package + "." + item.Name;
fullList.Add(item);
}
}
else if (aFile.Members.Count > 0)
{
foreach (MemberModel member in aFile.Members)
{
item = member.Clone() as MemberModel;
fullList.Add(item);
}
}
return true;
});
}
// void
fullList.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0));
// private classes
fullList.Add(GetPrivateClasses());
// in cache
fullList.Sort();
completionCache.AllTypes = fullList;
return fullList;
}
示例2: GetSortedInheritedMembersList
/// <summary>
/// Returns all members inherited from super classes of this class.
/// Does not take static inheritance into account.
/// </summary>
internal MemberList GetSortedInheritedMembersList()
{
MemberList items = new MemberList();
ClassModel curClass = this;
do
{
curClass.ResolveExtends();
curClass = curClass.Extends;
MemberList newMembers = curClass.GetSortedMembersList();
items.Merge(newMembers);
} while (curClass.Extends != VoidClass);
items.RemoveAllWithFlag(FlagType.Static);
items.Sort();
return items;
}
示例3: GetSortedMembersList
/// <summary>
/// Return a sorted list of the file
/// </summary>
/// <returns></returns>
internal MemberList GetSortedMembersList()
{
MemberList items = new MemberList();
items.Add(Members);
items.Sort();
return items;
}
示例4: GetVisibleExternalElements
/// <summary>
/// Return the elements (package, types, etc) visible from the current file
/// </summary>
/// <param name="typesOnly">Return only packages & types</param>
/// <returns></returns>
public override MemberList GetVisibleExternalElements(bool typesOnly)
{
MemberList visibleElements = new MemberList();
if (!IsFileValid) return visibleElements;
// top-level elements
if (!typesOnly && topLevel != null)
{
if (topLevel.OutOfDate) InitTopLevelElements();
visibleElements.Add(topLevel.Members);
}
if (completionCache.IsDirty)
{
MemberList elements = new MemberList();
// root types & packages
FileModel baseElements = ResolvePackage(null, false);
if (baseElements != null)
{
elements.Add(baseElements.Imports);
elements.Add(baseElements.Members);
}
elements.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0));
bool qualify = Settings.CompletionShowQualifiedTypes && settings.GenerateImports;
// other classes in same package
if (features.hasPackages && cFile.Package != "")
{
FileModel packageElements = ResolvePackage(cFile.Package, false);
if (packageElements != null)
{
foreach (MemberModel member in packageElements.Imports)
{
if (member.Flags != FlagType.Package)
{
if (qualify) member.Name = member.Type;
elements.Add(member);
}
}
foreach (MemberModel member in packageElements.Members)
{
string pkg = member.InFile.Package;
if (qualify && pkg != "") member.Name = pkg + "." + member.Name;
elements.Add(member);
}
}
}
// other classes in same file
if (cFile.PrivateSectionIndex > 0)
{
if (inPrivateSection && cFile.Classes.Count > 1)
{
ClassModel mainClass = cFile.GetPublicClass();
if (!mainClass.IsVoid())
{
MemberModel toRemove = elements.Search(mainClass.Name, 0, 0);
if (toRemove != null && toRemove.Type == mainClass.QualifiedName)
elements.Remove(toRemove);
}
}
MemberModel member;
foreach (ClassModel aClass in cFile.Classes)
{
if (features.hasMultipleDefs || aClass.Access == Visibility.Private)
{
member = aClass.ToMemberModel();
elements.Add(member);
}
}
}
// imports
elements.Add(ResolveImports(CurrentModel));
// in cache
elements.Sort();
completionCache = new CompletionCache(this, elements);
// known classes colorization
if (!CommonSettings.DisableKnownTypesColoring && !settings.LazyClasspathExploration && CurSciControl != null)
{
try
{
CurSciControl.KeyWords(1, completionCache.Keywords); // additional-keywords index = 1
CurSciControl.Colourise(0, -1); // re-colorize the editor
}
catch (AccessViolationException){} // catch memory errors
}
}
visibleElements.Merge(completionCache.Elements);
return visibleElements;
}
示例5: GetSortedMembersList
internal MemberList GetSortedMembersList()
{
MemberList items = new MemberList();
foreach (MemberModel item in Members)
if ((item.Flags & FlagType.Constructor) == 0) items.Add(item);
items.Sort();
return items;
}
示例6: GetBasePackages
/// <summary>
/// Search all base packages (com, net, org,...) in classpath
/// </summary>
/// <returns>Base packages list as members</returns>
public override MemberList GetBasePackages()
{
MemberList packages = new MemberList();
MemberModel package;
string[] dirEntries;
string[] fileEntries;
string cname;
string upPath;
string mmCP = MMClassPath.ToUpper();
string mtascCP = mtascRootFolder.ToUpper();
bool notMacromedia;
bool notMTASC;
foreach(string path in classPath)
try
{
upPath = path.ToUpper();
notMacromedia = (mmCP.Length == 0) || !upPath.StartsWith(mmCP);
notMTASC = (mtascCP.Length == 0) || !upPath.StartsWith(mtascCP);
// base classes
if (notMacromedia && notMTASC)
{
fileEntries = System.IO.Directory.GetFiles(path, "*.as");
if (fileEntries != null)
foreach(string entry in fileEntries)
{
cname = GetLastStringToken(entry, dirSeparator);
int p = cname.LastIndexOf('.');
cname = cname.Substring(0,p);
if (!cname.StartsWith("_") && (cname.IndexOf('.') < 0) && (cname.IndexOf(' ') < 0)
&& (packages.Search(cname, 0) == null))
{
//DebugConsole.Trace("Base class "+cname);
package = new MemberModel();
package.Flags = 0;
package.Type = package.Name = cname;
packages.Add(package);
}
}
}
// base packages
if (notMacromedia)
{
dirEntries = System.IO.Directory.GetDirectories(path);
if (dirEntries != null)
foreach(string entry in dirEntries)
{
cname = GetLastStringToken(entry, dirSeparator);
if (!cname.StartsWith("_") && (cname.IndexOf(' ') < 0) && (cname.IndexOf('.') < 0)
&& (packages.Search(cname, 0) == null))
{
//DebugConsole.Trace("Base package "+cname);
package = new MemberModel();
package.Flags = FlagType.Package;
package.Type = package.Name = cname;
packages.Add(package);
}
}
}
else if (packages.Search("mx", 0) == null)
{
package = new MemberModel();
package.Flags = FlagType.Package;
package.Type = package.Name = "mx";
packages.Add(package);
}
}
catch(Exception ex)
{
ErrorHandler.ShowError(ex.Message+"\n"+path, ex);
}
packages.Sort();
return packages;
}
示例7: GetAllProjectClasses
/// <summary>
/// Return the full project classes list
/// </summary>
/// <returns></returns>
public override MemberList GetAllProjectClasses()
{
// from cache
if (!completionCache.IsDirty && completionCache.AllTypes != null)
return completionCache.AllTypes;
MemberList fullList = new MemberList();
ClassModel aClass;
MemberModel item;
// public classes
foreach (PathModel aPath in classPath) if (aPath.IsValid && !aPath.Updating)
{
aPath.ForeachFile((aFile) =>
{
aClass = aFile.GetPublicClass();
if (!aClass.IsVoid() && aClass.IndexType == null && aClass.Access == Visibility.Public)
{
item = aClass.ToMemberModel();
item.Name = item.Type;
fullList.Add(item);
}
return true;
});
}
// void
fullList.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0));
// in cache
fullList.Sort();
completionCache.AllTypes = fullList;
return fullList;
}
示例8: FindPackage
/// <summary>
/// Find folder and classes in classpath
/// </summary>
/// <param name="folder">Path to eval</param>
/// <param name="completeContent">Return package content</param>
/// <returns>Package folders and classes</returns>
public override MemberList FindPackage(string folder, bool completeContent)
{
if ((folder == null) || (folder.Length == 0))
return null;
MemberList package = new MemberList();
MemberModel pathMember;
string[] dirEntries;
string cname;
foreach(string path in classPath)
try
{
if (System.IO.Directory.Exists(path+folder))
{
// continue parsing?
if (!completeContent) return package;
// add sub packages
dirEntries = System.IO.Directory.GetDirectories(path+folder);
if (dirEntries != null)
foreach(string entry in dirEntries)
{
cname = GetLastStringToken(entry, dirSeparator);
if ((cname.Length > 0) && !cname.StartsWith("_")
&& (cname.IndexOf(' ') < 0) && (cname.IndexOf('.') < 0)
&& (package.Search(cname, 0) == null))
{
pathMember = new MemberModel();
pathMember.Flags = FlagType.Package;
pathMember.Type = folder.Replace(dirSeparatorChar, '.')+"."+cname;
pathMember.Name = cname;
package.Add(pathMember);
}
}
// add sub classes
dirEntries = System.IO.Directory.GetFiles(path+folder);
if (dirEntries != null)
foreach(string entry in dirEntries)
if (entry.EndsWith(".as")) {
cname = GetLastStringToken(entry, dirSeparator);
cname = cname.Substring(0, cname.LastIndexOf("."));
pathMember = package.Search(cname, 0);
if ((pathMember == null) && (cname.Length > 0)
&& (cname.IndexOf(' ') < 0) && (cname.IndexOf('.') < 0))
{
pathMember = new MemberModel();
pathMember.Flags = 0;
pathMember.Type = folder.Replace(dirSeparatorChar,'.')+"."+cname;
pathMember.Name = cname;
package.Add(pathMember);
}
}
}
}
catch(Exception ex)
{
ErrorHandler.ShowError(ex.Message+"\n"+path+folder, ex);
}
// result
if (package.Count > 0)
{
package.Sort();
return package;
}
else return null;
}
示例9: GetVisibleExternalElements
/// <summary>
/// Return the visible elements (types, package-level declarations) visible from the current file
/// </summary>
/// <returns></returns>
public override MemberList GetVisibleExternalElements()
{
if (!IsFileValid) return new MemberList();
if (completionCache.IsDirty)
{
MemberList elements = new MemberList();
MemberList other = new MemberList();
// root types & packages
FileModel baseElements = ResolvePackage(null, false);
if (baseElements != null)
{
elements.Add(baseElements.Imports);
foreach(MemberModel decl in baseElements.Members)
if ((decl.Flags & (FlagType.Class | FlagType.Enum | FlagType.TypeDef | FlagType.Abstract)) > 0)
elements.Add(decl);
}
elements.Add(new MemberModel(features.voidKey, features.voidKey, FlagType.Class | FlagType.Intrinsic, 0));
// other classes in same package (or parent packages!)
if (features.hasPackages && cFile.Package != "")
{
string package = cFile.Package;
do
{
int pLen = package.Length;
FileModel packageElements = ResolvePackage(package, false);
if (packageElements != null)
{
foreach (MemberModel member in packageElements.Imports)
{
if (member.Flags != FlagType.Package && member.Type.LastIndexOf('.') == pLen)
{
//if (qualify) member.Name = member.Type;
elements.Add(member);
}
}
foreach (MemberModel member in packageElements.Members)
{
string pkg = member.InFile.Package;
//if (qualify && pkg != "") member.Name = pkg + "." + member.Name;
member.Type = pkg != "" ? pkg + "." + member.Name : member.Name;
elements.Add(member);
}
}
int p = package.LastIndexOf('.'); // parent package
if (p < 0) break;
package = package.Substring(0, p);
}
while (true);
}
// other types in same file
if (cFile.Classes.Count > 1)
{
ClassModel mainClass = cFile.GetPublicClass();
foreach (ClassModel aClass in cFile.Classes)
{
if (mainClass == aClass) continue;
elements.Add(aClass.ToMemberModel());
if (aClass.IsEnum())
other.Add(aClass.Members);
}
}
// imports
MemberList imports = ResolveImports(CurrentModel);
elements.Add(imports);
foreach (MemberModel import in imports)
{
if (import is ClassModel)
{
ClassModel aClass = import as ClassModel;
if (aClass.IsEnum()) other.Add(aClass.Members);
}
}
// in cache
elements.Sort();
other.Sort();
completionCache = hxCompletionCache = new HaxeCompletionCache(this, elements, other);
// known classes colorization
if (!CommonSettings.DisableKnownTypesColoring && !settings.LazyClasspathExploration && CurSciControl != null)
{
try
{
CurSciControl.KeyWords(1, completionCache.Keywords); // additional-keywords index = 1
CurSciControl.Colourise(0, -1); // re-colorize the editor
}
catch (AccessViolationException) { } // catch memory errors
}
}
//.........这里部分代码省略.........
示例10: GetAllProjectClasses
/// <summary>
/// Return the full project classes list
/// </summary>
/// <returns></returns>
public override MemberList GetAllProjectClasses()
{
// from cache
if (!completionCache.IsDirty && completionCache.AllTypes != null)
return completionCache.AllTypes;
MemberList fullList = new MemberList();
MemberModel item;
// public & internal classes
string package = CurrentModel.Package;
foreach (PathModel aPath in classPath) if (aPath.IsValid && !aPath.Updating)
{
aPath.ForeachFile((aFile) =>
{
string module = aFile.Module;
bool needModule = true;
if (aFile.Classes.Count > 0 && !aFile.Classes[0].IsVoid())
foreach (ClassModel aClass in aFile.Classes)
{
string tpackage = aClass.InFile.Package;
if (aClass.IndexType == null
&& (aClass.Access == Visibility.Public
|| (aClass.Access == Visibility.Internal && tpackage == package)))
{
if (aClass.Name == module) needModule = false;
item = aClass.ToMemberModel();
//if (tpackage != package)
if (item.Type != null) item.Name = item.Type;
fullList.Add(item);
}
}
// HX files correspond to a "module" which should appear in code completion
// (you don't import classes defined in modules but the module itself)
if (needModule)
{
string qmodule = aFile.FullPackage;
if (qmodule != null)
{
item = new MemberModel(qmodule, qmodule, FlagType.Class | FlagType.Module, Visibility.Public);
fullList.Add(item);
}
}
return true;
});
}
// display imported classes and classes declared in imported modules
MemberList imports = ResolveImports(cFile);
FlagType mask = FlagType.Class | FlagType.Enum;
foreach (MemberModel import in imports)
{
if ((import.Flags & mask) > 0)
{
/*if (import is ClassModel)
{
MemberModel cmodel = (import as ClassModel).ToMemberModel();
cmodel.Name = cmodel.Type;
fullList.Add(cmodel);
}
else*/ fullList.Add(import);
}
}
foreach(ClassModel aClass in cFile.Classes)
fullList.Add(aClass.ToMemberModel());
// in cache
fullList.Sort();
completionCache.AllTypes = fullList;
return fullList;
}
示例11: OnDotCompletionResult
internal void OnDotCompletionResult(HaXeCompletion hc, ArrayList al)
{
resolvingDot = false;
if (al == null || al.Count == 0)
return; // haxe.exe not found
ScintillaNet.ScintillaControl sci = hc.sci;
MemberList list = new MemberList();
string outputType = al[0].ToString();
if (outputType == "error")
{
string err = al[1].ToString();
TraceManager.AddAsync(err, -3);
//sci.CallTipShow(sci.CurrentPos, err);
//sci.CharAdded += new ScintillaNet.CharAddedHandler(removeTip);
// show default completion tooltip
if (!hxsettings.DisableMixedCompletion)
return;
}
else if (outputType == "list")
{
foreach (ArrayList i in al[1] as ArrayList)
{
string var = i[0].ToString();
string type = i[1].ToString();
string desc = i[2].ToString();
FlagType flag = FlagType.Variable;
MemberModel member = new MemberModel();
member.Name = var;
member.Access = Visibility.Public;
member.Comments = desc;
var p1 = desc.IndexOf('\r');
var p2 = desc.IndexOf('\n');
// Package or Class
if (type == "")
{
string bl = var.Substring(0, 1);
if (bl == bl.ToLower())
flag = FlagType.Package;
else
flag = FlagType.Class;
}
// Function or Variable
else
{
Array types = type.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries);
// Function
if (types.Length > 1)
{
flag = FlagType.Function;
// Function's arguments
member.Parameters = new List<MemberModel>();
int j = 0;
while (j < types.Length - 1)
{
MemberModel param = new MemberModel(types.GetValue(j).ToString(), "", FlagType.ParameterVar, Visibility.Public);
member.Parameters.Add(param);
j++;
}
// Function's return type
member.Type = types.GetValue(types.Length - 1).ToString();
}
// Variable
else
{
flag = FlagType.Variable;
// Variable's type
member.Type = type;
}
}
member.Flags = flag;
list.Add(member);
}
}
// update completion
if (list.Count > 0)
{
list.Sort();
ASComplete.DotContextResolved(sci, hc.expr, list, hc.autoHide);
}
}