本文整理汇总了C#中GetMemberOptions.Intersect方法的典型用法代码示例。如果您正苦于以下问题:C# GetMemberOptions.Intersect方法的具体用法?C# GetMemberOptions.Intersect怎么用?C# GetMemberOptions.Intersect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GetMemberOptions
的用法示例。
在下文中一共展示了GetMemberOptions.Intersect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMemberResults
internal IEnumerable<MemberResult> GetMemberResults(
IEnumerable<AnalysisValue> vars,
InterpreterScope scope,
GetMemberOptions options
)
{
IList<AnalysisValue> namespaces = new List<AnalysisValue>();
foreach (var ns in vars) {
if (ns != null) {
namespaces.Add(ns);
}
}
if (namespaces.Count == 1) {
// optimize for the common case of only a single namespace
var newMembers = namespaces[0].GetAllMembers(GlobalScope.InterpreterContext, options);
if (newMembers == null || newMembers.Count == 0) {
return new MemberResult[0];
}
return SingleMemberResult(GetPrivatePrefix(scope), options, newMembers);
}
Dictionary<string, IEnumerable<AnalysisValue>> memberDict = null;
Dictionary<string, IEnumerable<AnalysisValue>> ownerDict = null;
HashSet<string> memberSet = null;
int namespacesCount = namespaces.Count;
foreach (AnalysisValue ns in namespaces) {
if (ProjectState._noneInst == ns) {
namespacesCount -= 1;
continue;
}
var newMembers = ns.GetAllMembers(GlobalScope.InterpreterContext, options);
// IntersectMembers(members, memberSet, memberDict);
if (newMembers == null || newMembers.Count == 0) {
continue;
}
if (memberSet == null) {
// first namespace, add everything
memberSet = new HashSet<string>(newMembers.Keys);
memberDict = new Dictionary<string, IEnumerable<AnalysisValue>>();
ownerDict = new Dictionary<string, IEnumerable<AnalysisValue>>();
foreach (var kvp in newMembers) {
var tmp = new List<AnalysisValue>(kvp.Value);
memberDict[kvp.Key] = tmp;
ownerDict[kvp.Key] = new List<AnalysisValue> { ns };
}
} else {
// 2nd or nth namespace, union or intersect
HashSet<string> toRemove;
IEnumerable<string> adding;
if (options.Intersect()) {
adding = new HashSet<string>(newMembers.Keys);
// Find the things only in memberSet that we need to remove from memberDict
// toRemove = (memberSet ^ adding) & memberSet
toRemove = new HashSet<string>(memberSet);
toRemove.SymmetricExceptWith(adding);
toRemove.IntersectWith(memberSet);
// intersect memberSet with what we're adding
memberSet.IntersectWith(adding);
// we're only adding things they both had
adding = memberSet;
} else {
// we're adding all of newMembers keys
adding = newMembers.Keys;
toRemove = null;
}
// update memberDict
foreach (var name in adding) {
IEnumerable<AnalysisValue> values;
List<AnalysisValue> valueList;
if (!memberDict.TryGetValue(name, out values)) {
memberDict[name] = values = new List<AnalysisValue>();
}
if ((valueList = values as List<AnalysisValue>) == null) {
memberDict[name] = valueList = new List<AnalysisValue>(values);
}
valueList.AddRange(newMembers[name]);
if (!ownerDict.TryGetValue(name, out values)) {
ownerDict[name] = values = new List<AnalysisValue>();
}
if ((valueList = values as List<AnalysisValue>) == null) {
ownerDict[name] = valueList = new List<AnalysisValue>(values);
}
valueList.Add(ns);
}
if (toRemove != null) {
foreach (var name in toRemove) {
memberDict.Remove(name);
ownerDict.Remove(name);
}
//.........这里部分代码省略.........