Inheritance: ContentTypeRegistration
Example #1
0
        public bool TryGetMediaType(Type type, out MediaTypeRegistration registration)
        {
            ContentTypeRegistration reg;

            if (ContentTypeRegister.TryGetContentType(type, out reg))
            {
                registration = reg as MediaTypeRegistration;
                return(registration != null);
            }
            else
            {
                registration = null;
                return(false);
            }
        }
Example #2
0
        protected override ContentTypeRegistration CreateRegistration(Type type)
        {
            var mediaTypeAttribute = type.GetCodeFirstAttribute <MediaTypeAttribute>();

            if (mediaTypeAttribute != null)
            {
                var props = new List <PropertyRegistration>();
                var tabs  = new List <TabRegistration>();
                var comps = new List <ContentTypeCompositionRegistration>();
                MediaTypeRegistration registration = new MediaTypeRegistration(
                    props,
                    tabs,
                    comps,
                    mediaTypeAttribute.Alias,
                    mediaTypeAttribute.Name,
                    type,
                    mediaTypeAttribute);
                return(registration);
            }
            else
            {
                throw new CodeFirstException("The specified type does not have a MediaTypeAttribute. Type: " + type.Name);
            }
        }
Example #3
0
 public bool TryGetMediaType <T>(out MediaTypeRegistration registration) where T : MediaTypeBase
 {
     return(TryGetMediaType(typeof(T), out registration));
 }