/// <inheritdoc /> public void Visit <T>(LinqServerBehaviorAttribute behaviorAttribute, IIriTemplateMapping templateMapping, DescriptionContext descriptionContext) { IClass range = null; Uri uri = null; switch (behaviorAttribute.Operation) { case LinqOperations.Filter: range = (descriptionContext.ContainsType(typeof(string)) ? descriptionContext[typeof(string)] : descriptionContext.TypeDescriptionBuilder.BuildTypeDescription(descriptionContext.ForType(typeof(string)))); uri = new Uri(OData + "$filter"); break; case LinqOperations.Skip: uri = new Uri(OData + "$skip"); break; case LinqOperations.Take: uri = new Uri(OData + "$top"); break; } if (range == null) { range = (descriptionContext.ContainsType(typeof(T)) ? descriptionContext[typeof(T)] : descriptionContext.TypeDescriptionBuilder.BuildTypeDescription(descriptionContext.ForType(typeof(T)))); } templateMapping.Property = templateMapping.Context.Create <Rdfs.IProperty>(uri); templateMapping.Property.Range.Add(range); }
/// <summary>Initializes a new instance of the <see cref="PropertyMapping" /> class.</summary> /// <param name="builder">Mappings builder.</param> /// <param name="result">Current property mappings.</param> /// <param name="mapping">IRI template mapping.</param> internal PropertyMapping( MappingsBuilder builder, IDictionary <string, string> result, IIriTemplateMapping mapping) { _builder = builder; _result = result; _mapping = mapping; }
/// <summary>Accepts the specified visitor.</summary> /// <param name="attributes">The attributes to be visited.</param> /// <param name="memberType">Type of the member.</param> /// <param name="visitor">The visitor.</param> /// <param name="templateMapping">Template mapping to be amended by visitor.</param> /// <param name="descriptionContext">Description context.</param> public static void Accept( this IEnumerable<ServerBehaviorAttribute> attributes, Type memberType, IServerBehaviorAttributeVisitor visitor, IIriTemplateMapping templateMapping, DescriptionContext descriptionContext) { foreach (var attribute in attributes) { attribute.GetType().GetMethod("Accept", BindingFlags.Instance | BindingFlags.Public) .MakeGenericMethod(memberType).Invoke(attribute, new object[] { visitor, templateMapping, descriptionContext }); } }
/// <summary>Accepts the specified visitor.</summary> /// <param name="attributes">The attributes to be visited.</param> /// <param name="memberType">Type of the member.</param> /// <param name="visitor">The visitor.</param> /// <param name="templateMapping">Template mapping to be amended by visitor.</param> /// <param name="descriptionContext">Description context.</param> public static void Accept( this IEnumerable <ServerBehaviorAttribute> attributes, Type memberType, IServerBehaviorAttributeVisitor visitor, IIriTemplateMapping templateMapping, DescriptionContext descriptionContext) { foreach (var attribute in attributes) { attribute.GetType().GetMethod("Accept", BindingFlags.Instance | BindingFlags.Public) .MakeGenericMethod(memberType).Invoke(attribute, new object[] { visitor, templateMapping, descriptionContext }); } }
/// <inheritdoc /> public override void Accept <T>(IServerBehaviorAttributeVisitor visitor, IIriTemplateMapping templateMapping, DescriptionContext descriptionContext) { if (visitor == null) { throw new ArgumentNullException("visitor"); } if (templateMapping == null) { throw new ArgumentNullException("templateMapping"); } visitor.Visit <T>(this, templateMapping, descriptionContext); }
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); }
/// <summary>Accepts the specified visitor.</summary> /// <typeparam name="T">Type of member visited.</typeparam> /// <param name="visitor">The visitor.</param> /// <param name="templateMapping">Template mapping to be amended by visitor.</param> /// <param name="descriptionContext">Description context.</param> public abstract void Accept <T>(IServerBehaviorAttributeVisitor visitor, IIriTemplateMapping templateMapping, DescriptionContext descriptionContext);