private IPublishedContent GetContent(bool createChildren, int indexVals) { var dataTypeService = new TestObjects.TestDataTypeService( new DataType(new VoidEditor(Mock.Of <ILogger>())) { Id = 1 }); var factory = new PublishedContentTypeFactory(Mock.Of <IPublishedModelFactory>(), new PropertyValueConverterCollection(Array.Empty <IPropertyValueConverter>()), dataTypeService); var contentTypeAlias = createChildren ? "Parent" : "Child"; var contentType = new PublishedContentType(22, contentTypeAlias, PublishedItemType.Content, Enumerable.Empty <string>(), Enumerable.Empty <PublishedPropertyType>(), ContentVariation.Nothing); var d = new SolidPublishedContent(contentType) { CreateDate = DateTime.Now, CreatorId = 1, CreatorName = "Shannon", Id = 3, SortOrder = 4, TemplateId = 5, UpdateDate = DateTime.Now, Path = "-1,3", UrlSegment = "home-page", Name = "Page" + Guid.NewGuid(), Version = Guid.NewGuid(), WriterId = 1, WriterName = "Shannon", Parent = null, Level = 1, Children = new List <IPublishedContent>() }; d.Properties = new Collection <IPublishedProperty>(new List <IPublishedProperty> { new RawValueProperty(factory.CreatePropertyType("property1", 1), d, "value" + indexVals), new RawValueProperty(factory.CreatePropertyType("property2", 1), d, "value" + (indexVals + 1)) }); if (createChildren) { d.Children = new List <IPublishedContent>() { GetContent(false, indexVals + 3), GetContent(false, indexVals + 6), GetContent(false, indexVals + 9) }; } if (!createChildren) { //create additional columns, used to test the different columns for child nodes ((Collection <IPublishedProperty>)d.Properties).Add( new RawValueProperty(factory.CreatePropertyType("property4", 1), d, "value" + (indexVals + 2))); } else { ((Collection <IPublishedProperty>)d.Properties).Add( new RawValueProperty(factory.CreatePropertyType("property3", 1), d, "value" + (indexVals + 2))); } return(d); }
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); }
public void Add(SolidPublishedContent content) { _content[content.Id] = content.CreateModel(); }
internal override void PopulateCache(PublishedContentTypeFactory factory, SolidPublishedContentCache cache) { IEnumerable <IPublishedPropertyType> CreatePropertyTypes(IPublishedContentType contentType) { yield return(factory.CreatePropertyType(contentType, "prop1", 1)); } var contentType1 = factory.CreateContentType(Guid.NewGuid(), 1, "ContentType1", Enumerable.Empty <string>(), CreatePropertyTypes); var contentType2 = factory.CreateContentType(Guid.NewGuid(), 2, "ContentType2", Enumerable.Empty <string>(), CreatePropertyTypes); var contentType2Sub = factory.CreateContentType(Guid.NewGuid(), 3, "ContentType2Sub", Enumerable.Empty <string>(), CreatePropertyTypes); var content = new SolidPublishedContent(contentType1) { Id = 1, SortOrder = 0, Name = "Content 1", UrlSegment = "content-1", Path = "/1", Level = 1, Url = "/content-1", ParentId = -1, ChildIds = new int[] { }, Properties = new Collection <IPublishedProperty> { new SolidPublishedProperty { Alias = "prop1", SolidHasValue = true, SolidValue = 1234, SolidSourceValue = "1234" } } }; cache.Add(content); content = new SolidPublishedContent(contentType2) { Id = 2, SortOrder = 1, Name = "Content 2", UrlSegment = "content-2", Path = "/2", Level = 1, Url = "/content-2", ParentId = -1, ChildIds = new int[] { }, Properties = new Collection <IPublishedProperty> { new SolidPublishedProperty { Alias = "prop1", SolidHasValue = true, SolidValue = 1234, SolidSourceValue = "1234" } } }; cache.Add(content); content = new SolidPublishedContent(contentType2Sub) { Id = 3, SortOrder = 2, Name = "Content 2Sub", UrlSegment = "content-2sub", Path = "/3", Level = 1, Url = "/content-2sub", ParentId = -1, ChildIds = new int[] { }, Properties = new Collection <IPublishedProperty> { new SolidPublishedProperty { Alias = "prop1", SolidHasValue = true, SolidValue = 1234, SolidSourceValue = "1234" } } }; cache.Add(content); }
public void Add(SolidPublishedContent content) { _content[content.Id] = content.CreateModel(Current.PublishedModelFactory); }
public void Add(SolidPublishedContent content) { _content[content.Id] = PublishedContentModelFactory.CreateModel(content); }
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); }