Example #1
0
        public SemanticConstructorMask_I GetConstructor(ILConversion conversion, BoundTypeDefinitionWithConstructorsMask_I declaringType, MethodReference methodSignature)
        {
            //var sig = (IMethodSignature) methodReference;

            var constructors = declaringType.Constructors;

            // If there is  just a single constructor, return it.
            if (constructors.All.Count == 1)
            {
                return(constructors.All[0]);
            }

            for (int i = 0; i < constructors.All.Count; i++)
            {
                var constructor = constructors.All[i];

                // TODO: Eventually change to match up RIDs or something like that instead.
                // Member References should be matched up front right after all modules and assemblies are loaded, so they do not have to be rematched later.
                if (!Routines.Finding.ParameterMatching.VerifyParameters(conversion, constructor.MethodReference, methodSignature))
                {
                    continue;
                }

                return(constructor);
            }

            return(null);
        }
Example #2
0
        public SemanticConstructorMask_I GetConstructor(ILConversion conversion, BoundTypeDefinitionWithConstructorsMask_I declaringType, MethodReference methodSignature)
        {
            // I actually would want to match a mmberRef to a method siganture, but the problem is that the member ref accesse outside the
            // assembly. So you are left having to do parameter matching.
            var constructors = declaringType.Constructors;

            //if (constructors.All.Count > 0)
            //{

            // If there is  just a single constructor, return it.
            if (constructors.All.Count == 1)
            {
                return(constructors.All[0]);
            }

            for (int i = 0; i < constructors.All.Count; i++)
            {
                var constructor = constructors.All[i];

                // TODO: Eventually change to match up RIDs or something like that instead.
                // Member References should be matched up front right after all modules and assemblies are loaded, so they do not have to be rematched later.
                if (!Routines.Finding.ParameterMatching.VerifyParameters(conversion, constructor.MethodReference,
                                                                         methodSignature))
                {
                    continue;
                }

                if (constructor.IsStaticConstructor)
                {
                    continue;
                }

                return(constructor);
            }

            return(null);
            //}
            //  else
            //  {
            //var constructors1 = declaringType.UnderlyingType.GetConstructors(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);

            //   foreach (var constructor in constructors1)
            //   {
            //    var x =constructor.MetadataToken;

            //   }

            //   throw new System.NotImplementedException();
            //  }
        }