Esempio n. 1
0
        public Udi Resolve(IContentTypeComposition source)
        {
            if (source == null)
            {
                return(null);
            }

            return(Udi.Create(
                       source.GetType() == typeof(IMemberType)
                    ? Constants.UdiEntityType.MemberType
                    : source.GetType() == typeof(IMediaType)
                        ? Constants.UdiEntityType.MediaType : Constants.UdiEntityType.DocumentType, source.Key));
        }
Esempio n. 2
0
        public static Udi MapContentTypeUdi(IContentTypeComposition source)
        {
            if (source == null)
            {
                return(null);
            }

            string udiType;

            switch (source)
            {
            case IMemberType _:
                udiType = Constants.UdiEntityType.MemberType;
                break;

            case IMediaType _:
                udiType = Constants.UdiEntityType.MediaType;
                break;

            case IContentType _:
                udiType = Constants.UdiEntityType.DocumentType;
                break;

            default:
                throw new PanicException($"Source is of type {source.GetType()} which isn't supported here");
            }

            return(Udi.Create(udiType, source.Key));
        }
    /// <summary>
    ///     Gets the entity identifier of the entity.
    /// </summary>
    /// <param name="entity">The entity.</param>
    /// <returns>The entity identifier of the entity.</returns>
    public static GuidUdi GetUdi(this IContentTypeComposition entity)
    {
        if (entity == null)
        {
            throw new ArgumentNullException("entity");
        }

        string type;

        if (entity is IContentType)
        {
            type = Constants.UdiEntityType.DocumentType;
        }
        else if (entity is IMediaType)
        {
            type = Constants.UdiEntityType.MediaType;
        }
        else if (entity is IMemberType)
        {
            type = Constants.UdiEntityType.MemberType;
        }
        else
        {
            throw new NotSupportedException(string.Format(
                                                "Composition type {0} is not supported.",
                                                entity.GetType().FullName));
        }

        return(new GuidUdi(type, entity.Key).EnsureClosed());
    }