コード例 #1
0
        private string DeserializeFieldValue(string value, Item item, Guid fieldId, FieldSerializationType serializationType)
        {
            var args = new FieldSerializationPipelineArgs()
            {
                SerializationManager = this,
                Item                   = item,
                FieldId                = fieldId,
                ValueSerialized        = value,
                FieldSerializationType = serializationType
            };
            const string pipelineName = "serialization.deserializefieldvalue";

            if (CorePipelineFactory.GetPipeline(pipelineName, string.Empty) != null)
            {
                CorePipeline.Run(pipelineName, args);
            }
            return(args.ValueNormal ?? value);
        }
コード例 #2
0
        public void ShouldSerialize()
        {
            DbItem dbItem = new DbItem("it");

            using (var db = new Db()
            {
                dbItem
            })
            {
                var args = new FieldSerializationPipelineArgs()
                {
                    Item = db.GetItem(dbItem.ID),
                    SerializationManager = new SerializationManager(),
                    ValueNormal          = @"<p style=""line-height: 22px;"">From a single connected platform that also integrates with other customer-facing platforms, to a single view of the customer in a big data marketing repository, to a completely eliminating much of the complexity that has previously held marketers back, the latest version of Sitecore makes customer experience highly achievable. Learn how the latest version of Sitecore gives marketers the complete data, integrated tools, and automation capabilities to engage customers throughout an iterative lifecycle &ndash; the technology foundation absolutely necessary to win customers for life.</p>
<p>For further information, please go to the <a href=""https://doc.sitecore.net/"" target=""_blank"" title=""Sitecore Documentation site"">Sitecore Documentation site</a></p>",
                    FieldId      = Guid.NewGuid(),
                    FieldTypeKey = "Rich Text"
                };
                new Html().Process(args);
                args.ValueSerialized.ShouldBeEquivalentTo(@"
<p style=""line-height: 22px;"">
      From a single connected platform that also integrates with
      other customer-facing platforms, to a single view of the
      customer in a big data marketing repository, to a completely
      eliminating much of the complexity that has previously held
      marketers back, the latest version of Sitecore makes customer
      experience highly achievable. Learn how the latest version of
      Sitecore gives marketers the complete data, integrated tools,
      and automation capabilities to engage customers throughout an
      iterative lifecycle &ndash; the technology foundation
      absolutely necessary to win customers for life.
    </p>
    <p>
      For further information, please go to the <a href=
      ""https://doc.sitecore.net/"" target=""_blank"" title=
      ""Sitecore Documentation site"">Sitecore Documentation site</a>
    </p>
");
                args.FieldSerializationType.ShouldBeEquivalentTo(FieldSerializationType.Html);
            }
        }
コード例 #3
0
        public void ShouldDeserialize()
        {
            DbItem dbItem = new DbItem("it");

            using (var db = new Db()
            {
                dbItem
            })
            {
                var args = new FieldSerializationPipelineArgs()
                {
                    FieldSerializationType = FieldSerializationType.IdList,
                    Item = db.GetItem(dbItem.ID),
                    SerializationManager = new SerializationManager(),
                    ValueSerialized      = @"
f11cd74b-099b-48c6-aaed-44927164e9e7
62e71efe-bcc8-48dc-9868-4dd2fdbfc2dc
",
                    FieldId = Guid.NewGuid()
                };
                new IdList().Process(args);
                args.ValueNormal.ShouldBeEquivalentTo("{F11CD74B-099B-48C6-AAED-44927164E9E7}|{62E71EFE-BCC8-48DC-9868-4DD2FDBFC2DC}");
            }
        }
コード例 #4
0
        protected override void DoProcess(FieldSerializationPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (args.ValueNormal != null || FieldSerializationType.IdList != args.FieldSerializationType)
            {
                return;
            }

            StringBuilder valueNormal  = new StringBuilder();
            string        processValue = Regex.Replace(args.ValueSerialized, @"\s+", string.Empty);

            while (!string.IsNullOrWhiteSpace(processValue))
            {
                if (valueNormal.Length > 0)
                {
                    valueNormal.Append('|');
                }
                valueNormal.Append(ID.Parse(Guid.Parse(processValue.Substring(0, guidLength))));
                processValue = processValue.Substring(guidLength);
            }

            args.ValueNormal = valueNormal.ToString();
        }