public ParameterMetadata MapUp(ParameterModel model)
        {
            ParameterMetadata ParameterMetadata = new ParameterMetadata();

            ParameterMetadata.Name = model.Name;
            Type         type         = model.GetType();
            PropertyInfo typeProperty = type.GetProperty("Type",
                                                         BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
            TypeModel typeModel = (TypeModel)typeProperty?.GetValue(model);

            if (typeModel != null)
            {
                ParameterMetadata.TypeMetadata = TypeModelMapper.EmitType(typeModel);
            }
            return(ParameterMetadata);
        }
        public NamespaceMetadata MapUp(NamespaceModel model)
        {
            NamespaceMetadata NamespaceMetadata = new NamespaceMetadata();

            NamespaceMetadata.Name = model.Name;
            Type         type          = model.GetType();
            PropertyInfo typesProperty = type.GetProperty("Types",
                                                          BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
            List <TypeModel> types = (List <TypeModel>)HelperClass.ConvertList(typeof(TypeModel), (IList)typesProperty?.GetValue(model));

            if (types != null)
            {
                NamespaceMetadata.Types = types.Select(n => TypeModelMapper.EmitType(n)).ToList();
            }
            return(NamespaceMetadata);
        }
Exemple #3
0
        public MethodMetadata MapUp(MethodModel model)
        {
            MethodMetadata MethodMetadata = new MethodMetadata();

            MethodMetadata.Name      = model.Name;
            MethodMetadata.Extension = model.Extension;
            Type         type = model.GetType();
            PropertyInfo genericArgumentsProperty = type.GetProperty("GenericArguments",
                                                                     BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

            if (genericArgumentsProperty?.GetValue(model) != null)
            {
                List <TypeModel> genericArguments =
                    (List <TypeModel>)HelperClass.ConvertList(typeof(TypeModel),
                                                              (IList)genericArgumentsProperty?.GetValue(model));
                MethodMetadata.GenericArguments =
                    genericArguments.Select(g => TypeModelMapper.EmitType(g)).ToList();
            }

            MethodMetadata.Modifiers = model.Modifiers;

            PropertyInfo parametersProperty = type.GetProperty("Parameters",
                                                               BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

            if (parametersProperty?.GetValue(model) != null)
            {
                List <ParameterModel> parameters =
                    (List <ParameterModel>)HelperClass.ConvertList(typeof(ParameterModel),
                                                                   (IList)parametersProperty?.GetValue(model));

                MethodMetadata.Parameters = parameters
                                            .Select(p => new ParameterModelMapper().MapUp(p)).ToList();
            }

            PropertyInfo returnTypeProperty = type.GetProperty("ReturnType",
                                                               BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
            TypeModel returnType = (TypeModel)returnTypeProperty?.GetValue(model);

            if (returnType != null)
            {
                MethodMetadata.ReturnType = TypeModelMapper.EmitType(returnType);
            }
            return(MethodMetadata);
        }