示例#1
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 <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 <ConstructorInfo>(this));
                }

                Type            declaringType    = (Type)DeclaringType.GetClrVersion();
                ConstructorInfo foundConstructor = declaringType.GetConstructor(ParameterTypes.Select(p => (Type)p.GetClrVersion()).ToArray());
                tsInstance.SetClrVersion(this, foundConstructor);
                return(foundConstructor);
            }
        }
示例#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 <FieldInfo>(this));
                }

                Type      declaringType = (Type)DeclaringType.GetClrVersion();
                FieldInfo foundField    = declaringType.GetField(Name);
                tsInstance.SetClrVersion(this, foundField);
                return(foundField);
            }
        }
示例#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<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;
			}
		}
        /// <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));
                }

#if !NETFX_CORE
                Type            declaringType    = (Type)DeclaringType.GetClrVersion();
                ConstructorInfo foundConstructor = declaringType.GetConstructor(ParameterTypes.Select(p => (Type)p.GetClrVersion()).ToArray());
#else
                Type            declaringType    = ((TypeInfo)DeclaringType.GetClrVersion()).AsType();
                ConstructorInfo foundConstructor = declaringType.GetTypeInfo().DeclaredConstructors.FirstOrDefault(x => Enumerable.SequenceEqual(x.GetParameters().Select(y => y.ParameterType), ParameterTypes.Select(p => ((TypeInfo)p.GetClrVersion()).AsType())));
#endif
                tsInstance.SetClrVersion(this, foundConstructor);
                return(foundConstructor);
            }
        }
示例#6
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));
                }

#if !NETFX_CORE
                Type      declaringType = (Type)DeclaringType.GetClrVersion();
                FieldInfo foundField    = declaringType.GetField(Name);
#else
                Type      declaringType = ((TypeInfo)DeclaringType.GetClrVersion()).AsType();
                FieldInfo foundField    = declaringType.GetTypeInfo().DeclaredFields.FirstOrDefault(x => x.Name == Name);
#endif
                tsInstance.SetClrVersion(this, foundField);
                return(foundField);
            }
        }
        /// <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));
                }

#if !NETFX_CORE
                Type         declaringType = (Type)DeclaringType.GetClrVersion();
                PropertyInfo foundProperty = declaringType.GetProperty(Name);
#else
                Type         declaringType = ((TypeInfo)DeclaringType.GetClrVersion()).AsType();
                PropertyInfo foundProperty = declaringType.GetTypeInfo().GetDeclaredProperty(Name);
#endif
                tsInstance.SetClrVersion(this, foundProperty);
                return(foundProperty);
            }
        }