public void Commit() { if (domainMap != null) { ILoggingService loggingService = engine.GetService<ILoggingService>(); if (loggingService != null) loggingService.LogInfo(this, "Saving NPersist mapping file."); string path = @"C:\Test\test.xml"; IMapSerializer serialiser = new DefaultMapSerializer(); domainMap.Save(path, serialiser); domainMap = null; } }
public IContext GetContext() { if (context == null) { ILoggingService loggingService = engine.GetService<ILoggingService>(); if (loggingService != null) loggingService.LogInfo(this, "Creating NPersist context"); IConfigurationService configurationService = engine.GetService<IConfigurationService>(); string path = configurationService.SchemaFilePath; IMapSerializer serialier = new DefaultMapSerializer(); IDomainMap domainMap = DomainMap.Load(path, serialier, false, false); context = new Context(domainMap); GenerateAssembly(context); context.SetConnectionString(configurationService.ConnectionString); context.AutoTransactions = false; } return context; }
protected static IMapSerializer GetMapSerializerFromXml(string xml) { IMapSerializer mapSerializer = null; XmlDocument xmlDoc = new XmlDocument(); XmlNode xmlDom; if (xml.Length > 0) { xmlDoc.LoadXml(xml); xmlDom = xmlDoc.SelectSingleNode("domain"); if (xmlDom != null) { if (!(xmlDom.Attributes["serializer"] == null)) { if (xmlDom.Attributes["serializer"].Value.ToLower(CultureInfo.InvariantCulture) == "dotnet") { mapSerializer = null; } else { mapSerializer = new DefaultMapSerializer(); } } else { mapSerializer = new DefaultMapSerializer(); } } else { xmlDom = xmlDoc.SelectSingleNode("DomainMap"); if (xmlDom != null) { mapSerializer = null; } else { mapSerializer = null; } } } return mapSerializer; }
public static IDomainMap LoadFromXml(string xml, IMapSerializer mapSerializer,bool useCache,bool validate) { IDomainMap domainMap; if (mapSerializer == null) { mapSerializer = new DefaultMapSerializer(); // GetMapSerializerFromXml(xml); } if (mapSerializer != null) { try { domainMap = mapSerializer.LoadFromXml(xml); } catch (Exception ex) { throw new MappingException("Failed loading NPersist XML mapping file! " + ex.Message, ex); // do not localize } } else { try { Stream xmlStream = new MemoryStream(ASCIIEncoding.Default.GetBytes(xml)); XmlSerializer mySerializer = new XmlSerializer(typeof (DomainMap)); domainMap = ((DomainMap) (mySerializer.Deserialize(xmlStream))); domainMap.MapSerializer = MapSerializer.DotNetSerializer; Init(domainMap); } catch (Exception ex) { throw new MappingException("Failed loading NPersist XML mapping file! " + ex.Message, ex); // do not localize } } RecalculateModel(domainMap); domainMap.Dirty = false; if (validate) ((DomainMap)domainMap).Validate(); return domainMap; }
public IDomainMap GetDomainMap() { if (domainMap == null) { ILoggingService loggingService = engine.GetService<ILoggingService>(); if (loggingService != null) loggingService.LogInfo(this, "Loading NPersist mapping file."); IConfigurationService configurationService = engine.GetService<IConfigurationService>(); IMapSerializer serializer = new DefaultMapSerializer(); this.domainMap = DomainMap.Load(configurationService.SchemaFilePath, serializer, false, false); } return this.domainMap; }
private IContext GetContext(string mapPath) { IMapSerializer serialier = new DefaultMapSerializer(); IDomainMap domainMap = DomainMap.Load(mapPath, serialier, false, false); IContext context = new Context(domainMap); GenerateAssembly(context); return context; }
private IContext GetContext() { //Assembly asm = this.GetType().Assembly; //string path = "Puzzle.FastForward.Web.Test.npersist"; string path = @"C:\Berlioz\Puzzle\FastForward\Puzzle.FastForward.Web\Test.npersist"; IMapSerializer serialier = new DefaultMapSerializer(); IDomainMap domainMap = DomainMap.Load(path, serialier, false, false); IContext context = new Context(domainMap); GenerateAssembly(context); return context; }