Inheritance: Zyan.InterLinq.Types.InterLinqMemberInfo
Beispiel #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;
			}
			InterLinqFieldInfo other = (InterLinqFieldInfo)obj;
			return FieldType.Equals(other.FieldType);
		}
Beispiel #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;
                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;

                case MemberTypes.NestedType:
                    createdMemberInfo = 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);
            }
        }