Ejemplo n.º 1
0
        private void CreateExplicitInterfaceImplementations(TypeDefinitionMember member)
        {
            List <ITypeDefinitionMember> interfaceMembers = Util.FindRelatedInterfaceMembers(member);

            foreach (ITypeDefinitionMember interfaceMember in interfaceMembers)
            {
                IMethodDefinition methodDef = interfaceMember.ResolvedTypeDefinitionMember as IMethodDefinition;
                if (methodDef != null)
                {
                    List <IMethodImplementation> methodImpls = null;
                    methodImpls = GetExplicitImplementationOverrides(member, methodImpls);

                    if (methodImpls != null)
                    {
                        // Make sure implementedmethod is in the closure
                        TrimType trimType = (TrimType)_currentTrimAssembly.GetTypeElement(Util.GetTypeName(Util.ContainingTypeDefinition(interfaceMember)));
                        if (trimType != null)
                        {
                            TrimMember trimMember = trimType.GetMemberElementFromMember(interfaceMember);
                            if (trimMember != null)
                            {
                                MethodImplementation methodImpl = new MethodImplementation();
                                methodImpl.ImplementedMethod  = interfaceMember.ResolvedTypeDefinitionMember as IMethodReference;
                                methodImpl.ImplementingMethod = member as IMethodReference;

                                methodImpl.ContainingType = member.ContainingTypeDefinition;
                                methodImpls.Add(Rewrite(methodImpl));
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override MemberElement CreateMemberElement(TypeElement type, string memberName, string returnType, MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus)
        {
            TrimType typeInfo = (TrimType)type;

            TrimMember id = new TrimMember(typeInfo, memberName, returnType, /*paramListString, */ memberType, includeStatus, visibilityOverride, securityTransparencyStatus);

            typeInfo.Members.Add(id.Key, id);
            return(id);
        }
Ejemplo n.º 3
0
        public override List <IMethodImplementation> Rewrite(List <IMethodImplementation> methodImplementations)
        {
            TrimType currentType = CurrentTrimElement as TrimType;

            List <IMethodImplementation> newList = new List <IMethodImplementation>();

            if (methodImplementations == null)
            {
                return(newList);
            }
            foreach (IMethodImplementation methodImpl in methodImplementations)
            {
                IMethodReference implementingMethod        = methodImpl.ImplementingMethod;
                IMethodReference implementedMethod         = methodImpl.ImplementedMethod;
                TrimMember       implementingMemberElement = currentType.GetMemberElementFromMember(implementingMethod);
                TrimMember       implementedMemberElement  = null;

                if (implementingMemberElement != null)
                {
                    ITypeReference implementedType        = Util.CanonicalizeTypeReference(implementedMethod.ContainingType);
                    TrimType       implementedTypeElement = (TrimType)_currentTrimAssembly.GetTypeElement(Util.GetTypeName(implementedType));
                    if (implementedTypeElement != null)
                    {
                        implementedMemberElement = implementedTypeElement.GetMemberElementFromMember(Util.CanonicalizeMethodReference(implementedMethod));
                    }
                }
                else
                {
                }

                if (implementingMemberElement != null && (implementedMemberElement != null ||
                                                          !_includeSet.Assemblies.ContainsKey(Util.GetDefiningAssembly(implementedMethod.ContainingType).Name.Value)))
                {
                    IMethodImplementation newMethodImpl = Rewrite(methodImpl);
                    newList.Add(newMethodImpl);
                }
                //else
                //{ Console.WriteLine("Removing {0}'s impl of {1}", implementingMethod.ToString(), implementedMethod.ToString()); }
            }

            return(newList);
        }
Ejemplo n.º 4
0
 public void LoadFrom(ModelElement otherModel)
 {
     foreach (AssemblyElement assembly in otherModel.Assemblies.Values)
     {
         TrimAssembly newAssembly = new TrimAssembly(assembly.Key, assembly.IncludeStatus);
         _assemblies.Add(newAssembly.Name, newAssembly);
         foreach (KeyValuePair<String, TypeForwarderElement> typeForwarder in assembly.TypeForwarders)
         {
             TrimTypeForwarder newTypeForwarder = new TrimTypeForwarder(typeForwarder.Value.AssemblyName, typeForwarder.Value.TypeName, typeForwarder.Value.IncludeStatus);
             newAssembly.TypeForwarders.Add(newTypeForwarder.Key, newTypeForwarder);
         }
         foreach (KeyValuePair<String, TypeElement> type in assembly.Types)
         {
             TrimType newType = new TrimType(type.Value.Key, type.Value.IncludeStatus, type.Value.VisibilityOverride, type.Value.SecurityTransparencyStatus);
             newAssembly.Types.Add(newType.Key, newType);
             foreach (KeyValuePair<String, MemberElement> member in type.Value.Members)
             {
                 TrimMember newMember = new TrimMember(newType, member.Value.Name, member.Value.ReturnType, member.Value.MemberType, member.Value.IncludeStatus, member.Value.VisibilityOverride, member.Value.SecurityTransparencyStatus);
                 newType.Members.Add(newMember.Key, newMember);
             }
         }
     }
 }
Ejemplo n.º 5
0
 public void LoadFrom(ModelElement otherModel)
 {
     foreach (AssemblyElement assembly in otherModel.Assemblies.Values)
     {
         TrimAssembly newAssembly = new TrimAssembly(assembly.Key, assembly.IncludeStatus);
         _assemblies.Add(newAssembly.Name, newAssembly);
         foreach (KeyValuePair <String, TypeForwarderElement> typeForwarder in assembly.TypeForwarders)
         {
             TrimTypeForwarder newTypeForwarder = new TrimTypeForwarder(typeForwarder.Value.AssemblyName, typeForwarder.Value.TypeName, typeForwarder.Value.IncludeStatus);
             newAssembly.TypeForwarders.Add(newTypeForwarder.Key, newTypeForwarder);
         }
         foreach (KeyValuePair <String, TypeElement> type in assembly.Types)
         {
             TrimType newType = new TrimType(type.Value.Key, type.Value.IncludeStatus, type.Value.VisibilityOverride, type.Value.SecurityTransparencyStatus);
             newAssembly.Types.Add(newType.Key, newType);
             foreach (KeyValuePair <String, MemberElement> member in type.Value.Members)
             {
                 TrimMember newMember = new TrimMember(newType, member.Value.Name, member.Value.ReturnType, member.Value.MemberType, member.Value.IncludeStatus, member.Value.VisibilityOverride, member.Value.SecurityTransparencyStatus);
                 newType.Members.Add(newMember.Key, newMember);
             }
         }
     }
 }
Ejemplo n.º 6
0
        public override MemberElement CreateMemberElement(TypeElement type, string memberName, string returnType, MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus)
        {
            TrimType typeInfo = (TrimType)type;

            TrimMember id = new TrimMember(typeInfo, memberName, returnType, /*paramListString, */memberType, includeStatus, visibilityOverride, securityTransparencyStatus);
            typeInfo.Members.Add(id.Key, id);
            return id;
        }
Ejemplo n.º 7
0
 public void AddMember(TrimMember member)
 {
     _typeMembers.Add(member.Key, member);
 }
Ejemplo n.º 8
0
 public void AddMember(TrimMember member)
 {
     _typeMembers.Add(member.Key, member);
 }