public void CreateClass(string name) { ILoggingService loggingService = engine.GetService<ILoggingService>(); if (loggingService != null) loggingService.LogInfo(this, String.Format("Creating class {0} in NPersist mapping file.", name)); //Add the class to the npersist xml file IClassMap classMap = new ClassMap(name); classMap.DomainMap = GetDomainMap(); }
protected virtual void DeserializeClassMap(IDomainMap domainMap, XmlNode xmlClass) { IClassMap classMap = new ClassMap(); XmlNodeList xmlProps; string str; string[] arr; classMap.DomainMap = domainMap; if (!(xmlClass.Attributes["name"] == null)) { classMap.Name = xmlClass.Attributes["name"].Value; } if (!(xmlClass.Attributes["type"] == null)) { classMap.ClassType = (ClassType) Enum.Parse(typeof (ClassType), xmlClass.Attributes["type"].Value); } if (!(xmlClass.Attributes["assembly"] == null)) { classMap.AssemblyName = xmlClass.Attributes["assembly"].Value; } if (!(xmlClass.Attributes["load-span"] == null)) { classMap.LoadSpan = xmlClass.Attributes["load-span"].Value; } if (!(xmlClass.Attributes["validate"] == null)) { classMap.ValidateMethod = xmlClass.Attributes["validate"].Value; } if (!(xmlClass.Attributes["source-class"] == null)) { classMap.SourceClass = xmlClass.Attributes["source-class"].Value; } if (!(xmlClass.Attributes["source"] == null)) { classMap.Source = xmlClass.Attributes["source"].Value; } if (!(xmlClass.Attributes["doc-source"] == null)) { classMap.DocSource = xmlClass.Attributes["doc-source"].Value; } if (!(xmlClass.Attributes["table"] == null)) { classMap.Table = xmlClass.Attributes["table"].Value; } if (!(xmlClass.Attributes["doc-element"] == null)) { classMap.DocElement = xmlClass.Attributes["doc-element"].Value; } if (!(xmlClass.Attributes["doc-root"] == null)) { classMap.DocRoot = xmlClass.Attributes["doc-root"].Value; } if (!(xmlClass.Attributes["doc-mode"] == null)) { classMap.DocClassMapMode = (DocClassMapMode) Enum.Parse(typeof (DocClassMapMode), xmlClass.Attributes["doc-mode"].Value); } if (!(xmlClass.Attributes["type-column"] == null)) { classMap.TypeColumn = xmlClass.Attributes["type-column"].Value; } if (!(xmlClass.Attributes["type-value"] == null)) { classMap.TypeValue = xmlClass.Attributes["type-value"].Value; } if (!(xmlClass.Attributes["doc-parent"] == null)) { classMap.DocParentProperty = xmlClass.Attributes["doc-parent"].Value; } if (!(xmlClass.Attributes["read-only"] == null)) { classMap.IsReadOnly = ParseBool(xmlClass.Attributes["read-only"].Value); } if (!(xmlClass.Attributes["abstract"] == null)) { classMap.IsAbstract = ParseBool(xmlClass.Attributes["abstract"].Value); } if (!(xmlClass.Attributes["inherits"] == null)) { classMap.InheritsClass = xmlClass.Attributes["inherits"].Value; } if (!(xmlClass.Attributes["id-separator"] == null)) { classMap.IdentitySeparator = xmlClass.Attributes["id-separator"].Value; } if (!(xmlClass.Attributes["key-separator"] == null)) { classMap.KeySeparator = xmlClass.Attributes["key-separator"].Value; } if (!(xmlClass.Attributes["inheritance"] == null)) { classMap.InheritanceType = (InheritanceType) Enum.Parse(typeof (InheritanceType), xmlClass.Attributes["inheritance"].Value); } if (!(xmlClass.Attributes["base"] == null)) { classMap.InheritsTransientClass = xmlClass.Attributes["base"].Value; } if (!(xmlClass.Attributes["ttl"] == null)) { classMap.TimeToLive = Int32.Parse(xmlClass.Attributes["ttl"].Value); } if (!(xmlClass.Attributes["ttl-behavior"] == null)) { classMap.TimeToLiveBehavior = (TimeToLiveBehavior) Enum.Parse(typeof (TimeToLiveBehavior), xmlClass.Attributes["ttl-behavior"].Value); } if (!(xmlClass.Attributes["load"] == null)) { classMap.LoadBehavior = (LoadBehavior) Enum.Parse(typeof (LoadBehavior), xmlClass.Attributes["load"].Value); } if (!(xmlClass.Attributes["implements"] == null)) { str = xmlClass.Attributes["implements"].Value; if (str.Length > 0) { arr = str.Split(','); foreach (string iStr in arr) { str = iStr.Trim(); if (str.Length > 0) { classMap.ImplementsInterfaces.Add(str); } } } } if (!(xmlClass.Attributes["imports"] == null)) { str = xmlClass.Attributes["imports"].Value; if (str.Length > 0) { arr = str.Split(','); foreach (string iStr in arr) { str = iStr.Trim(); if (str.Length > 0) { classMap.ImportsNamespaces.Add(str); } } } } if (!(xmlClass.Attributes["merge"] == null)) { classMap.MergeBehavior = (MergeBehaviorType) Enum.Parse(typeof (MergeBehaviorType), xmlClass.Attributes["merge"].Value); } if (!(xmlClass.Attributes["refresh"] == null)) { classMap.RefreshBehavior = (RefreshBehaviorType) Enum.Parse(typeof (RefreshBehaviorType), xmlClass.Attributes["refresh"].Value); } if (!(xmlClass.Attributes["validation"] == null)) { classMap.ValidationMode = (ValidationMode) Enum.Parse(typeof (ValidationMode), xmlClass.Attributes["validation"].Value); } if (!(xmlClass.Attributes["optimistic-delete"] == null)) { classMap.DeleteOptimisticConcurrencyBehavior = (OptimisticConcurrencyBehaviorType) Enum.Parse(typeof (OptimisticConcurrencyBehaviorType), xmlClass.Attributes["optimistic-delete"].Value); } if (!(xmlClass.Attributes["optimistic-update"] == null)) { classMap.UpdateOptimisticConcurrencyBehavior = (OptimisticConcurrencyBehaviorType) Enum.Parse(typeof (OptimisticConcurrencyBehaviorType), xmlClass.Attributes["optimistic-update"].Value); } ArrayList metaData = classMap.MetaData; DeserializeMetaData(xmlClass, ref metaData); xmlProps = xmlClass.SelectNodes("property"); foreach (XmlNode xmlProp in xmlProps) { DeserializePropertyMap(classMap, xmlProp); } XmlNodeList xmlCodeMaps = xmlClass.SelectNodes("code"); foreach (XmlNode xmlCodeMap in xmlCodeMaps) { DeserializeCodeMap(classMap, xmlCodeMap); } XmlNodeList xmlEnumValueMaps = xmlClass.SelectNodes("enum-value"); foreach (XmlNode xmlEnumValueMap in xmlEnumValueMaps) { DeserializeEnumValueMap(classMap, xmlEnumValueMap); } }