RequiresRdf() public method

Checks whether the given type requires an RDF approach.
public RequiresRdf ( Type type ) : bool
type System.Type The type to check.
return bool
Ejemplo n.º 1
0
        private IClass CreateEnumerableDefinition(DescriptionContext context, Uri baseType, out bool requiresRdf, out Type itemType, bool isGeneric = true)
        {
            itemType    = null;
            requiresRdf = false;
            if (!isGeneric)
            {
                return(context.ApiDocumentation.Context.Create <IClass>(baseType));
            }

            itemType = context.Type.GetItemType();
            IClass result = context.ApiDocumentation.Context.Create <IClass>(context.Type.MakeUri());

            result.Label       = context.Type.MakeTypeName(false, true);
            result.Description = _xmlDocProvider.GetDescription(context.Type);
            result.SubClassOf.Add(context.ApiDocumentation.Context.Create <IClass>(baseType));
            requiresRdf |= context.RequiresRdf(itemType);
            context.Describe(result, requiresRdf);
            return(result);
        }
Ejemplo n.º 2
0
        private IOperation BuildOperation(DescriptionContext context, OperationInfo <Verb> operation, out IIriTemplate template)
        {
            IOperation result = operation.AsOperation(context.ApiDocumentation);

            result.Label       = operation.UnderlyingMethod.Name;
            result.Description = _xmlDocProvider.GetDescription(operation.UnderlyingMethod);
            result.Method.Add(operation.ProtocolSpecificCommand.ToString());
            template = BuildTemplate(context, operation, result);
            bool requiresRdf   = context.RequiresRdf(SpecializationType);
            bool isRdfRequired = requiresRdf;
            var  arguments     = operation.Arguments.Where(parameter => parameter.Source is FromBodyAttribute).Select(parameter => parameter.Parameter);
            var  results       = operation.Results.Where(output => output.Target is ToBodyAttribute).Select(parameter => parameter.Parameter);

            foreach (var value in arguments)
            {
                var expected = (context.ContainsType(value.ParameterType) ? context[value.ParameterType] : context.ForType(value.ParameterType).BuildTypeDescription(out isRdfRequired));
                expected             = context.SubClass(expected, value.ParameterType);
                expected.Label       = value.Name ?? "instance";
                expected.Description = _xmlDocProvider.GetDescription(operation.UnderlyingMethod, value);
                result.Expects.Add(expected);
                requiresRdf |= isRdfRequired;
            }

            foreach (var value in results)
            {
                var returned = (context.ContainsType(value.ParameterType) ? context[value.ParameterType] : context.ForType(value.ParameterType).BuildTypeDescription(out isRdfRequired));
                returned             = context.SubClass(returned, value.ParameterType);
                returned.Description = _xmlDocProvider.GetDescription(operation.UnderlyingMethod, value);
                result.Returns.Add(returned);
                requiresRdf |= isRdfRequired;
            }

            BuildStatusCodes(result, operation);
            BuildOperationMediaType(result, result.Returns, operation, requiresRdf);
            BuildOperationMediaType(result, result.Expects, operation, requiresRdf);
            if (!result.MediaTypes.Any())
            {
                BuildOperationMediaType(result, requiresRdf);
            }

            return(result);
        }
        private IClass CreateEnumerableDefinition(DescriptionContext context, Uri baseType, out bool requiresRdf, out Type itemType, bool isGeneric = true)
        {
            itemType = null;
            requiresRdf = false;
            if (!isGeneric)
            {
                return context.ApiDocumentation.Context.Create<IClass>(baseType);
            }

            itemType = context.Type.GetItemType();
            IClass result = context.ApiDocumentation.Context.Create<IClass>(context.Type.MakeUri());
            result.Label = context.Type.MakeTypeName(false, true);
            result.Description = _xmlDocProvider.GetDescription(context.Type);
            result.SubClassOf.Add(context.ApiDocumentation.Context.Create<IClass>(baseType));
            requiresRdf |= context.RequiresRdf(itemType);
            context.Describe(result, requiresRdf);
            return result;
        }
Ejemplo n.º 4
0
        private IOperation BuildOperation(DescriptionContext context, OperationInfo<Verb> operation, out IIriTemplate template)
        {
            IOperation result = operation.AsOperation(context.ApiDocumentation);
            result.Label = operation.UnderlyingMethod.Name;
            result.Description = _xmlDocProvider.GetDescription(operation.UnderlyingMethod);
            result.Method.Add(operation.ProtocolSpecificCommand.ToString());
            template = BuildTemplate(context, operation, result);
            bool requiresRdf = context.RequiresRdf(SpecializationType);
            bool isRdfRequired = requiresRdf;
            var arguments = operation.Arguments.Where(parameter => parameter.Source is FromBodyAttribute).Select(parameter => parameter.Parameter);
            var results = operation.Results.Where(output => output.Target is ToBodyAttribute).Select(parameter => parameter.Parameter);

            foreach (var value in arguments)
            {
                var expected = (context.ContainsType(value.ParameterType) ? context[value.ParameterType] : context.ForType(value.ParameterType).BuildTypeDescription(out isRdfRequired));
                expected = context.SubClass(expected, value.ParameterType);
                expected.Label = value.Name ?? "instance";
                expected.Description = _xmlDocProvider.GetDescription(operation.UnderlyingMethod, value);
                result.Expects.Add(expected);
                requiresRdf |= isRdfRequired;
            }

            foreach (var value in results)
            {
                var returned = (context.ContainsType(value.ParameterType) ? context[value.ParameterType] : context.ForType(value.ParameterType).BuildTypeDescription(out isRdfRequired));
                returned = context.SubClass(returned, value.ParameterType);
                returned.Description = _xmlDocProvider.GetDescription(operation.UnderlyingMethod, value);
                result.Returns.Add(returned);
                requiresRdf |= isRdfRequired;
            }

            BuildStatusCodes(result, operation);
            BuildOperationMediaType(result, result.Returns, operation, requiresRdf);
            BuildOperationMediaType(result, result.Expects, operation, requiresRdf);
            if (!result.MediaTypes.Any())
            {
                BuildOperationMediaType(result, requiresRdf);
            }

            return result;
        }