示例#1
0
 public static ParameterExpression Variable(Type type, string name)
 {
     ContractUtils.RequiresNotNull(type, "type");
     ContractUtils.Requires(type != typeof(void), "type", Strings.ArgumentCannotBeOfTypeVoid);
     ContractUtils.Requires(!type.IsByRef, "type", Strings.TypeMustNotBeByRef);
     return(ParameterExpression.Make(type, name, false));
 }
示例#2
0
        /// <summary>
        /// Creates a <see cref="ParameterExpression"/> node that can be used to identify a parameter or a variable in an expression tree.
        /// </summary>
        /// <param name="type">The type of the parameter or variable.</param>
        /// <param name="name">The name of the parameter or variable, used for debugging or pretty printing purpose only.</param>
        /// <returns>A <see cref="ParameterExpression"/> node with the specified name and type.</returns>
        public static ParameterExpression Variable(Type type, string name)
        {
            Validate(type);

            if (type.IsByRef)
            {
                throw Error.TypeMustNotBeByRef(nameof(type));
            }

            return(ParameterExpression.Make(type, name, isByRef: false));
        }
示例#3
0
        /// <summary>
        /// Creates a <see cref="ParameterExpression"/> node that can be used to identify a parameter or a variable in an expression tree.
        /// </summary>
        /// <param name="type">The type of the parameter or variable.</param>
        /// <param name="name">The name of the parameter or variable, used for debugging or pretty printing purpose only.</param>
        /// <returns>A <see cref="ParameterExpression"/> node with the specified name and type.</returns>
        public static ParameterExpression Parameter(Type type, string?name)
        {
            Validate(type, allowByRef: true);
            bool byref = type.IsByRef;

            if (byref)
            {
                type = type.GetElementType() !;
            }

            return(ParameterExpression.Make(type, name, byref));
        }
        /// <summary>
        ///     Creates a <see cref="ParameterExpression" /> node that can be used to identify a parameter or a variable in an
        ///     expression tree.
        /// </summary>
        /// <param name="type">The type of the parameter or variable.</param>
        /// <param name="name">The name of the parameter or variable, used for debugging or pretty printing purpose only.</param>
        /// <returns>A <see cref="ParameterExpression" /> node with the specified name and type.</returns>
        public static ParameterExpression Parameter(Type type, string name)
        {
            Validate(type, true);
            var byref = type.IsByRef;

            if (byref)
            {
                type = type.GetElementType();
            }

            return(ParameterExpression.Make(type, name, byref));
        }
示例#5
0
 /// <summary>
 /// Creates a <see cref="ParameterExpression" /> node that can be used to identify a parameter or a variable in an expression tree.
 /// </summary>
 /// <param name="type">The type of the parameter or variable.</param>
 /// <param name="name">The name of the parameter or variable, used for debugging or pretty printing purpose only.</param>
 /// <returns>A <see cref="ParameterExpression" /> node with the specified name and type.</returns>
 public static ParameterExpression Variable(Type type, string name)
 {
     ContractUtils.RequiresNotNull(type, "type");
     if (type == typeof(void))
     {
         throw Error.ArgumentCannotBeOfTypeVoid();
     }
     if (type.IsByRef)
     {
         throw Error.TypeMustNotBeByRef();
     }
     return(ParameterExpression.Make(type, name, false));
 }
示例#6
0
        /// <summary>
        /// Creates a <see cref="ParameterExpression" /> node that can be used to identify a parameter or a variable in an expression tree.
        /// </summary>
        /// <param name="type">The type of the parameter or variable.</param>
        /// <param name="name">The name of the parameter or variable, used for debugging or pretty printing purpose only.</param>
        /// <returns>A <see cref="ParameterExpression" /> node with the specified name and type.</returns>
        public static ParameterExpression Parameter(Type type, string name)
        {
            ContractUtils.RequiresNotNull(type, "type");

            if (type == typeof(void))
            {
                throw Error.ArgumentCannotBeOfTypeVoid();
            }

            bool byref = type.IsByRef;

            if (byref)
            {
                type = type.GetElementType();
            }

            return(ParameterExpression.Make(type, name, byref));
        }
