Ejemplo n.º 1
0
        /// <summary>
        /// Initializes this class.
        /// </summary>
        /// <param name="memberInfo">Represented <see cref="MemberInfo"/></param>
        /// <seealso cref="InterLinqMemberInfo.Initialize"/>
        public override void Initialize(MemberInfo memberInfo)
        {
            base.Initialize(memberInfo);
            PropertyInfo propertyInfo = memberInfo as PropertyInfo;

            PropertyType = InterLinqTypeSystem.Instance.GetInterLinqVersionOf <InterLinqType>(propertyInfo.PropertyType);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes this class.
        /// </summary>
        /// <param name="memberInfo">Represented <see cref="MemberInfo"/></param>
        /// <seealso cref="InterLinqMemberInfo.Initialize"/>
        public override void Initialize(MemberInfo memberInfo)
        {
            base.Initialize(memberInfo);
            FieldInfo fieldInfo = memberInfo as FieldInfo;

            FieldType = InterLinqTypeSystem.Instance.GetInterLinqVersionOf <InterLinqType>(fieldInfo.FieldType);
        }
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;

                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);
            }
        }
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);
            }
            InterLinqType other = (InterLinqType)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(MemberType == other.MemberType && representedType == other.representedType && Name == other.Name && IsGeneric == other.IsGeneric);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes this class.
 /// </summary>
 /// <param name="memberInfo">Represented <see cref="MemberInfo"/></param>
 /// <seealso cref="InterLinqMemberInfo.Initialize"/>
 public override void Initialize(MemberInfo memberInfo)
 {
     base.Initialize(memberInfo);
     MethodInfo methodInfo = memberInfo as MethodInfo;
     ReturnType = InterLinqTypeSystem.Instance.GetInterLinqVersionOf<InterLinqType>(methodInfo.ReturnType);
     IsStatic = methodInfo.IsStatic;
     if (methodInfo.IsGenericMethod)
     {
         foreach (Type genericArgument in methodInfo.GetGenericArguments())
         {
             GenericArguments.Add(InterLinqTypeSystem.Instance.GetInterLinqVersionOf<InterLinqType>(genericArgument));
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes this class.
 /// </summary>
 /// <param name="memberInfo">Represented <see cref="MemberInfo"/></param>
 public virtual void Initialize(MemberInfo memberInfo)
 {
     Name          = memberInfo.Name;
     DeclaringType = InterLinqTypeSystem.Instance.GetInterLinqVersionOf <InterLinqType>(memberInfo.DeclaringType);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes this class.
 /// </summary>
 /// <param name="memberInfo">Represented <see cref="MemberInfo"/></param>
 /// <seealso cref="InterLinqMemberInfo.Initialize"/>
 public override void Initialize(MemberInfo memberInfo)
 {
     base.Initialize(memberInfo);
     PropertyInfo propertyInfo = memberInfo as PropertyInfo;
     PropertyType = InterLinqTypeSystem.Instance.GetInterLinqVersionOf<InterLinqType>(propertyInfo.PropertyType);
 }