Exemple #1
0
        protected virtual TypeReference GetTypeReference([NotNull] Type type, [NotNull] TypeReferenceContext context)
        {
            type = GetReturnType(type);

            if (type != null)
            {
                return(_typeReference.GetTypeReference(type, context) ?? new AnyType());
            }

            return(null);
        }
Exemple #2
0
        public ServiceMethodResponse MapMethodResponse(MethodInfo methodInfo, MethodResponseContexts context)
        {
            var response = new ServiceMethodResponse();

            var typeContext = new TypeReferenceContext(context.Services.Definitions);

            response.SourceMethod = methodInfo;
            response.Type         = _returnTypeMapper.GetReturnType(methodInfo, typeContext);

            return(response);
        }
        public ParameterType GetParameterType(ParameterInfo parameterInfo, TypeReferenceContext context)
        {
            TypeReference typeReference = _typeReference.GetTypeReference(parameterInfo.ParameterType, context) ?? new AnyType();

            return new ParameterType
            {
                IsOptional = _optionalStrategy.IsOptional(parameterInfo, context),
                IsNullable = _nullableStrategy.IsNullable(parameterInfo, context),
                Types = { typeReference }
            };
        }
        public PropertyType GetPropertyType(PropertyInfo property, TypeReferenceContext context)
        {
            TypeReference typeReference = _typeReference.GetTypeReference(property.PropertyType, context) ?? new AnyType();

            return(new PropertyType
            {
                IsOptional = _optionalStrategy.IsOptional(property, context),
                IsNullable = _nullableStrategy.IsNullable(property, context),
                Types = { typeReference }
            });
        }
Exemple #5
0
        public ServiceMethodParameter MapServiceMethodParameter(ParameterInfo parameterInfo, MethodParameterContexts context)
        {
            var name      = _parameterNameMapper.MapParameterName(parameterInfo);
            var parameter = new ServiceMethodParameter(name);

            var propertyContext = new TypeReferenceContext(context.Services.Definitions);

            parameter.Source   = parameterInfo;
            parameter.PassOver = _parameterPassOverMapper.MapPassOver(parameterInfo);
            parameter.Type     = _parameterTypeMapper.GetParameterType(parameterInfo, propertyContext);

            return(parameter);
        }
Exemple #6
0
        public virtual ReturnType GetReturnType(MethodInfo methodInfo, TypeReferenceContext context)
        {
            TypeReference typeReference = GetTypeReference(methodInfo.ReturnType, context);

            var result = new ReturnType
            {
                IsOptional = _optionalStrategy.IsOptional(methodInfo, context),
                IsNullable = _nullableStrategy.IsNullable(methodInfo, context)
            };

            if (typeReference != null)
            {
                result.Types.Add(typeReference);
            }

            return(result);
        }
Exemple #7
0
        public TypeReference GetTypeReference(Type type, TypeReferenceContext context)
        {
            var nullableType = Nullable.GetUnderlyingType(type);

            if (nullableType != null)
            {
                type = nullableType;
            }

            foreach (var converter in Converters)
            {
                var typeReference = converter.TryConvert(type, context);
                if (typeReference != null)
                {
                    return(typeReference);
                }
            }

            return(null);
        }
Exemple #8
0
 public static TypeContext GetTypeContext(this TypeReferenceContext context)
 {
     return(new TypeContext(context.Definitions));
 }
 public bool IsNullable(MethodInfo methodInfo, TypeReferenceContext context)
 {
     return(false);
 }
 public bool IsNullable(PropertyInfo propertyInfo, TypeReferenceContext context)
 {
     return(false);
 }
 public bool IsNullable(ParameterInfo parameterInfo, TypeReferenceContext context)
 {
     return(false);
 }
 public bool IsOptional(MethodInfo methodInfo, TypeReferenceContext context)
 {
     return(IsOptional(methodInfo.ReturnType, methodInfo));
 }
 public bool IsOptional(PropertyInfo propertyInfo, TypeReferenceContext context)
 {
     return(IsOptional(propertyInfo.PropertyType, propertyInfo));
 }
 public bool IsOptional(ParameterInfo parameterInfo, TypeReferenceContext context)
 {
     return(IsOptional(parameterInfo.ParameterType, parameterInfo));
 }