示例#1
0
 public void merge(InterfaceScope other)
 {
     if (ReferenceEquals(this, other))
         return;
     addInterfaces(other.interfaces.Keys);
     foreach (var cls in other.classes.Keys)
         addClass(cls);
 }
示例#2
0
        IList<InterfaceScope> createInterfaceScopes()
        {
            var interfaceScopes = new Dictionary<TypeDef, InterfaceScope>();
            foreach (var scopeInfo in getInterfaceScopeInfo(baseTypes)) {
                InterfaceScope interfaceScope = null;
                foreach (var iface in scopeInfo.interfaces) {
                    if (interfaceScopes.TryGetValue(iface, out interfaceScope))
                        break;
                }
                List<InterfaceScope> mergeScopes = null;
                if (interfaceScope == null)
                    interfaceScope = new InterfaceScope();
                else {
                    // Find all interfaces in scopeInfo.interfaces that are in another
                    // InterfaceScope, and merge them with interfaceScope.
                    foreach (var iface in scopeInfo.interfaces) {
                        InterfaceScope scope;
                        if (!interfaceScopes.TryGetValue(iface, out scope))
                            continue;	// not in any scope yet
                        if (ReferenceEquals(scope, interfaceScope))
                            continue;	// same scope

                        if (mergeScopes == null)
                            mergeScopes = new List<InterfaceScope>();
                        mergeScopes.Add(scope);
                    }
                }

                foreach (var iface in scopeInfo.interfaces)
                    interfaceScopes[iface] = interfaceScope;
                if (mergeScopes != null) {
                    foreach (var scope in mergeScopes) {
                        interfaceScope.merge(scope);
                        foreach (var iface in scope.Interfaces)
                            interfaceScopes[iface] = interfaceScope;
                    }
                }
                interfaceScope.addInterfaces(scopeInfo.interfaces);
                interfaceScope.addClass(scopeInfo.theClass);
            }

            return new List<InterfaceScope>(Utils.unique(interfaceScopes.Values));
        }