public override ObjectDefinitionBase Process(ObjectDefinitionBase definition, IObjectDefinitions <Type> objectDefinitions, Type parameter) { var typeInfo = parameter.GetTypeInfo(); if (typeInfo.BaseType != null) { definition.BaseType = objectDefinitions.Get(typeInfo.BaseType); } typeInfo.ImplementedInterfaces? .Select(objectDefinitions.Get) .ToList() .ForEach(definition.AddImplementedInterface); definition.Namespace = typeInfo.Namespace; definition.IsAbstract = typeInfo.IsAbstract; definition.IsInterface = typeInfo.IsInterface; if (typeInfo.IsArray && parameter != typeof(string)) { definition.IsArray = true; definition.InnerObject = objectDefinitions.Get(parameter.GetElementType() ?? typeof(object)); } else if (typeof(IEnumerable).GetTypeInfo().IsAssignableFrom(typeInfo) && parameter != typeof(string)) { definition.IsArray = true; definition.InnerObject = objectDefinitions.Get((typeInfo.IsGenericType ? parameter.GenericTypeArguments.FirstOrDefault() : parameter.GetElementType()) ?? typeof(object)); } if (typeInfo.IsGenericType) { } return(definition); }
public override MethodDefinition Process(MethodDefinition definition, IObjectDefinitions <Type> objectDefinitions, MethodInfo parameter) { var attributeProvider = this.Resolve <IAttributeDefinitionProvider <Attribute, Type> >(); var parameterProvider = this.Resolve <IParameterDefinitionProvider <ParameterInfo, Type> >(); var methodDefinition = definition; if (methodDefinition == null) { return(definition); } methodDefinition.Name = parameter.Name; methodDefinition.ReturnType = objectDefinitions.Get(parameter.ReturnType); parameter.GetCustomAttributes() .Select(x => attributeProvider.Process(attributeProvider.GetFromSource(x), objectDefinitions, x)) .ToList() .ForEach(x => methodDefinition.AddAttribute(x)); parameter.GetParameters() .Select(x => parameterProvider.Process(parameterProvider.GetFromSource(x), objectDefinitions, x)) .ToList() .ForEach(x => methodDefinition.AddParameter(x)); return(definition); }
public override PropertyDefinition Process(PropertyDefinition definition, IObjectDefinitions <Type> objectDefinitions, PropertyInfo parameter) { var attributeProvider = this.Resolve <IAttributeDefinitionProvider <Attribute, Type> >(); var propertyDefinition = definition; if (propertyDefinition == null) { return(definition); } propertyDefinition.Name = parameter.Name; propertyDefinition.Type = objectDefinitions.Get(parameter.PropertyType); parameter.GetCustomAttributes() .Select(x => attributeProvider.Process(attributeProvider.GetFromSource(x), objectDefinitions, x)) .ToList() .ForEach(x => propertyDefinition.AddAttribute(x)); return(definition); }