本文整理汇总了C#中MemberList.Add方法的典型用法代码示例。如果您正苦于以下问题:C# MemberList.Add方法的具体用法?C# MemberList.Add怎么用?C# MemberList.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberList
的用法示例。
在下文中一共展示了MemberList.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public override MemberList Process(WebClient client)
{
MemberList ml = new MemberList();
String content = client.DownloadString(GetUrl());
MatchCollection mc = Regex.Matches(content,
"<a href=\"http://baki\\.info/subcat/(\\d+)\" class=\"sc_listone\">.*?<span class=\"csc_sub_name\"><div class=\"title_inner\">(.+?)</div>", RegexOptions.Singleline);
if (mc.Count > 0)
{
// process sub categories
foreach (Match m in mc)
{
CategorySub c = new CategorySub();
c.Id = m.Groups[1].Value;
c.Name = m.Groups[2].Value.Replace(" ", " ").Replace("&", "&").Trim();
Children.Add(c);
ml.Add(c);
}
Unprocessed = false;
}
else
{
// process products
content = client.DownloadString(ProductsUrl(page));
MatchCollection mc1 = Regex.Matches(content, "<div class=\"cop_title\"><h3><a href=\"(.+?)\">(.+?)</a></h3></div>");
foreach (Match m in mc1)
{
Product p = new Product();
p.Name = m.Groups[2].Value.Replace(" ", " ").Replace("&", "&").Trim();
p.Url = m.Groups[1].Value;
Children.Add(p);
ml.Add(p);
}
MatchCollection mc2 = Regex.Matches(content, "new Paginator\\('paginator1', (\\d+?), \\d+, (\\d+?), \"#\"\\);");
String total = mc2[0].Groups[1].Value;
String current = mc2[0].Groups[2].Value;
if (page < Int16.Parse(total))
{
Page++;
ml.Add(this);
}
else
{
Unprocessed = false;
}
}
return ml;
}
示例2: Process
public override MemberList Process(WebClient client)
{
MemberList ml = new MemberList();
String content = client.DownloadString(GetUrl());
MatchCollection mc = Regex.Matches(content, "<option value=\"(\\d+)\">(.+?)</option>");
foreach (Match m in mc)
{
String id = m.Groups[1].Value;
String name = m.Groups[2].Value;
if (id != "0")
{
CategoryTop c = new CategoryTop();
c.Name = name;
c.Id = id;
Children.Add(c);
ml.Add(c);
}
}
Unprocessed = false;
return ml;
}
示例3: GetNestedNamespaces
public virtual MemberList GetNestedNamespaces(Identifier name, Scope scope) {
MemberList fullList = this.GetNestedNamespacesAndTypes(name, scope);
MemberList result = new MemberList();
for (int i = 0, n = fullList == null ? 0 : fullList.Count; i < n; i++){
Namespace ns = fullList[i] as Namespace;
if (ns == null) continue;
result.Add(ns);
}
return result;
}
示例4: Process
public override MemberList Process(WebClient client)
{
MemberList ml = new MemberList();
String content = client.DownloadString(GetUrl());
MatchCollection mc = Regex.Matches(content,
"<a href=\"http://baki\\.info/subcat/(\\d+)\" class=\"sc_listone\">.*?<span class=\"csc_sub_name\"><div class=\"title_inner\">(.+?)</div>", RegexOptions.Singleline);
foreach (Match m in mc)
{
CategorySub c = new CategorySub();
c.Id = m.Groups[1].Value;
c.Name = m.Groups[2].Value;
Children.Add(c);
ml.Add(c);
}
Unprocessed = false;
return ml;
}
示例5: VisitMemberList
public virtual Differences VisitMemberList(MemberList list1, MemberList list2,
out MemberList changes, out MemberList deletions, out MemberList insertions){
changes = list1 == null ? null : list1.Clone();
deletions = list1 == null ? null : list1.Clone();
insertions = list1 == null ? new MemberList() : list1.Clone();
//^ assert insertions != null;
Differences differences = new Differences();
//Compare definitions that have matching key attributes
TrivialHashtable matchingPosFor = new TrivialHashtable();
TrivialHashtable matchedNodes = new TrivialHashtable();
for (int j = 0, n = list2 == null ? 0 : list2.Count; j < n; j++){
//^ assert list2 != null;
Member nd2 = list2[j];
if (nd2 == null || nd2.Name == null) continue;
string fullName = nd2.FullName;
if (fullName == null) continue;
matchingPosFor[Identifier.For(fullName).UniqueIdKey] = j;
insertions.Add(null);
}
for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
//^ assert list1 != null && changes != null && deletions != null;
Member nd1 = list1[i];
if (nd1 == null || nd1.Name == null) continue;
string fullName = nd1.FullName;
if (fullName == null) continue;
object pos = matchingPosFor[Identifier.For(fullName).UniqueIdKey];
if (!(pos is int)) continue;
//^ assert pos != null;
//^ assume list2 != null; //since there was entry int matchingPosFor
int j = (int)pos;
Member nd2 = list2[j];
//^ assume nd2 != null;
//nd1 and nd2 have the same key attributes and are therefore treated as the same entity
matchedNodes[nd1.UniqueKey] = nd1;
matchedNodes[nd2.UniqueKey] = nd2;
//nd1 and nd2 may still be different, though, so find out how different
Differences diff = this.VisitMember(nd1, nd2);
if (diff == null){Debug.Assert(false); continue;}
if (diff.NumberOfDifferences != 0){
changes[i] = diff.Changes as Member;
deletions[i] = diff.Deletions as Member;
insertions[i] = diff.Insertions as Member;
insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
Debug.Assert(diff.Changes == changes[i] && diff.Deletions == deletions[i] && diff.Insertions == insertions[i]);
differences.NumberOfDifferences += diff.NumberOfDifferences;
differences.NumberOfSimilarities += diff.NumberOfSimilarities;
if ((nd1.DeclaringType != null && nd1.DeclaringType.DeclaringModule == this.OriginalModule) ||
(nd1 is TypeNode && ((TypeNode)nd1).DeclaringModule == this.OriginalModule)){
if (this.MembersThatHaveChanged == null) this.MembersThatHaveChanged = new MemberList();
this.MembersThatHaveChanged.Add(nd1);
}
continue;
}
changes[i] = null;
deletions[i] = null;
insertions[i] = null;
insertions[n+j] = nd1; //Records the position of nd2 in list2 in case the change involved a permutation
}
//Find deletions
for (int i = 0, n = list1 == null ? 0 : list1.Count; i < n; i++){
//^ assert list1 != null && changes != null && deletions != null;
Member nd1 = list1[i];
if (nd1 == null) continue;
if (matchedNodes[nd1.UniqueKey] != null) continue;
changes[i] = null;
deletions[i] = nd1;
insertions[i] = null;
differences.NumberOfDifferences += 1;
if ((nd1.DeclaringType != null && nd1.DeclaringType.DeclaringModule == this.OriginalModule) ||
(nd1 is TypeNode && ((TypeNode)nd1).DeclaringModule == this.OriginalModule)){
if (this.MembersThatHaveChanged == null) this.MembersThatHaveChanged = new MemberList();
this.MembersThatHaveChanged.Add(nd1);
}
}
//Find insertions
for (int j = 0, n = list1 == null ? 0 : list1.Count, m = list2 == null ? 0 : list2.Count; j < m; j++){
//^ assert list2 != null;
Member nd2 = list2[j];
if (nd2 == null) continue;
if (matchedNodes[nd2.UniqueKey] != null) continue;
insertions[n+j] = nd2; //Records nd2 as an insertion into list1, along with its position in list2
differences.NumberOfDifferences += 1; //REVIEW: put the size of the tree here?
}
if (differences.NumberOfDifferences == 0){
changes = null;
deletions = null;
insertions = null;
}
return differences;
}
示例6: ParseMethodParameters
/// <summary>
/// Returns parameters string as member list
/// </summary>
/// <param name="parameters">Method parameters</param>
/// <returns>Member list</returns>
static private MemberList ParseMethodParameters(string parameters)
{
MemberList list = new MemberList();
if (parameters == null)
return list;
int p = parameters.IndexOf('(');
if (p >= 0)
parameters = parameters.Substring(p + 1, parameters.IndexOf(')') - p - 1);
parameters = parameters.Trim();
if (parameters.Length == 0)
return list;
string[] sparam = parameters.Split(',');
string[] parType;
MemberModel param;
char[] toClean = new char[] { ' ', '\t', '\n', '\r', '*', '?' };
foreach (string pt in sparam)
{
parType = pt.Split(':');
param = new MemberModel();
param.Name = parType[0].Trim(toClean);
if (param.Name.Length == 0)
continue;
if (parType.Length == 2) param.Type = parType[1].Trim();
else param.Type = ASContext.Context.Features.objectKey;
param.Flags = FlagType.Variable | FlagType.Dynamic;
list.Add(param);
}
return list;
}
示例7: ResolveImports
/// <summary>
/// Return imported classes list (not null)
/// </summary>
/// <param name="package">Package to explore</param>
/// <param name="inFile">Current file</param>
public override MemberList ResolveImports(FileModel inFile)
{
if (inFile == cFile && completionCache.Imports != null)
return completionCache.Imports;
MemberList imports = new MemberList();
if (inFile == null) return imports;
bool filterImports = (inFile == cFile) && inFile.Classes.Count > 1;
int lineMin = (filterImports && inPrivateSection) ? inFile.PrivateSectionIndex : 0;
int lineMax = (filterImports && inPrivateSection) ? int.MaxValue : inFile.PrivateSectionIndex;
foreach (MemberModel item in inFile.Imports)
{
if (filterImports && (item.LineFrom < lineMin || item.LineFrom > lineMax)) continue;
if (item.Name != "*")
{
if (settings.LazyClasspathExploration) imports.Add(item);
else
{
ClassModel type = ResolveType(item.Type, null);
if (!type.IsVoid()) imports.Add(type);
else
{
// package-level declarations
int p = item.Type.LastIndexOf('.');
if (p < 0) continue;
string package = item.Type.Substring(0, p);
string token = item.Type.Substring(p+1);
FileModel pack = ResolvePackage(package, false);
if (pack == null) continue;
MemberModel member = pack.Members.Search(token, 0, 0);
if (member != null) imports.Add(member);
}
}
}
else
{
// classes matching wildcard
FileModel matches = ResolvePackage(item.Type.Substring(0, item.Type.Length - 2), false);
if (matches != null)
{
foreach (MemberModel import in matches.Imports)
imports.Add(import);
foreach (MemberModel member in matches.Members)
imports.Add(member);
}
}
}
if (inFile == cFile) completionCache.Imports = imports;
return imports;
}
示例8: 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;
}
示例9: PopulateClassesEntries
private void PopulateClassesEntries(string package, string path, MemberList memberList)
{
string[] fileEntries = null;
try
{
fileEntries = System.IO.Directory.GetFiles(path, "*" + settings.DefaultExtension);
}
catch { }
if (fileEntries == null) return;
string mname;
string type;
FlagType flag = FlagType.Class | ((package == null) ? FlagType.Intrinsic : 0);
foreach (string entry in fileEntries)
{
mname = GetLastStringToken(entry, dirSeparator);
mname = mname.Substring(0, mname.LastIndexOf("."));
if (mname.Length > 0 && memberList.Search(mname, 0, 0) == null && re_token.IsMatch(mname))
{
type = mname;
if (package.Length > 0) type = package + "." + mname;
memberList.Add(new MemberModel(mname, type, flag, Visibility.Public));
}
}
}
示例10: GetVisibleExternalElements
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 || !typesOnly)
{
MemberList elements = 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));
bool qualify = Settings.CompletionShowQualifiedTypes && settings.GenerateImports;
// other classes in same package
if (features.hasPackages && cFile.Package != "")
{
int pLen = cFile.Package.Length;
FileModel packageElements = ResolvePackage(cFile.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;
elements.Add(member);
}
}
}
// 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 (!typesOnly && aClass.IsEnum())
elements.Add(aClass.Members);
}
}
// imports
MemberList imports = ResolveImports(CurrentModel);
elements.Add(imports);
if (!typesOnly)
foreach (MemberModel import in imports)
{
if (import is ClassModel)
{
ClassModel aClass = import as ClassModel;
if (aClass.IsEnum()) elements.Add(aClass.Members);
}
}
elements.Sort();
// in cache
if (typesOnly)
{
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(elements);
}
else
visibleElements.Merge(completionCache.Elements);
return visibleElements;
}
示例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);
}
}
示例12: GetPrivateClasses
protected MemberList GetPrivateClasses()
{
MemberList list = new MemberList();
// private classes
foreach(ClassModel model in cFile.Classes)
if (model.Access == Visibility.Private)
{
MemberModel item = model.ToMemberModel();
item.Type = item.Name;
item.Access = Visibility.Private;
list.Add(item);
}
// 'Class' members
if (cClass != null)
foreach (MemberModel member in cClass.Members)
if (member.Type == "Class") list.Add(member);
return list;
}
示例13: GetDataMembers
protected virtual void GetDataMembers(TypeNode type, MemberList list){
if (type == null) return;
if (type.BaseType != SystemTypes.Object) this.GetDataMembers(type.BaseType, list);
MemberList tMembers = type.Members;
for (int i = 0, n = tMembers == null ? 0 : tMembers.Count; i < n; i++ ){
Member m = tMembers[i];
if ((m is Field || m is Property) && m.IsPublic) list.Add(m);
}
}
示例14: ResolveImports
/// <summary>
/// Return imported classes list (not null)
/// </summary>
/// <param name="package">Package to explore</param>
/// <param name="inFile">Current file</param>
public override MemberList ResolveImports(FileModel inFile)
{
bool filterImports = (inFile == cFile) && inFile.Classes.Count > 1;
int lineMin = (filterImports && inPrivateSection) ? inFile.PrivateSectionIndex : 0;
int lineMax = (filterImports && inPrivateSection) ? int.MaxValue : inFile.PrivateSectionIndex;
MemberList imports = new MemberList();
foreach (MemberModel item in inFile.Imports)
{
if (filterImports && (item.LineFrom < lineMin || item.LineFrom > lineMax)) continue;
ClassModel type = ResolveType(item.Type, null);
if (!type.IsVoid()) imports.Add(type);
else
{
// package-level declarations
FileModel matches = ResolvePackage(item.Type, false);
if (matches != null)
{
foreach (MemberModel import in matches.Imports)
imports.Add(import);
foreach (MemberModel member in matches.Members)
imports.Add(member);
}
}
}
return imports;
}
示例15: 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;
}