Ejemplo n.º 1
0
        /// <summary>
        /// Creates <see cref="TypeMethodInfo" /> for given element.
        /// </summary>
        /// <param name="element">Element which <see cref="TypeMethodInfo" /> is created.</param>
        /// <returns>Created <see cref="TypeMethodInfo" />.</returns>
        protected TypeMethodInfo BuildFrom(CodeFunction element)
        {
            //collect information from element - note, every call working with element may fail with exception, because of VS doesn't provide determinism
            var name          = RequiredName;
            var isShared      = element.IsShared;
            var isAbstract    = element.MustImplement || element.IsVirtual();
            var declaringType = CreateDescriptor(element.DeclaringType());
            var returnType    = CreateDescriptor(element.Type);
            var parameters    = CreateParametersInfo(element.Parameters);

            //Methods cannot have generic arguments (only parameters, that are contained within path)
            var methodTypeArguments = TypeDescriptor.NoDescriptors;

            //create result according to collected information
            var methodInfo = new TypeMethodInfo(
                declaringType, name, returnType, parameters,
                isShared, methodTypeArguments, isAbstract
                );

            return(methodInfo);
        }