示例#7
0
        /// <summary>
        /// Creates a <see cref="ParameterExpression"/> node that can be used to identify a parameter or a variable in an expression tree.
        /// </summary>
        /// <param name="type">The type of the parameter or variable.</param>
        /// <param name="name">The name of the parameter or variable, used for debugging or pretty printing purpose only.</param>
        /// <returns>A <see cref="ParameterExpression"/> node with the specified name and type.</returns>
        public static ParameterExpression Variable(Type type, string name)
        {
            ContractUtils.RequiresNotNull(type, nameof(type));
            TypeUtils.ValidateType(type, nameof(type));
            if (type == typeof(void))
            {
                throw Error.ArgumentCannotBeOfTypeVoid(nameof(type));
            }
            if (type.IsByRef)
            {
                throw Error.TypeMustNotBeByRef(nameof(type));
            }

            if (type.IsPointer)
            {
                throw Error.TypeMustNotBePointer(nameof(type));
            }

            return(ParameterExpression.Make(type, name, isByRef: false));
        }
        /// <summary>
        ///     Creates a <see cref="ParameterExpression" /> node that can be used to identify a parameter or a variable in an
        ///     expression tree.
        /// </summary>
        /// <param name="type">The type of the parameter or variable.</param>
        /// <param name="name">The name of the parameter or variable, used for debugging or pretty printing purpose only.</param>
        /// <returns>A <see cref="ParameterExpression" /> node with the specified name and type.</returns>
        public static ParameterExpression Parameter(Type type, string?name)
        {
            ContractUtils.RequiresNotNull(type, nameof(type));
            Validate(type, true);

            var elementType = type.GetElementType();

            if (elementType == null)
            {
                return(ParameterExpression.Make(type, name, false));
            }

            var byref = type.IsByRef;

            if (byref)
            {
                type = elementType;
            }

            return(ParameterExpression.Make(type, name, byref));
        }
 /// <summary>
 ///     Creates a <see cref="ParameterExpression" /> node that can be used to identify a parameter or a variable in an
 ///     expression tree.
 /// </summary>
 /// <param name="type">The type of the parameter or variable.</param>
 /// <param name="name">The name of the parameter or variable, used for debugging or pretty printing purpose only.</param>
 /// <returns>A <see cref="ParameterExpression" /> node with the specified name and type.</returns>
 public static ParameterExpression Variable(Type type, string?name)
 {
     ContractUtils.RequiresNotNull(type, nameof(type));
     Validate(type, false);
     return(ParameterExpression.Make(type, name, false));
 }
示例#10
0
 /// <summary>
 /// Creates a <see cref="ParameterExpression"/> node that can be used to identify a parameter or a variable in an expression tree.
 /// </summary>
 /// <param name="type">The type of the parameter or variable.</param>
 /// <param name="name">The name of the parameter or variable, used for debugging or pretty printing purpose only.</param>
 /// <returns>A <see cref="ParameterExpression"/> node with the specified name and type.</returns>
 public static ParameterExpression Variable(Type type, string?name)
 {
     Validate(type, allowByRef: false);
     return(ParameterExpression.Make(type, name, isByRef: false));
 }
示例#11
0
 /// <summary>
 ///     Creates a <see cref="ParameterExpression" /> node that can be used to identify a parameter or a variable in an
 ///     expression tree.
 /// </summary>
 /// <param name="type">The type of the parameter or variable.</param>
 /// <param name="name">The name of the parameter or variable, used for debugging or pretty printing purpose only.</param>
 /// <returns>A <see cref="ParameterExpression" /> node with the specified name and type.</returns>
 public static ParameterExpression Variable(Type type, string name)
 {
     Validate(type, false);
     return(ParameterExpression.Make(type, name, false));
 }