private static Dictionary Create(Type type,string aspect){ var dictionary = new Dictionary(new DictionaryNode(ApplicationNodeWrapper.NodeName), Schema.GetCommonSchema()); new ApplicationNodeWrapper(dictionary).Load(type); var dictionary1 = new Dictionary(Schema.GetCommonSchema()); dictionary1.AddAspect(aspect, dictionary.RootNode); return dictionary1; }
public override object ConvertFromStorageType(object value){ if (!(string.IsNullOrEmpty(value as string))) { var settings = new XmlReaderSettings{ConformanceLevel = ConformanceLevel.Auto}; var reader = XmlReader.Create(new StringReader((string) value), settings); var serializableDictionary = new SerializableDictionary<string, string>(); serializableDictionary.ReadXml(reader); var schema = new Schema(new DictionaryXmlReader().ReadFromString(serializableDictionary["Schema"].Replace(":",""))); var commonSchema = Schema.GetCommonSchema(); commonSchema.CombineWith(schema); var helper = new DictionaryHelper(); var aspects = serializableDictionary["aspects"].Split(',').ToList(); string aspectFromXml = helper.GetAspectFromXml(aspects, serializableDictionary["DefaultAspect"]); var dictionary = new Dictionary(new DictionaryXmlReader().ReadFromString(aspectFromXml), commonSchema); foreach (var aspectValue in aspects.Where(s => !string.IsNullOrEmpty(s))){ string xml = serializableDictionary[aspectValue]; if (!(string.IsNullOrEmpty(xml))) dictionary.AddAspect(aspectValue, new DictionaryXmlReader().ReadFromString(xml)); } return dictionary; } return null; }
private Dictionary loadFromPath(Dictionary dictionary) { foreach (var s in GetModelPaths().Where(s => Path.GetFileName(s).ToLower().StartsWith("model") && s.IndexOf(".User") == -1)) { var dictionaryNode = new DictionaryXmlReader().ReadFromFile(s); string replace = s.Replace(".xafml", ""); string aspect = DictionaryAttribute.DefaultLanguage; if (replace.IndexOf("_") > -1) aspect = replace.Substring(replace.IndexOf("_") + 1); dictionary.AddAspect(aspect, dictionaryNode); } SaveDifference(dictionary); return dictionary; }
protected override Dictionary LoadDifferenceCore(Schema schema) { var dictionary = new Dictionary(schema); foreach (var aspect in Application.Model.Aspects){ dictionary.AddAspect(aspect, new DictionaryNode("Application")); } var modelDifferenceObjects = GetActiveDifferenceObjects().ToList(); if (modelDifferenceObjects.Count() == 0){ SaveDifference(dictionary); return dictionary; } return CombineWithActiveDifferenceObjects(modelDifferenceObjects); }
private void setCurrentAspect(Dictionary dictionary) { dictionary.AddAspect(CurrentLanguage,new DictionaryNode(ApplicationNodeWrapper.NodeName)); dictionary.CurrentAspectProvider.CurrentAspect = CurrentLanguage; }
public void Application_Model_With_More_Than_one_Aspect_And_Spaces_Between_Attribute_Values_Can_Be_Saved(){ const string defaultS = "ProtectedContentText=\"Protected Content\" PreferredLanguage=\"el\" VersionFormat=\"Version {0}.{1}.{2}\" Title=\"Solution1\" Logo=\"ExpressAppLogo\" Company=\"Endligh\" WebSite=\"1\" CanClose=\"True\" "; var dictionary1 = new Dictionary(new DictionaryXmlReader().ReadFromString("<Application "+defaultS + "><BOModel><Class Name=\"MyClass2\" Caption=\"Default\"></Class></BOModel></Application>"), Schema.GetCommonSchema()); Dictionary dictionary = dictionary1.Clone(); dictionary1.AddAspect("el", new DictionaryXmlReader().ReadFromString("<Application Company=\"Greek\"></Application>")); var application = Isolate.Fake.Instance<DifferenceObject>(Members.CallOriginal, ConstructorWillBe.Called, Session.DefaultSession); application.Model=dictionary1; application.Save(); application.Reload(); var dictionaryXmlWriter = new DictionaryXmlWriter(); Assert.AreEqual(dictionary.RootNode.ToXml(), new DictionaryXmlReader().ReadFromString(dictionaryXmlWriter.GetAspectXML(DictionaryAttribute.DefaultLanguage, application.Model.RootNode)).ToXml()); }
public void ApplicationModel_That_Has_As_First_Aspect_Non_Default_And_Has_More_Than_One_Can_Be_Saved() { var dictionary1 = new Dictionary(new DictionaryXmlReader().ReadFromString("<Application><BOModel><Class Name=\"MyClass\" ></Class><Class Name=\"MyClass2\" Caption=\"Default\"></Class></BOModel></Application>"), Schema.GetCommonSchema()); var dictionary = dictionary1.Clone(); var elDict = new Dictionary(new DictionaryXmlReader().ReadFromString("<Application><BOModel><Class Name=\"MyClass\" Caption=\"elDefault\" AttributeWithOnlyAspect=\"something\"></Class><Class Name=\"MyClass2\" Caption=\"Default\"></Class></BOModel></Application>"), Schema.GetCommonSchema()); dictionary.AddAspect("el", elDict.RootNode); var defDict = new Dictionary(new DictionaryXmlReader().ReadFromString("<Application><BOModel><Class Name=\"MyClass\" Caption=\"Default\" ></Class><Class Name=\"MyClass2\" Caption=\"Default\"></Class></BOModel></Application>"), Schema.GetCommonSchema()); dictionary.AddAspect(DictionaryAttribute.DefaultLanguage, defDict.RootNode); var application = Isolate.Fake.Instance<DifferenceObject>(Members.CallOriginal, ConstructorWillBe.Called, Session.DefaultSession); application.Model=dictionary; application.Save(); application.Reload(); dictionary1.AddAspect(DictionaryAttribute.DefaultLanguage,defDict.RootNode); Assert.AreEqual(dictionary1.RootNode.ToXml(), new DictionaryXmlReader().ReadFromString(new DictionaryXmlWriter().GetAspectXML(DictionaryAttribute.DefaultLanguage, application.Model.RootNode)).ToXml()); }
public void Model_Should_be_Created_By_Combining_Persistent_ApplicationModel_DefaultLanguage_And_PrefferedLanguage_With_CurrentObject_DefaultLang_And_PrefferedLanguage(){ var persistentAppDictionary = DefaultDictionary.Clone(); persistentAppDictionary.AddAspect("el",elDictionary.Clone().RootNode); const string s = "<Application><BOModel><Class Name=\"MyClass\" Caption=\"el2\"></Class></BOModel></Application>"; var diffObjectDictionary = new Dictionary(new DictionaryXmlReader().ReadFromString(s), Schema.GetCommonSchema()); diffObjectDictionary.AddAspect("el", new DictionaryXmlReader().ReadFromString("<Application><BOModel><Class Name=\"MyClass\" Caption=\"el3\"></Class></BOModel></Application>")); var editor = new ModelEditorPropertyEditor(null, null) { CurrentObject =new ModelDifferenceObject( Session.DefaultSession) { Model = diffObjectDictionary, PersistentApplication = new PersistentApplication(Session.DefaultSession) { Model = persistentAppDictionary }, PreferredAspect = "el" } }; // var dictionary = editor.GetModel(); // dictionary.CurrentAspectProvider.CurrentAspect = "el"; // Assert.AreEqual("el3", new ApplicationNodeWrapper(dictionary).BOModel.FindClassByName("MyClass").Caption); throw new NotImplementedException(); }