Describe() public method

Describes the current type.
public Describe ( IClass resource, bool requiresRdf ) : void
resource IClass The resource describing a type.
requiresRdf bool Flag determining whether the type requires RDF approach.
return void
コード例 #1
0
        /// <inheritdoc />
        public IClass BuildTypeDescription(DescriptionContext context, out bool requiresRdf)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (context.ContainsType(context.Type))
            {
                return(context.BuildTypeDescription(out requiresRdf));
            }

            if (System.Reflection.TypeExtensions.IsEnumerable(context.Type))
            {
                if (context.Type.IsList())
                {
                    return(CreateListDefinition(context, out requiresRdf, context.Type.IsGenericList()));
                }

                return(CreateCollectionDefinition(context, out requiresRdf, context.Type.IsGenericEnumerable()));
            }

            requiresRdf = false;
            Type itemType = context.Type.GetItemType();

            if (TypeDescriptions.ContainsKey(itemType))
            {
                return(BuildDatatypeDescription(context, TypeDescriptions[itemType]));
            }

            var classUri = itemType.MakeUri();

            if (typeof(IEntity).IsAssignableFrom(itemType))
            {
                classUri    = context.ApiDocumentation.Context.Mappings.MappingFor(itemType).Classes.Select(item => item.Uri).FirstOrDefault() ?? classUri;
                requiresRdf = true;
            }

            IClass result = context.ApiDocumentation.Context.Create <IClass>(classUri);

            result.Label       = itemType.MakeTypeName(false, true);
            result.Description = _xmlDocProvider.GetDescription(itemType);
            if (typeof(EntityId).IsAssignableFrom(itemType))
            {
                context.Describe(result, requiresRdf);
                return(result);
            }

            context.Prescribe(result, requiresRdf);
            SetupProperties(context.ForType(itemType), result);
            context.Describe(result, requiresRdf);
            return(result);
        }
コード例 #2
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);
        }
コード例 #3
0
        /// <inheritdoc />
        public IClass BuildTypeDescription(DescriptionContext context, out bool requiresRdf)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (context.ContainsType(context.Type))
            {
                return context.BuildTypeDescription(out requiresRdf);
            }

            if (System.Reflection.TypeExtensions.IsEnumerable(context.Type))
            {
                if (context.Type.IsList())
                {
                    return CreateListDefinition(context, out requiresRdf, context.Type.IsGenericList());
                }

                return CreateCollectionDefinition(context, out requiresRdf, context.Type.IsGenericEnumerable());
            }

            requiresRdf = false;
            Type itemType = context.Type.GetItemType();
            if (TypeDescriptions.ContainsKey(itemType))
            {
                return BuildDatatypeDescription(context, TypeDescriptions[itemType]);
            }

            var classUri = itemType.MakeUri();
            if (typeof(IEntity).IsAssignableFrom(itemType))
            {
                classUri = context.ApiDocumentation.Context.Mappings.MappingFor(itemType).Classes.Select(item => item.Uri).FirstOrDefault() ?? classUri;
                requiresRdf = true;
            }

            IClass result = context.ApiDocumentation.Context.Create<IClass>(classUri);
            result.Label = itemType.MakeTypeName(false, true);
            result.Description = _xmlDocProvider.GetDescription(itemType);
            if (typeof(EntityId).IsAssignableFrom(itemType))
            {
                context.Describe(result, requiresRdf);
                return result;
            }

            context.Prescribe(result, requiresRdf);
            SetupProperties(context.ForType(itemType), result);
            context.Describe(result, requiresRdf);
            return result;
        }
コード例 #4
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;
        }