예제 #1
0
        private static Member ReplaceExtensionMethods(Member member, MemberIdMap map)
        {
            if (member.Kind != MemberKinds.Method)
            {
                return(member);
            }

            var method = (MethodBase)map.GetOrDefault(member.ToString());

            if (method == null)
            {
                return(member);
            }

            if (method.GetCustomAttributes(true).Any(attr => attr.GetType().FullName == "System.Runtime.CompilerServices.ExtensionAttribute"))
            {
                var extendedTypeId = map.GetOrDefault(method.GetParameters()[0].ParameterType);
                if (!string.IsNullOrEmpty(extendedTypeId))
                {
                    return(new ExtensionMethod(member.ToString(), extendedTypeId, member.Elements));
                }
            }

            return(member);
        }
예제 #2
0
        private static Member ReplaceTypes(Member member, MemberIdMap map)
        {
            if (member.Kind != MemberKinds.Type)
            {
                return(member);
            }

            var type = (Type)map.GetOrDefault(member.ToString());

            if (type == null)
            {
                return(member);
            }

            var nestingTypeId = "";

            if (type.DeclaringType != null &&
                !string.IsNullOrEmpty((nestingTypeId = map.GetOrDefault(type.DeclaringType))))
            {
                return(new NestedType(member.ToString(), nestingTypeId, member.Elements));
            }

            if (type.IsInterface)
            {
                return(new Interface(member.ToString(), member.Elements));
            }
            if (type.IsClass)
            {
                return(new Class(member.ToString(), member.Elements));
            }
            if (type.IsEnum)
            {
                return(new Enum(member.ToString(), member.Elements));
            }
            if (type.IsValueType)
            {
                return(new Struct(member.ToString(), member.Elements));
            }

            return(member);
        }
예제 #3
0
        private static Member SetInfo(Member member, MemberIdMap map)
        {
            member.Info = map.GetOrDefault(member.ToString());

            return(member);
        }
예제 #4
0
        private static Member SetInfo(Member member, MemberIdMap map)
        {
            member.Info = map.GetOrDefault(member.ToString());

            return member;
        }
예제 #5
0
        private static Member ReplaceTypes(Member member, MemberIdMap map)
        {
            if (member.Kind != MemberKinds.Type)
                return member;

            var type = (Type)map.GetOrDefault(member.ToString());
            if (type == null)
                return member;

            var nestingTypeId = "";
            if (type.DeclaringType != null &&
                !string.IsNullOrEmpty((nestingTypeId = map.GetOrDefault(type.DeclaringType))))
                return new NestedType(member.ToString(), nestingTypeId, member.Elements);

            if (type.IsInterface)
                return new Interface(member.ToString(), member.Elements);
            if (type.IsClass)
                return new Class(member.ToString(), member.Elements);
            if (type.IsEnum)
                return new Enum(member.ToString(), member.Elements);
            if (type.IsValueType)
                return new Struct(member.ToString(), member.Elements);

            return member;
        }
예제 #6
0
        private static Member ReplaceExtensionMethods(Member member, MemberIdMap map)
        {
            if (member.Kind != MemberKinds.Method)
                return member;

            var method = (MethodBase)map.GetOrDefault(member.ToString());
            if (method == null)
                return member;

            if (method.GetCustomAttributes(true).Any(attr => attr.GetType().FullName == "System.Runtime.CompilerServices.ExtensionAttribute"))
            {
                var extendedTypeId = map.GetOrDefault(method.GetParameters()[0].ParameterType);
                if (!string.IsNullOrEmpty(extendedTypeId))
                    return new ExtensionMethod(member.ToString(), extendedTypeId, member.Elements);
            }

            return member;
        }