Beispiel #1
0
		private YamlItem CreateBaseTestItem()
		{
			var testItem = new YamlItem
			{
				Id = new Guid("a4f985d9-98b3-4b52-aaaf-4344f6e747c6"),
				DatabaseName = "master",
				ParentId = new Guid("001dd393-96c5-490b-924a-b0f25cd9efd8"),
				TemplateId = new Guid("007a464d-5b09-4d0e-8481-cb6a604a5948"),
				Path = "/sitecore/content/test"
			};

			return testItem;
		}
		public virtual IItemData ReadSerializedItem(Stream dataStream, string serializedItemId)
		{
			Assert.ArgumentNotNull(dataStream, "dataStream");

			try
			{
				using (var reader = new YamlReader(dataStream, 4096, true))
				{
					var item = new YamlItem();
					item.ReadYaml(reader);

					return new YamlItemData(item, serializedItemId, FieldFormatters.ToArray(), ParentDataStore);
				}
			}
			catch (Exception exception)
			{
				throw new YamlFormatException("Error parsing YAML " + serializedItemId, exception);
			}
		}
Beispiel #3
0
		private void DecorateSharedFieldsTestData(YamlItem item)
		{
			var field = new YamlFieldValue
			{
				Id = new Guid("9a5a2ce9-9ae3-4a21-92f0-dba3cb7ac2bf"),
				Value = "Hello world."
			};

			var field2 = new YamlFieldValue
			{
				Id = new Guid("badd9cf9-53e0-4d0c-bcc0-2d784c282f6a"),
				NameHint = "Test Field",
				Value = @"Lorem thine ipsum
<p>forsooth thy sit amet</p>
<div class=""simian"">Chimpanzee.</div>"
			};

			item.SharedFields.Add(field);
			item.SharedFields.Add(field2);
		}
Beispiel #4
0
        private void DecorateVersionsTestData(YamlItem item)
        {
            var field = new YamlFieldValue
            {
                Id = new Guid("9a5a2ce9-9ae3-4a21-92f0-dba3cb7ac2bf"),
                Value = "Hello \"silly\" world."
            };

            var field2 = new YamlFieldValue
            {
                Id = new Guid("badd9cf9-53e0-4d0c-bcc0-2d784c282f6a"),
                NameHint = "Test Field",
                Value = @"Lorem thine ipsum
            <p>forsooth thy sit amet</p>
            <div class=""simian"">Chimpanzee.</div>"
            };

            var testVersion1 = new YamlVersion();
            testVersion1.VersionNumber = 1;
            testVersion1.Fields.Add(field);
            testVersion1.Fields.Add(field2);

            var testVersion2 = new YamlVersion();
            testVersion2.VersionNumber = 2;
            testVersion2.Fields.Add(field);

            var testLanguage = new YamlLanguage();
            testLanguage.Language = "en-US";
            testLanguage.Versions.Add(testVersion1);

            var testLanguage2 = new YamlLanguage();
            testLanguage2.Language = "da-DK";
            testLanguage2.Versions.Add(testVersion1);
            testLanguage2.Versions.Add(testVersion2);

            item.Languages.Add(testLanguage);
            item.Languages.Add(testLanguage2);
        }
 public YamlItemData(YamlItem item, string serializedItemId, IFieldFormatter[] formatters, IDataStore sourceDataStore)
 {
     _item = item;
     _serializedItemId = serializedItemId;
     _formatters = formatters;
     _sourceDataStore = sourceDataStore;
 }
        public virtual void WriteSerializedItem(IItemData itemData, Stream outputStream)
        {
            Assert.ArgumentNotNull(itemData, "item");
            Assert.ArgumentNotNull(outputStream, "outputStream");

            if(_fieldFilter != null)
                itemData = new FilteredItem(itemData, _fieldFilter);

            var itemToSerialize = new YamlItem();
            itemToSerialize.LoadFrom(itemData, FieldFormatters.ToArray());

            using (var writer = new YamlWriter(outputStream, 4096, true))
            {
                itemToSerialize.WriteYaml(writer);
            }
        }