public void Temp() { var productService = ObjectFactoryBase.Resolve <IProductService>(); var article = productService.GetProductById(2166354); XamlConfigurationParser.Save(article); }
public ActionResult GetInitialNodeUrl(int?contentId) { var xml = XamlConfigurationParser.Save(new Content { ContentId = contentId.Value }); return(new ContentResult() { ContentType = "application/json", Content = JsonConvert.SerializeObject(xml) }); }
public void TextJsonDeserialization() { var jsonProductService = ObjectFactoryBase.Resolve <IJsonProductService>(); var defStr = File.ReadAllText("TestData\\ProductDefinition.xaml"); var json = File.ReadAllText("TestData\\ProductJson.js"); var resultArticle = jsonProductService.DeserializeProduct(json, (Content)XamlConfigurationParser.CreateFrom(defStr)); var resultXaml = XamlConfigurationParser.Save(resultArticle); var referenceXaml = File.ReadAllText("TestData\\ReferenceDto.xaml"); Assert.AreEqual(resultXaml, referenceXaml); }
public void TestXmlDeserialization() { var xmlProductService = ObjectFactoryBase.Resolve <IXmlProductService>(); var xDoc = XDocument.Load("TestData\\Product.xml"); var defStr = File.ReadAllText("TestData\\ProductDefinition.xaml"); var resultArticle = xmlProductService.DeserializeProductXml(xDoc, (Content)XamlConfigurationParser.CreateFrom(defStr)); var st = new Stopwatch(); st.Start(); xmlProductService.DeserializeProductXml(xDoc, (Content)XamlConfigurationParser.CreateFrom(defStr)); st.Stop(); Debug.WriteLine(st.Elapsed); XamlConfigurationParser.Save(resultArticle); File.ReadAllText("TestData\\ReferenceDto.xaml"); }
public ActionResult Index([Bind("content_item_id")] int?contentItemId, int?contentId) { _cacheItemWatcher.TrackChanges(); var definitionXml = contentItemId.HasValue ? _contentDefinitionService.GetDefinitionXml(contentItemId.Value) : contentId.HasValue ? XamlConfigurationParser.Save(new Content { ContentId = contentId.Value }) : string.Empty; return(View(new DefinitionEditor { ContentItemId = contentItemId, Xml = definitionXml })); }
public ActionResult SaveField(DefinitionFieldInfo defInfo) { var rootContent = (Content)XamlConfigurationParser.CreateFrom(defInfo.Xml); var savedField = _definitionEditorService.UpdateOrDeleteField(rootContent, defInfo.GetField(), defInfo.Path, !defInfo.InDefinition); string resultXml = XamlConfigurationParser.Save(rootContent); ModelState.Clear(); Field fieldForEditView = savedField ?? (Field)_definitionEditorService.GetObjectFromPath(rootContent, defInfo.Path, out _); return(new ContentResult() { ContentType = "application/json", Content = JsonConvert.SerializeObject(new DefinitionFieldInfo(fieldForEditView) { InDefinition = defInfo.InDefinition, Path = defInfo.Path, Xml = resultXml }) }); }
public string Serialize(Article product) { return(XamlConfigurationParser.Save(product)); }
public static void SaveXaml(string path, object data) { XamlConfigurationParser.Save(data); }
public ActionResult SaveContent(DefinitionContentInfo defInfo) { var rootContent = (Content)XamlConfigurationParser.CreateFrom(defInfo.Xml); var contentToSave = (Content)_definitionEditorService.GetObjectFromPath(rootContent, defInfo.Path, out var notFoundInDef); contentToSave.ContentName = defInfo.ContentName; contentToSave.CachePeriod = defInfo.CacheEnabled ? defInfo.CachePeriod : (TimeSpan?)null; if (defInfo.IsFromDictionaries) { var dictionaries = (Dictionaries)_definitionEditorService.GetParentObjectFromPath(rootContent, defInfo.Path); if (contentToSave.CachePeriod != null && notFoundInDef) { dictionaries.ContentDictionaries[contentToSave.ContentId] = contentToSave; } else if (contentToSave.CachePeriod == null && !notFoundInDef) { dictionaries.ContentDictionaries.Remove(contentToSave.ContentId); } } else { contentToSave.IsReadOnly = defInfo.IsReadOnly; contentToSave.LoadAllPlainFields = defInfo.LoadAllPlainFields; contentToSave.PublishingMode = defInfo.PublishingMode; if (notFoundInDef) { var parentExtension = (ExtensionField)_definitionEditorService.GetParentObjectFromPath(rootContent, defInfo.Path); parentExtension.ContentMapping[contentToSave.ContentId] = contentToSave; } } string resultXml = XamlConfigurationParser.Save(rootContent); var objectToEdit = _definitionEditorService.GetObjectFromPath(rootContent, defInfo.Path, out _); var isFromDictionaries = false; if (!Equals(rootContent, objectToEdit)) { isFromDictionaries = _definitionEditorService.GetParentObjectFromPath(rootContent, defInfo.Path) is Dictionaries; } var contentToEdit = (Content)objectToEdit; ModelState.Clear(); return(new ContentResult() { ContentType = "application/json", Content = JsonConvert.SerializeObject(new DefinitionContentInfo { ContentName = contentToEdit.ContentName, IsReadOnly = contentToEdit.IsReadOnly, PublishingMode = contentToEdit.PublishingMode, ContentId = contentToEdit.ContentId, LoadAllPlainFields = contentToEdit.LoadAllPlainFields, CacheEnabled = contentToEdit.CachePeriod.HasValue, CachePeriod = contentToEdit.CachePeriod ?? new TimeSpan(1, 45, 0), Path = defInfo.Path, Xml = resultXml, InDefinition = !notFoundInDef, IsFromDictionaries = isFromDictionaries, }) }); }
public static string GetXml <T>(T content) { return(XamlConfigurationParser.Save(content)); }