Example #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);
        }
Example #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 }
            });
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #8
0
 public static TypeContext GetTypeContext(this TypeReferenceContext context)
 {
     return(new TypeContext(context.Definitions));
 }
Example #9
0
 public bool IsNullable(MethodInfo methodInfo, TypeReferenceContext context)
 {
     return(false);
 }
Example #10
0
 public bool IsNullable(PropertyInfo propertyInfo, TypeReferenceContext context)
 {
     return(false);
 }
Example #11
0
 public bool IsNullable(ParameterInfo parameterInfo, TypeReferenceContext context)
 {
     return(false);
 }
Example #12
0
 public bool IsOptional(MethodInfo methodInfo, TypeReferenceContext context)
 {
     return(IsOptional(methodInfo.ReturnType, methodInfo));
 }
Example #13
0
 public bool IsOptional(PropertyInfo propertyInfo, TypeReferenceContext context)
 {
     return(IsOptional(propertyInfo.PropertyType, propertyInfo));
 }
Example #14
0
 public bool IsOptional(ParameterInfo parameterInfo, TypeReferenceContext context)
 {
     return(IsOptional(parameterInfo.ParameterType, parameterInfo));
 }