Пример #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));
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        public override List <IPropertyDefinition> Rewrite(List <IPropertyDefinition> propertyDefinitions)
        {
            TrimType currentType = CurrentTrimElement as TrimType;

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

            if (propertyDefinitions == null)
            {
                return(newList);
            }
            foreach (IPropertyDefinition property in propertyDefinitions)
            {
                MemberElement currentElement = currentType.GetMemberElementFromMember(property);

                if (currentElement != null)
                {
                    _trimElements.Push(currentElement);

                    IPropertyDefinition newProperty = Rewrite(property);
                    newList.Add(newProperty);

                    _trimElements.Pop();
                }
            }

            return(newList);
        }
Пример #3
0
        public override List <IEventDefinition> Rewrite(List <IEventDefinition> eventDefinitions)
        {
            TrimType currentType = CurrentTrimElement as TrimType;

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

            if (eventDefinitions == null)
            {
                return(newList);
            }
            foreach (IEventDefinition evnt in eventDefinitions)
            {
                MemberElement currentElement = currentType.GetMemberElementFromMember(evnt);

                if (currentElement != null)
                {
                    _trimElements.Push(currentElement);

                    IEventDefinition newEvnt = Rewrite(evnt);
                    newList.Add(newEvnt);

                    _trimElements.Pop();
                }
            }

            return(newList);
        }
Пример #4
0
        public override List <IMethodDefinition> Rewrite(List <IMethodDefinition> methodDefinitions)
        {
            TrimType currentType = CurrentTrimElement as TrimType;

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

            if (methodDefinitions == null)
            {
                return(newList);
            }
            foreach (IMethodDefinition method in methodDefinitions)
            {
                MemberElement currentElement = currentType.GetMemberElementFromMember(method);

                if (currentElement != null)
                {
                    _trimElements.Push(currentElement);

                    IMethodDefinition newMethod = Rewrite(method);
                    newList.Add(newMethod);

                    _trimElements.Pop();
                }
            }

            return(newList);
        }
Пример #5
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);
        }
Пример #6
0
        public override TypeElement CreateTypeElement(AssemblyElement assembly, string typeName, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus)
        {
            TrimAssembly trimAssembly = (TrimAssembly)assembly;

            TrimType typeIncludeInfo = new TrimType(typeName, includeStatus, visibilityOverride, securityTransparencyStatus);

            trimAssembly.Types.Add(typeIncludeInfo.Key, typeIncludeInfo);
            return(typeIncludeInfo);
        }
Пример #7
0
 public TrimMember(TrimType declaringType, string memberName, string returnType, /*string paramListString, */ MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus)
 {
     _declaringType = declaringType;
     _memberName    = memberName;
     _returnType    = returnType;
     _memberType    = memberType;
     _includeStatus = includeStatus;
     _securityTransparencyStatus = securityTransparencyStatus;
     //_paramListString = paramListString;
     //if (null == paramListString)
     //    _paramQualifiedTypeNames = new List<string>();
     //else
     //    _paramQualifiedTypeNames = SplitParameterList(paramListString);
     _visibilityOverride = visibilityOverride;
 }
Пример #8
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);
        }
Пример #9
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);
             }
         }
     }
 }
Пример #10
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);
             }
         }
     }
 }
Пример #11
0
        public override TypeElement CreateTypeElement(AssemblyElement assembly, string typeName, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus)
        {
            TrimAssembly trimAssembly = (TrimAssembly)assembly;

            TrimType typeIncludeInfo = new TrimType(typeName, includeStatus, visibilityOverride, securityTransparencyStatus);
            trimAssembly.Types.Add(typeIncludeInfo.Key, typeIncludeInfo);
            return typeIncludeInfo;
        }
Пример #12
0
 public SpecialTrimMember(TrimType trimType, string memberName, string returnType, MemberTypes memberType)
     : base(trimType, memberName, returnType, memberType, IncludeStatus.ImplRoot, VisibilityOverride.None, SecurityTransparencyStatus.Transparent)
 {
 }
Пример #13
0
 public TrimMember(TrimType declaringType, string memberName, string returnType, /*string paramListString, */MemberTypes memberType, IncludeStatus includeStatus, VisibilityOverride visibilityOverride, SecurityTransparencyStatus securityTransparencyStatus)
 {
     _declaringType = declaringType;
     _memberName = memberName;
     _returnType = returnType;
     _memberType = memberType;
     _includeStatus = includeStatus;
     _securityTransparencyStatus = securityTransparencyStatus;
     //_paramListString = paramListString;
     //if (null == paramListString)
     //    _paramQualifiedTypeNames = new List<string>();
     //else
     //    _paramQualifiedTypeNames = SplitParameterList(paramListString);
     _visibilityOverride = visibilityOverride;
 }
Пример #14
0
 public SpecialTrimMember(TrimType trimType, string memberName, string returnType, MemberTypes memberType)
     : base(trimType, memberName, returnType, memberType, IncludeStatus.ImplRoot, VisibilityOverride.None, SecurityTransparencyStatus.Transparent)
 {
 }