예제 #1
0
 public virtual void UpdateName(string newName)
 {
     if (DomainMap.GetSourceMap() == this)
     {
         DomainMap.Source = newName;
     }
     else
     {
         foreach (IClassMap classMap in DomainMap.ClassMaps)
         {
             if (classMap.GetSourceMap() == this)
             {
                 classMap.Source = newName;
             }
             if (classMap.GetDocSourceMap() == this)
             {
                 classMap.DocSource = newName;
             }
             foreach (IPropertyMap propertyMap in classMap.GetNonInheritedPropertyMaps())
             {
                 if (propertyMap.GetSourceMap() == this)
                 {
                     propertyMap.Source = newName;
                 }
                 if (propertyMap.GetDocSourceMap() == this)
                 {
                     propertyMap.DocSource = newName;
                 }
             }
         }
     }
     m_name = newName;
 }
        public IDomainMap GetMap()
        {
            if (this.url.Length < 1)
            {
                throw new NPersistException("You must specify an url to your NPersist Web Service in your WebServiceRemotingEngine!");
            }

            RemotingService rs = new RemotingService(this.Context, url);

            bool doUseCompression = this.useCompression;

            if (this.compressor == null)
            {
                doUseCompression = false;
            }

            string result = rs.GetMap(this.domainKey, doUseCompression);

            if (useCompression && this.compressor != null)
            {
                result = this.compressor.Decompress(result);
            }

            return(DomainMap.LoadFromXml(result, new DefaultMapSerializer()));
        }
예제 #3
0
        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);
        }
예제 #4
0
        public string Export(DomainMap map)
        {
            foreach (var type in map.Mappings.MappedTypes)
            {
                var mapping = map.Mappings.For(type);
                dialect.CreateTable(mapping.Table, x => mapping.ExportTo(dialect));
            }

            return builder.ToString();
        }
예제 #5
0
        public string Export(DomainMap map)
        {
            foreach (var type in map.Mappings.MappedTypes)
            {
                var mapping = map.Mappings.For(type);
                dialect.CreateTable(mapping.Table, x => mapping.ExportTo(dialect));
            }

            return(builder.ToString());
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            IDomainMap domainMap = new DomainMap();

            domainMap.Name          = "Test";
            domainMap.RootNamespace = "Puzzle.Testing";

            IClassMap employee = new ClassMap();

            employee.Name      = "Employee";
            employee.DomainMap = domainMap;

            IPropertyMap firstName = new PropertyMap();

            firstName.Name     = "FirstName";
            firstName.DataType = "System.String";
            firstName.ClassMap = employee;

            IPropertyMap lastName = new PropertyMap();

            lastName.Name     = "LastName";
            lastName.DataType = "System.String";
            lastName.ClassMap = employee;

            IPropertyMap reportsTo = new PropertyMap();

            reportsTo.Name     = "ReportsTo";
            reportsTo.DataType = "Employee";
            reportsTo.ClassMap = employee;

            IPropertyMap employees = new PropertyMap();

            employees.Name         = "Employees";
            employees.IsCollection = true;
            employees.ItemType     = "Employee";
            employees.ClassMap     = employee;

            ModelToCodeTransformer modelToCodeTransformer = new ModelToCodeTransformer();
            string code = modelToCodeTransformer.ToCSharpCode(domainMap);
            //string code = modelToCodeTransformer.ToCSharpCodeFile(domainMap, "Test");

            //modelToCodeTransformer.ToAssemblyFile(domainMap, domainMap.Name + ".dll");
            Assembly asm = modelToCodeTransformer.ToAssembly(domainMap);

            textBox1.Text = code;
        }
        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);
        }
예제 #10
0
 public ISessionFactory Build()
 {
     if (dbAdapter == null)
     {
         dbAdapter = new NullDbAdapter();
     }
     var domainMap = new DomainMap(dbAdapter);
     if (domainConfig != null)
     {
         domainConfig(domainMap);
     }
     domainMap.Done();
     if (sessionCacheProvider == null)
     {
         sessionCacheProvider = () => new SessionCache();
     }
     return new SessionFactory(connString, dbAdapter, domainMap, sessionCacheProvider);
 }
예제 #11
0
 public void SetUp()
 {
     map = new DomainMap();
 }
예제 #12
0
 public static void Configure(params IEntityMap[] entityMaps)
 {
     Map = new DomainMap(entityMaps);
 }
예제 #13
0
 public void SetUp()
 {
     map = new DomainMap();
 }
예제 #14
0
 public InsertCommand(DomainMap domainMap)
 {
     this.domainMap = domainMap;
 }
예제 #15
0
        public static void Convert(string sourceFileName, string targetFileName, IMapSerializer sourceMapSerializer, IMapSerializer targetMapSerializer)
        {
            IDomainMap domainMap = DomainMap.Load(sourceFileName, sourceMapSerializer);

            domainMap.Save(targetFileName, targetMapSerializer);
        }