/// <summary>
        /// Returns the CLR <see cref="MemberInfo"/>.
        /// </summary>
        /// <returns>Returns the CLR <see cref="MemberInfo"/>.</returns>
        public override MemberInfo GetClrVersion()
        {
            InterLinqTypeSystem tsInstance = InterLinqTypeSystem.Instance;

            lock (tsInstance)
            {
                if (tsInstance.IsInterLinqMemberInfoRegistered(this))
                {
                    return(tsInstance.GetClrVersion <MethodInfo>(this));
                }

                Type       declaringType        = (Type)DeclaringType.GetClrVersion();
                Type[]     genericArgumentTypes = GenericArguments.Select(p => (Type)p.GetClrVersion()).ToArray();
                MethodInfo foundMethod          = null;
                foreach (MethodInfo method in declaringType.GetMethods().Where(m => m.Name == Name))
                {
                    MethodInfo currentMethod = method;
                    if (currentMethod.IsGenericMethod)
                    {
                        if (currentMethod.GetGenericArguments().Length == genericArgumentTypes.Length)
                        {
                            currentMethod = currentMethod.MakeGenericMethod(genericArgumentTypes);
                        }
                        else
                        {
                            continue;
                        }
                    }
                    ParameterInfo[] currentParameters = currentMethod.GetParameters();
                    if (ParameterTypes.Count == currentParameters.Length)
                    {
                        bool allArumentsFit = true;
                        for (int i = 0; i < ParameterTypes.Count && i < currentParameters.Length; i++)
                        {
                            Type currentArg       = (Type)ParameterTypes[i].GetClrVersion();
                            Type currentParamType = currentParameters[i].ParameterType;
                            if (!currentParamType.IsAssignableFrom(currentArg))
                            {
                                allArumentsFit = false;
                                break;
                            }
                        }
                        if (allArumentsFit)
                        {
                            foundMethod = currentMethod;
                        }
                    }
                }

                if (foundMethod == null)
                {
                    throw new Exception(string.Format("Method \"{0}.{1}\" not found.", declaringType, Name));
                }
                tsInstance.SetClrVersion(this, foundMethod);
                return(foundMethod);
            }
        }
예제 #2
0
        /// <summary>
        /// Returns the CLR <see cref="MemberInfo"/>.
        /// </summary>
        /// <returns>Returns the CLR <see cref="MemberInfo"/>.</returns>
        public override MemberInfo GetClrVersion()
        {
            InterLinqTypeSystem tsInstance = InterLinqTypeSystem.Instance;

            lock (tsInstance)
            {
                if (tsInstance.IsInterLinqMemberInfoRegistered(this))
                {
                    return(tsInstance.GetClrVersion <Type>(this));
                }
                Type createdType = CreateClrType();
                tsInstance.SetClrVersion(this, createdType);
                return(createdType);
            }
        }
예제 #3
0
        /// <summary>
        /// Returns the CLR <see cref="MemberInfo"/>.
        /// </summary>
        /// <returns>Returns the CLR <see cref="MemberInfo"/>.</returns>
        public override MemberInfo GetClrVersion()
        {
            InterLinqTypeSystem tsInstance = InterLinqTypeSystem.Instance;

            lock (tsInstance)
            {
                if (tsInstance.IsInterLinqMemberInfoRegistered(this))
                {
                    return(tsInstance.GetClrVersion <PropertyInfo>(this));
                }

                Type         declaringType = (Type)DeclaringType.GetClrVersion();
                PropertyInfo foundProperty = declaringType.GetProperty(Name);
                tsInstance.SetClrVersion(this, foundProperty);
                return(foundProperty);
            }
        }
예제 #4
0
        /// <summary>
        /// Returns the CLR <see cref="MemberInfo"/>.
        /// </summary>
        /// <returns>Returns the CLR <see cref="MemberInfo"/>.</returns>
        public override MemberInfo GetClrVersion()
        {
            InterLinqTypeSystem tsInstance = InterLinqTypeSystem.Instance;

            lock (tsInstance)
            {
                if (tsInstance.IsInterLinqMemberInfoRegistered(this))
                {
                    return(tsInstance.GetClrVersion <ConstructorInfo>(this));
                }

                Type            declaringType    = (Type)DeclaringType.GetClrVersion();
                ConstructorInfo foundConstructor = declaringType.GetConstructor(ParameterTypes.Select(p => (Type)p.GetClrVersion()).ToArray());
                tsInstance.SetClrVersion(this, foundConstructor);
                return(foundConstructor);
            }
        }
예제 #5
0
		/// <summary>
		/// Returns the CLR <see cref="MemberInfo"/>.
		/// </summary>
		/// <returns>Returns the CLR <see cref="MemberInfo"/>.</returns>
		public override MemberInfo GetClrVersion()
		{
			InterLinqTypeSystem tsInstance = InterLinqTypeSystem.Instance;
			lock (tsInstance)
			{
				if (tsInstance.IsInterLinqMemberInfoRegistered(this))
				{
					return tsInstance.GetClrVersion<FieldInfo>(this);
				}

				var declaringType = (Type)DeclaringType.GetClrVersion();
				var foundField = declaringType.GetField(Name);
				if (foundField == null)
				{
					foundField = declaringType.GetField(Name, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
				}

				tsInstance.SetClrVersion(this, foundField);
				return foundField;
			}
		}