Пример #1
0
        protected virtual void EnsureSerializationSupport(IEnumerable <ModelNode> models)
        {
            foreach (var model in models)
            {
                var xml = SPMeta2Model.ToXML(model);
                var xmlModelInstance = SPMeta2Model.FromXML(xml);

                var json = SPMeta2Model.ToJSON(model);
                var jsonModelInstance = SPMeta2Model.FromJSON(json);
            }
        }
        public virtual List <ModelNode> GetSerializedAndRestoredModels(IEnumerable <ModelNode> models)
        {
            var result = new List <ModelNode>();

            foreach (var model in models)
            {
                var xml = SPMeta2Model.ToXML(model);
                var xmlModelInstance = SPMeta2Model.FromXML(xml);

                var json = SPMeta2Model.ToJSON(model);
                var jsonModelInstance = SPMeta2Model.FromJSON(json);

                result.Add(xmlModelInstance);
                result.Add(jsonModelInstance);
            }

            return(result);
        }
Пример #3
0
        public void CanSerialize_SiteModelToJSONAndBack()
        {
            var orginalModel = SPMeta2Model.NewSiteModel(site =>
            {
            });

            TraceUtils.WithScope(trace =>
            {
                var modelString = SPMeta2Model.ToJSON(orginalModel);
                Assert.IsFalse(string.IsNullOrEmpty(modelString));

                trace.WriteLine("JSON");
                trace.WriteLine(modelString);

                var deserializedModel = SPMeta2Model.FromJSON(modelString);
                Assert.IsNotNull(deserializedModel);
            });
        }