Exemplo n.º 1
0
        private IIriTemplateMapping BuildTemplateMapping(DescriptionContext context, Uri templateUri, OperationInfo <Verb> operation, ArgumentInfo mapping)
        {
            IIriTemplateMapping templateMapping = context.ApiDocumentation.Context.Create <IIriTemplateMapping>(templateUri.AddFragment(mapping.VariableName));

            templateMapping.Variable    = mapping.VariableName;
            templateMapping.Required    = (mapping.Parameter.ParameterType.IsValueType) && (!mapping.Parameter.HasDefaultValue);
            templateMapping.Description = _xmlDocProvider.GetDescription(operation.UnderlyingMethod, mapping.Parameter);
            var linqBehaviors = mapping.Parameter.GetCustomAttributes <LinqServerBehaviorAttribute>(true);

            if (linqBehaviors.Any())
            {
                foreach (var visitor in _serverBehaviorAttributeVisitors)
                {
                    linqBehaviors.Accept(mapping.Parameter.ParameterType, visitor, templateMapping, context);
                }
            }
            else if (context.Type != typeof(object))
            {
                templateMapping.Property = GetMappingProperty(context, mapping.Parameter);
            }

            return(templateMapping);
        }