Beispiel #1
0
        internal override void PopulateCache(PublishedContentTypeFactory factory, SolidPublishedContentCache cache)
        {
            var prop1Type    = factory.CreatePropertyType("prop1", 1, variations: ContentVariation.Culture);
            var welcomeType  = factory.CreatePropertyType("welcomeText", 1, variations: ContentVariation.Culture);
            var welcome2Type = factory.CreatePropertyType("welcomeText2", 1, variations: ContentVariation.Culture);
            var nopropType   = factory.CreatePropertyType("noprop", 1, variations: ContentVariation.Culture);

            IEnumerable <IPublishedPropertyType> CreatePropertyTypes1(IPublishedContentType contentType)
            {
                yield return(factory.CreatePropertyType(contentType, "prop1", 1, variations: ContentVariation.Culture));

                yield return(factory.CreatePropertyType(contentType, "welcomeText", 1, variations: ContentVariation.Culture));

                yield return(factory.CreatePropertyType(contentType, "welcomeText2", 1, variations: ContentVariation.Culture));

                yield return(factory.CreatePropertyType(contentType, "noprop", 1, variations: ContentVariation.Culture));
            }

            var contentType1 = factory.CreateContentType(Guid.NewGuid(), 1, "ContentType1", Enumerable.Empty <string>(), CreatePropertyTypes1);

            IEnumerable <IPublishedPropertyType> CreatePropertyTypes2(IPublishedContentType contentType)
            {
                yield return(factory.CreatePropertyType(contentType, "prop3", 1, variations: ContentVariation.Culture));
            }

            var contentType2 = factory.CreateContentType(Guid.NewGuid(), 2, "contentType2", Enumerable.Empty <string>(), CreatePropertyTypes2);

            var prop1 = new SolidPublishedPropertyWithLanguageVariants
            {
                Alias        = "welcomeText",
                PropertyType = welcomeType
            };

            prop1.SetSourceValue("en-US", "Welcome", true);
            prop1.SetValue("en-US", "Welcome", true);
            prop1.SetSourceValue("de", "Willkommen");
            prop1.SetValue("de", "Willkommen");
            prop1.SetSourceValue("nl", "Welkom");
            prop1.SetValue("nl", "Welkom");

            var prop2 = new SolidPublishedPropertyWithLanguageVariants
            {
                Alias        = "welcomeText2",
                PropertyType = welcome2Type
            };

            prop2.SetSourceValue("en-US", "Welcome", true);
            prop2.SetValue("en-US", "Welcome", true);

            var prop3 = new SolidPublishedPropertyWithLanguageVariants
            {
                Alias        = "welcomeText",
                PropertyType = welcomeType
            };

            prop3.SetSourceValue("en-US", "Welcome", true);
            prop3.SetValue("en-US", "Welcome", true);

            var noprop = new SolidPublishedProperty
            {
                Alias        = "noprop",
                PropertyType = nopropType
            };

            noprop.SolidHasValue = false; // has no value
            noprop.SolidValue    = "xxx"; // but returns something

            var item1 = new SolidPublishedContent(contentType1)
            {
                Id         = 1,
                SortOrder  = 0,
                Name       = "Content 1",
                UrlSegment = "content-1",
                Path       = "/1",
                Level      = 1,
                Url        = "/content-1",
                ParentId   = -1,
                ChildIds   = new[] { 2 },
                Properties = new Collection <IPublishedProperty>
                {
                    prop1, prop2, noprop
                }
            };

            var item2 = new SolidPublishedContent(contentType1)
            {
                Id         = 2,
                SortOrder  = 0,
                Name       = "Content 2",
                UrlSegment = "content-2",
                Path       = "/1/2",
                Level      = 2,
                Url        = "/content-1/content-2",
                ParentId   = 1,
                ChildIds   = new int[] { 3 },
                Properties = new Collection <IPublishedProperty>
                {
                    prop3
                }
            };

            var prop4 = new SolidPublishedPropertyWithLanguageVariants
            {
                Alias        = "prop3",
                PropertyType = contentType2.GetPropertyType("prop3")
            };

            prop4.SetSourceValue("en-US", "Oxxo", true);
            prop4.SetValue("en-US", "Oxxo", true);

            var item3 = new SolidPublishedContent(contentType2)
            {
                Id         = 3,
                SortOrder  = 0,
                Name       = "Content 3",
                UrlSegment = "content-3",
                Path       = "/1/2/3",
                Level      = 3,
                Url        = "/content-1/content-2/content-3",
                ParentId   = 2,
                ChildIds   = new int[] { },
                Properties = new Collection <IPublishedProperty>
                {
                    prop4
                }
            };

            item1.Children = new List <IPublishedContent> {
                item2
            };
            item2.Parent = item1;

            item2.Children = new List <IPublishedContent> {
                item3
            };
            item3.Parent = item2;

            cache.Add(item1);
            cache.Add(item2);
            cache.Add(item3);
        }
Beispiel #2
0
        internal override void PopulateCache(PublishedContentTypeFactory factory, SolidPublishedContentCache cache)
        {
            var prop1Type    = factory.CreatePropertyType("prop1", 1);
            var welcomeType  = factory.CreatePropertyType("welcomeText", 1);
            var welcome2Type = factory.CreatePropertyType("welcomeText2", 1);
            var props        = new[]
            {
                prop1Type,
                welcomeType,
                welcome2Type,
            };
            var contentType1 = factory.CreateContentType(1, "ContentType1", Enumerable.Empty <string>(), props);

            var prop1 = new SolidPublishedPropertyWithLanguageVariants
            {
                Alias        = "welcomeText",
                PropertyType = welcomeType
            };

            prop1.SetSourceValue("en-US", "Welcome", true);
            prop1.SetValue("en-US", "Welcome", true);
            prop1.SetSourceValue("de", "Willkommen");
            prop1.SetValue("de", "Willkommen");
            prop1.SetSourceValue("nl", "Welkom");
            prop1.SetValue("nl", "Welkom");

            var prop2 = new SolidPublishedPropertyWithLanguageVariants
            {
                Alias        = "welcomeText2",
                PropertyType = welcome2Type
            };

            prop2.SetSourceValue("en-US", "Welcome", true);
            prop2.SetValue("en-US", "Welcome", true);

            var prop3 = new SolidPublishedPropertyWithLanguageVariants
            {
                Alias        = "welcomeText",
                PropertyType = welcomeType
            };

            prop3.SetSourceValue("en-US", "Welcome", true);
            prop3.SetValue("en-US", "Welcome", true);

            var item1 = new SolidPublishedContent(contentType1)
            {
                Id         = 1,
                SortOrder  = 0,
                Name       = "Content 1",
                UrlSegment = "content-1",
                Path       = "/1",
                Level      = 1,
                Url        = "/content-1",
                ParentId   = -1,
                ChildIds   = new[] { 2 },
                Properties = new Collection <IPublishedProperty>
                {
                    prop1, prop2
                }
            };

            var item2 = new SolidPublishedContent(contentType1)
            {
                Id         = 2,
                SortOrder  = 0,
                Name       = "Content 2",
                UrlSegment = "content-2",
                Path       = "/1/2",
                Level      = 2,
                Url        = "/content-1/content-2",
                ParentId   = 1,
                ChildIds   = new int[] { },
                Properties = new Collection <IPublishedProperty>
                {
                    prop3
                }
            };

            item1.Children = new List <IPublishedContent> {
                item2
            };
            item2.Parent = item1;

            cache.Add(item1);
            cache.Add(item2);
        }