コード例 #1
0
        private bool TryGetConstructor(TypeReference type, out MethodDefinition constructor, bool returnConstructorIfAbstractType = false)
        {
            if (!returnConstructorIfAbstractType)
            {
                TypeDefinition td = AnalysisUtils.GetTypeDefinitionFromTypeReference(type, _modules);
                if (td == null || AnalysisUtils.IsTypeAbstract(td))
                {
                    constructor = null;
                    return(false);
                }
            }
            HashSet <MethodDefinition> constructors;

            if (TryGetConstructors(type, out constructors))
            {
                constructor = ConvertConstructorToGenericInstanceMethod(GetConstructorWithMinimumParameters(constructors), type);
                return(true);
            }
            // we should never be in this situation
            else
            {
                constructor = null;
                return(false);
            }
        }