Ejemplo n.º 1
0
        /// <summary>
        /// Compares <paramref name="obj"/> to this instance.
        /// </summary>
        /// <param name="obj"><see langword="object"/> to compare.</param>
        /// <returns>True if equal, false if not.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            if (!base.Equals(obj))
            {
                return(false);
            }
            InterLinqMethodInfo other = (InterLinqMethodInfo)obj;

            if (GenericArguments.Count != other.GenericArguments.Count)
            {
                return(false);
            }

            for (int i = 0; i < GenericArguments.Count; i++)
            {
                if (!GenericArguments[i].Equals(other.GenericArguments[i]))
                {
                    return(false);
                }
            }

            return(ReturnType.Equals(other.ReturnType));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the <see cref="InterLinqMemberInfo"/> for a C# <see cref="MemberInfo"/>.
        /// </summary>
        /// <param name="memberInfo"><see cref="MemberInfo"/>.</param>
        /// <returns>Returns the <see cref="InterLinqMemberInfo"/> for a C# <see cref="MemberInfo"/>.</returns>
        public InterLinqMemberInfo GetInterLinqMemberInfo(MemberInfo memberInfo)
        {
            lock (this)
            {
                if (memberInfo == null)
                {
                    return null;
                }
                if (typeMap.ContainsKey(memberInfo))
                {
                    return typeMap[memberInfo];
                }

                InterLinqMemberInfo createdMemberInfo;
#if !NETFX_CORE
                switch (memberInfo.MemberType)
#else
                switch (memberInfo.GetMemberType())
#endif
                {
                    case MemberTypes.Constructor:
                        createdMemberInfo = new InterLinqConstructorInfo();
                        break;
                    case MemberTypes.Field:
                        createdMemberInfo = new InterLinqFieldInfo();
                        break;
                    case MemberTypes.Method:
                        createdMemberInfo = new InterLinqMethodInfo();
                        break;
                    case MemberTypes.Property:
                        createdMemberInfo = new InterLinqPropertyInfo();
                        break;
                    case MemberTypes.NestedType:
                    case MemberTypes.TypeInfo:
#if !NETFX_CORE
                        createdMemberInfo = ((Type)memberInfo).IsAnonymous() ? new AnonymousMetaType() : new InterLinqType();
#else
                        createdMemberInfo = ((TypeInfo)memberInfo).AsType().IsAnonymous() ? new AnonymousMetaType() : new InterLinqType();
#endif
                        break;
                    default:
                        throw new Exception(string.Format("MemberInfo \"{0}\" could not be handled.", memberInfo));
                }
                typeMap.Add(memberInfo, createdMemberInfo);
                createdMemberInfo.Initialize(memberInfo);
                return createdMemberInfo;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the <see cref="InterLinqMemberInfo"/> for a C# <see cref="MemberInfo"/>.
        /// </summary>
        /// <param name="memberInfo"><see cref="MemberInfo"/>.</param>
        /// <returns>Returns the <see cref="InterLinqMemberInfo"/> for a C# <see cref="MemberInfo"/>.</returns>
        public InterLinqMemberInfo GetInterLinqMemberInfo(MemberInfo memberInfo)
        {
            lock (this)
            {
                if (memberInfo == null)
                {
                    return(null);
                }
                if (_typeMap.ContainsKey(memberInfo))
                {
                    return(_typeMap[memberInfo]);
                }

                InterLinqMemberInfo createdMemberInfo;
                switch (memberInfo.MemberType)
                {
                case MemberTypes.Constructor:
                    createdMemberInfo = new InterLinqConstructorInfo();
                    break;

                case MemberTypes.Field:
                    createdMemberInfo = new InterLinqFieldInfo();
                    break;

                case MemberTypes.Method:
                    createdMemberInfo = new InterLinqMethodInfo();
                    break;

                case MemberTypes.Property:
                    createdMemberInfo = new InterLinqPropertyInfo();
                    break;

                case MemberTypes.TypeInfo:
                    createdMemberInfo = ((Type)memberInfo).IsAnonymous() ? new AnonymousMetaType() : new InterLinqType();
                    break;

                default:
                    throw new Exception(string.Format("MemberInfo \"{0}\" could not be handled.", memberInfo));
                }
                _typeMap.Add(memberInfo, createdMemberInfo);
                createdMemberInfo.Initialize(memberInfo);
                return(createdMemberInfo);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Compares <paramref name="obj"/> to this instance.
        /// </summary>
        /// <param name="obj"><see langword="object"/> to compare.</param>
        /// <returns>True if equal, false if not.</returns>
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            if (!base.Equals(obj))
            {
                return(false);
            }
            InterLinqMethodInfo other = (InterLinqMethodInfo)obj;

            if (GenericArguments.Count != other.GenericArguments.Count)
            {
                return(false);
            }

            return(!GenericArguments.Where((t, i) => !t.Equals(other.GenericArguments[i])).Any() && ReturnType.Equals(other.ReturnType));
        }
        private static string GetPropertyNoThrow(InterLinqMethodInfo method)
        {
            if (method != null)
            {
//TODO, Implement
                //InterLinqType declaringType = method.DeclaringType;
                //BindingFlags bindingAttr = BindingFlags.NonPublic | BindingFlags.Public;
                //bindingAttr |= method.IsStatic ? BindingFlags.Static : BindingFlags.Instance;
                //foreach( PropertyInfo info in declaringType.GetProperties( bindingAttr ) ) {
                //    if( info.CanRead && ( method == info.GetGetMethod( true ) ) ) {
                //        return info;
                //    }
                //    if( info.CanWrite && ( method == info.GetSetMethod( true ) ) ) {
                //        return info;
                //    }
                //}
            }
            return null;
        }