Пример #1
0
        public void Fragment2()
        {
            var factory = Factory.GetInstance <IPublishedContentTypeFactory>() as PublishedContentTypeFactory;

            IEnumerable <IPublishedPropertyType> CreatePropertyTypes(IPublishedContentType contentType)
            {
                yield return(factory.CreatePropertyType(contentType, "legend", 1004));

                yield return(factory.CreatePropertyType(contentType, "image", 1005));

                yield return(factory.CreatePropertyType(contentType, "size", 1003));
            }

            const string val1 = "boom bam";
            const int    val2 = 0;
            const int    val3 = 666;

            var guid = Guid.NewGuid();

            var ct = factory.CreateContentType(0, "alias", CreatePropertyTypes);

            var c = new ImageWithLegendModel(ct, guid, new Dictionary <string, object>
            {
                { "legend", val1 },
                { "image", val2 },
                { "size", val3 },
            }, false);

            Assert.AreEqual(val1, c.Legend);
            Assert.AreEqual(val3, c.Size);
        }
Пример #2
0
        public void Fragment2()
        {
            var factory = Factory.GetInstance <IPublishedContentTypeFactory>() as PublishedContentTypeFactory;

            var          pt1  = factory.CreatePropertyType("legend", 1004);
            var          pt2  = factory.CreatePropertyType("image", 1005);
            var          pt3  = factory.CreatePropertyType("size", 1003);
            const string val1 = "boom bam";
            const int    val2 = 0;
            const int    val3 = 666;

            var guid = Guid.NewGuid();

            var ct = factory.CreateContentType(0, "alias", new[] { pt1, pt2, pt3 });

            var c = new ImageWithLegendModel(ct, guid, new Dictionary <string, object>
            {
                { "legend", val1 },
                { "image", val2 },
                { "size", val3 },
            }, false);

            Assert.AreEqual(val1, c.Legend);
            Assert.AreEqual(val3, c.Size);
        }
Пример #3
0
    public void Fragment2()
    {
        IEnumerable <IPublishedPropertyType> CreatePropertyTypes(IPublishedContentType contentType)
        {
            yield return(PublishedContentTypeFactory.CreatePropertyType(contentType, "legend", _dataTypes[0].Id));

            yield return(PublishedContentTypeFactory.CreatePropertyType(contentType, "image", _dataTypes[0].Id));

            yield return(PublishedContentTypeFactory.CreatePropertyType(contentType, "size", _dataTypes[0].Id));
        }

        const string val1 = "boom bam";
        const int    val2 = 0;
        const int    val3 = 666;

        var guid = Guid.NewGuid();

        var ct = PublishedContentTypeFactory.CreateContentType(Guid.NewGuid(), 0, "alias", CreatePropertyTypes);

        var c = new ImageWithLegendModel(
            ct,
            guid,
            new Dictionary <string, object> {
            { "legend", val1 }, { "image", val2 }, { "size", val3 }
        },
            false);

        Assert.AreEqual(val1, c.Legend);
        Assert.AreEqual(val3, c.Size);
    }
Пример #4
0
        public void CreatedDetachedContentInConverterSample()
        {
            // the converter args
            PublishedPropertyType argPropertyType = null;
            bool argPreview = false;

            var    pt1  = new PublishedPropertyType("legend", 0, Constants.PropertyEditors.TextboxAlias);
            var    pt2  = new PublishedPropertyType("image", 0, Constants.PropertyEditors.MediaPickerAlias);
            string val1 = "";
            int    val2 = 0;

            var c = new ImageWithLegendModel(
                PublishedProperty.GetDetached(pt1.Nested(argPropertyType), val1, argPreview),
                PublishedProperty.GetDetached(pt2.Nested(argPropertyType), val2, argPreview));
        }