Esempio n. 1
0
        private IType GetType(List <INamedDeclaration> declarations)
        {
            if (declarations.All(x => x is ITypeDeclaration))
            {
                return(new StaticReference(declarations.Cast <INode>().ToList()));
            }

            IType type = null;

            switch (declarations.Single())
            {
            case VariableDeclaration variableDeclaration:
                type = variableDeclaration.Type;
                break;

            case GetterSetterDeclaration getterSetterDeclaration:
                if (getterSetterDeclaration.Getter != null && getterSetterDeclaration.Getter.ReturnType == null)
                {
                    Visit(getterSetterDeclaration.Getter);
                }
                type = getterSetterDeclaration.Type;
                break;

            case MethodDeclaration methodDeclaration:
                type = new MethodReferenceType(methodDeclaration);
                break;

            default:
                throw new Exception("Unexpected declaration: " + declarations.Single().GetType().FullName);
            }

            return(type);
        }
 /// <summary>
 /// Creates a new <see cref="UnboundMethodReferenceStub"/> with the
 /// <paramref name="source"/>,
 /// <paramref name="genericParameters"/> and
 /// <paramref name="referenceType"/> provdied.
 /// </summary>
 /// <param name="source">The <see cref="IMemberParentReferenceExpression"/>
 /// from which the <see cref="UnboundMethodReferenceStub"/> was sourced.</param>
 /// <param name="genericParameters">The <see cref="ITypeCollection"/>
 /// of generic parameter replacements for the signature.</param>
 /// <param name="referenceType">The means to refer to
 /// the method.</param>
 public MethodReferenceStubBase(IMemberParentReferenceExpression source, IControlledTypeCollection genericParameters = null, MethodReferenceType referenceType = MethodReferenceType.VirtualMethodReference)
 {
     if (genericParameters != null)
     {
         this.genericParameters = genericParameters is ILockedTypeCollection ? ((ILockedTypeCollection)(genericParameters)) : genericParameters.ToLockedCollection();
     }
     this.referenceType = referenceType;
     this.source        = source;
 }
Esempio n. 3
0
 public IndexerSignatureReferenceExpression(TIndexer member, IEnumerable <IExpression> parameters, IMemberParentReferenceExpression source, MethodReferenceType referenceType = MethodReferenceType.VirtualMethodReference, IndexerReferenceType indexerType = IndexerReferenceType.InferredIndexer)
     : base()
 {
     this.Source        = source;
     this.Member        = member;
     this.Parameters    = new MalleableExpressionCollection(parameters);
     this.ReferenceType = referenceType;
 }
 /// <summary>
 /// Creates a new <see cref="UnboundMethodReferenceStub"/> with the
 /// <paramref name="source"/>, <paramref name="member"/>,
 /// <paramref name="genericParameters"/> and
 /// <paramref name="referenceType"/> provdied.
 /// </summary>
 /// <param name="source">The <see cref="IMemberParentReferenceExpression"/>
 /// from which the <see cref="UnboundMethodReferenceStub"/> was sourced.</param>
 /// <param name="member">The <typeparamref name="TSignature"/>
 /// to reference.</param>
 /// <param name="genericParameters">The <see cref="ITypeCollection"/>
 /// of generic parameter replacements for the signature.</param>
 /// <param name="referenceType">The means to refer to
 /// the method.</param>
 /// <param name="signatureTypesObtainer">The <see cref="Func{TResult}"/> which obtains the signature
 /// of the <paramref name="member"/>.</param>
 public MethodReferenceStub(IMemberParentReferenceExpression source, TSignature member, IControlledTypeCollection genericParameters, MethodReferenceType referenceType, Func <MethodPointerReferenceExpression <TSignatureParameter, TSignature, TParent> .SignatureTypes> signatureTypesObtainer)
     : base(source, genericParameters, referenceType)
 {
     this.Member = member;
     this.signatureTypesObtainer = signatureTypesObtainer;
 }
 /// <summary>
 /// Creates a new <see cref="UnboundMethodReferenceStub"/> with the
 /// <paramref name="genericParameters"/>
 /// and <paramref name="referenceType"/> provdied.
 /// </summary>
 /// <param name="genericParameters">The <see cref="ITypeCollection"/>
 /// of generic parameter replacements for the signature.</param>
 /// <param name="referenceType">The means to refer to
 /// the method.</param>
 public MethodReferenceStubBase(IControlledTypeCollection genericParameters, MethodReferenceType referenceType)
     : this(null, genericParameters, referenceType)
 {
 }
 /// <summary>
 /// Creates a new <see cref="UnboundMethodReferenceStub"/> with the
 /// <paramref name="name"/>, and
 /// <paramref name="referenceType"/> provdied.
 /// </summary>
 /// <param name="name">A <see cref="System.String"/>
 /// relative to the name of the method.</param>
 /// <param name="referenceType">The means to refer to
 /// the method.</param>
 public UnboundMethodReferenceStub(string name, MethodReferenceType referenceType)
     : base(source: null, referenceType: referenceType)
 {
     this.name = name;
 }
 /// <summary>
 /// Creates a new <see cref="UnboundMethodReferenceStub"/> with the
 /// <paramref name="name"/>, <paramref name="genericParameters"/>
 /// and <paramref name="referenceType"/> provdied.
 /// </summary>
 /// <param name="name">A <see cref="System.String"/>
 /// relative to the name of the method.</param>
 /// <param name="genericParameters">The <see cref="ITypeCollection"/>
 /// of generic parameter replacements for the signature.</param>
 /// <param name="referenceType">The means to refer to
 /// the method.</param>
 public UnboundMethodReferenceStub(string name, IControlledTypeCollection genericParameters, MethodReferenceType referenceType)
     : base(genericParameters, referenceType)
 {
     this.name = name;
 }
 /// <summary>
 /// Creates a new <see cref="UnboundMethodReferenceStub"/> with the
 /// <paramref name="source"/>, <paramref name="name"/>,
 /// <paramref name="genericParameters"/> and
 /// <paramref name="referenceType"/> provdied.
 /// </summary>
 /// <param name="source">The <see cref="IMemberParentReferenceExpression"/>
 /// from which the <see cref="UnboundMethodReferenceStub"/> was sourced.</param>
 /// <param name="name">A <see cref="System.String"/>
 /// relative to the name of the method.</param>
 /// <param name="genericParameters">The <see cref="ITypeCollection"/>
 /// of generic parameter replacements for the signature.</param>
 /// <param name="referenceType">The means to refer to
 /// the method.</param>
 public UnboundMethodReferenceStub(IMemberParentReferenceExpression source, string name, IControlledTypeCollection genericParameters, MethodReferenceType referenceType)
     : base(source, genericParameters, referenceType)
 {
     this.name = name;
 }
 public PropertyReferenceExpression(IMemberParentReferenceExpression source, TProperty member, MethodReferenceType referenceType = MethodReferenceType.VirtualMethodReference)
 {
     this.Source        = source;
     this.Member        = member;
     this.ReferenceType = referenceType;
 }