Exemple #1
0
 internal MethodName WithParameters(ParameterData[] pms)
 {
     return(new DefaultMethodName(DeclaringType, _name)
     {
         _parameters = ParameterData.ToArray(this, pms),
         _genericParameters = _genericParameters,
         _returnParameter = CopyReturnParameter(this),
     });
 }
Exemple #2
0
 internal PropertyName(TypeName declaringType,
                       string name,
                       TypeName propertyType,
                       ParameterData[] parameters) : base(declaringType)
 {
     _name        = name;
     PropertyType = propertyType;
     _parameters  = ParameterData.ToArray(this, parameters)
                    ?? ParameterNameCollection.Empty;
 }
Exemple #3
0
 internal static Arg SetParameters(IEnumerable <TypeName> parameterTypes)
 {
     return(result => {
         result.FinalizeParameters(
             ParameterData.AllFromTypes(
                 BindParameterTypes(result, parameterTypes)
                 )
             );
     });
 }
Exemple #4
0
        public static PropertyName FromPropertyInfo(System.Reflection.PropertyInfo property)
        {
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            var declaringType = TypeName.FromType(property.DeclaringType);
            var propertyType  = TypeName.FromType(property.PropertyType);
            var parms         = ParameterData.ConvertAll(property.GetIndexParameters());

            return(new PropertyName(declaringType, property.Name, propertyType, parms));
        }
Exemple #5
0
        internal override MethodName WithGenericParameters(GenericParameterName[] parameters)
        {
            var result = new DefaultMethodName(DeclaringType, _name);

            result.FinalizeGenerics(parameters);
            result.FinalizeParameters(ParameterData.AsData(_parameters).ToArray());

            if (ReturnType != null)
            {
                result.FinalizeReturnType(ReturnType.CloneBind(DeclaringType, result));
            }
            return(result);
        }
Exemple #6
0
        public static MethodName FromConstructorInfo(System.Reflection.ConstructorInfo constructor)
        {
            if (constructor == null)
            {
                throw new ArgumentNullException("constructor");
            }

            return(new DefaultMethodName(
                       TypeName.FromType(constructor.DeclaringType),
                       constructor.Name,
                       DefaultMethodName.SetGenericMangle(0),
                       DefaultMethodName.SetParameters(
                           ParameterData.ConvertAll(constructor.GetParameters())
                           )
                       ));
        }
Exemple #7
0
        private MethodName GetSetMethod()
        {
            string name = "set_" + Name;

            var parameters = new ParameterData[IndexParameters.Count + 1];

            parameters[parameters.Length - 1] = new ParameterData("value", PropertyType);
            var indexes = ParameterData.AllFromTypes(IndexParameters.Select(t => t.ParameterType));

            indexes.CopyTo(parameters, 0);

            return(new DefaultMethodName(
                       DeclaringType,
                       name,
                       DefaultMethodName.SetParameters(parameters),
                       DefaultMethodName.SetReturnType(TypeName.Void)
                       ));
        }
Exemple #8
0
        public PropertyName GetProperty(string name, params TypeName[] parameters)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (name.Length == 0)
            {
                throw Failure.EmptyString(nameof(name));
            }

            parameters = parameters ?? Array.Empty <TypeName>();
            if (parameters.Any(t => t == null))
            {
                throw Failure.CollectionContainsNullElement("parameters");
            }

            return(new PropertyName(this, name, null, ParameterData.AllFromTypes(parameters)));
        }
Exemple #9
0
        public PropertyName GetProperty(string name,
                                        TypeName propertyType,
                                        IEnumerable <TypeName> parameters)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (name.Length == 0)
            {
                throw Failure.EmptyString(nameof(name));
            }

            parameters = parameters ?? Array.Empty <TypeName>();
            if (parameters.Any(t => t == null))
            {
                throw Failure.CollectionContainsNullElement(nameof(parameters));
            }

            // TODO Can't bind unboound method parameters here
            var allParams = ParameterData.AllFromTypes(BindParameterTypes(null, parameters.ToArray()));

            return(new PropertyName(this, name, SafeCloneBind(propertyType), allParams));
        }
Exemple #10
0
 internal static Arg SetParameters(ParameterInfo[] parameters)
 {
     return(result => result.FinalizeParameters(ParameterData.ConvertAll(parameters)));
 }
Exemple #11
0
 internal void FinalizeParameters(ParameterData[] pms)
 {
     _parameters = ParameterData.ToArray(this, pms);
 }