예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UmbracoType{T}"/> class.
 /// </summary>
 public UmbracoType()
 {
     _properties         = new List <AbstractPropertyConfiguration>();
     _configuration      = new UmbracoTypeConfiguration();
     _configuration.Type = typeof(T);
     _configuration.ConstructorMethods = Mapper.Utilities.CreateConstructorDelegates(_configuration.Type);
 }
예제 #2
0
        public void Configure_ConfigurationIsOfCorrectType_NoExceptionThrown()
        {
            //Assign
            var attr   = new UmbracoTypeAttribute();
            var config = new UmbracoTypeConfiguration();
            var type   = typeof(StubClass);

            //Act
            attr.Configure(type, config);

            //Assert
            config.Type.ShouldBeEquivalentTo(type);
        }
예제 #3
0
        /// <summary>
        /// Configures the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="config">The config.</param>
        /// <exception cref="ConfigurationException">Type configuration is not of type {0}.Formatted(typeof(UmbracoTypeConfiguration).FullName)</exception>
        public override AbstractTypeConfiguration Configure(Type type)
        {
            var umbConfig = new UmbracoTypeConfiguration();

            if (umbConfig == null)
                throw new ConfigurationException(
                    "Type configuration is not of type {0}".Formatted(typeof(UmbracoTypeConfiguration).FullName));

            umbConfig.ContentTypeAlias = ContentTypeAlias;
            umbConfig.CodeFirst = CodeFirst;
            umbConfig.ContentTypeName = ContentTypeName;

            base.Configure(type, umbConfig);

            return umbConfig;
        }
예제 #4
0
        public void Configure_AttributeHasContentTypeAlias_ContentTypeAliasSetOnConfig()
        {
            //Assign
            var attr   = new UmbracoTypeAttribute();
            var config = new UmbracoTypeConfiguration();
            var type   = typeof(StubClass);

            var contentTypeAliasExpected = "test";

            attr.ContentTypeAlias = contentTypeAliasExpected;

            //Act
            attr.Configure(type, config);

            //Assert
            config.Type.ShouldBeEquivalentTo(type);
            config.ContentTypeAlias.ShouldBeEquivalentTo(contentTypeAliasExpected);
        }
예제 #5
0
        /// <summary>
        /// Writes to item.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="target">The target.</param>
        /// <param name="content">The content.</param>
        /// <param name="config">The config.</param>
        public void WriteToItem <T>(T target, IContent content, UmbracoTypeConfiguration config = null)
        {
            if (config == null)
            {
                config = GlassContext.GetTypeConfiguration <UmbracoTypeConfiguration>(target);
            }

            var savingContext = new UmbracoTypeSavingContext
            {
                Config  = config,
                Content = content,
                Object  = target
            };

            //ME-an item with no versions should be null

            SaveObject(savingContext);
        }
        /// <summary>
        /// Configures the specified type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="config">The config.</param>
        /// <exception cref="ConfigurationException">Type configuration is not of type {0}.Formatted(typeof(UmbracoTypeConfiguration).FullName)</exception>
        public override AbstractTypeConfiguration Configure(Type type)
        {
            var umbConfig = new UmbracoTypeConfiguration();

            if (umbConfig == null)
            {
                throw new ConfigurationException(
                          "Type configuration is not of type {0}".Formatted(typeof(UmbracoTypeConfiguration).FullName));
            }

            umbConfig.ContentTypeAlias = ContentTypeAlias;
            umbConfig.CodeFirst        = CodeFirst;
            umbConfig.ContentTypeName  = ContentTypeName;

            base.Configure(type, umbConfig);

            return(umbConfig);
        }