Exemplo n.º 1
0
        public void Create()
        {
            Dictionary <string, ClassGeneratorInfo> generatorInfos = new ClassGenerator(_persistentAssemblyInfo, _storageTables).CreateAll().ToDictionary(classGeneratorInfo => classGeneratorInfo.PersistentClassInfo.Name);

            foreach (var classGeneratorInfo in generatorInfos.Where(pair => pair.Value.PersistentClassInfo.CodeTemplateInfo.CodeTemplate.TemplateType == TemplateType.Class))
            {
                var generatorInfo = classGeneratorInfo.Value;
                new ClassAtrributeGenerator(generatorInfo, _logonObject.NavigationPath).Create().Each(info => generatorInfo.PersistentClassInfo.TypeAttributes.Add(info));
                var memberGeneratorInfos = new MemberGenerator(classGeneratorInfo.Value.DbTable, generatorInfos).Create();
                memberGeneratorInfos.Each(info => new MemberAttributeGenerator(info, generatorInfo).Create());
            }
            var oneToOneMemberInfos = _persistentAssemblyInfo.PersistentClassInfos.SelectMany(info => info.OwnMembers.OfType <IPersistentReferenceMemberInfo>()).Where(info => info.CodeTemplateInfo.CodeTemplate.TemplateType == TemplateType.XPOneToOnePropertyMember);

            foreach (var oneToOneMemberInfo in oneToOneMemberInfos)
            {
                var codeTemplate = _objectSpace.CreateWCObject <ICodeTemplate>();
                codeTemplate.TemplateCode = oneToOneMemberInfo.ReferenceClassInfo.OwnMembers.OfType <IPersistentReferenceMemberInfo>().Single(info => info.CodeTemplateInfo.CodeTemplate.TemplateType == TemplateType.XPOneToOnePropertyMember).Name;
                oneToOneMemberInfo.TemplateInfos.Add(codeTemplate);
            }
            CodeEngine.SupportCompositeKeyPersistentObjects(_persistentAssemblyInfo);
            CreateAssemblyAttributes();
        }
Exemplo n.º 2
0
        public void Map(Database database, IMapperInfo mapperInfo)
        {
            var attributeMapper = new AttributeMapper(_objectSpace);
            var tableMapper     = new TableMapper(_objectSpace, database, attributeMapper);
            var dataTypeMapper  = new DataTypeMapper();
            var columnMapper    = new ColumnMapper(dataTypeMapper, attributeMapper);

            Tracing.Tracer.LogSeparator("DBMapper Start mapping database " + database.Name);
            foreach (Table table in database.Tables.OfType <Table>().Where(table => !(table.IsSystemObject)))
            {
                Tracing.Tracer.LogValue("Table", table.Name);
                IPersistentClassInfo persistentClassInfo = tableMapper.Create(table, _persistentAssemblyInfo, mapperInfo);
                foreach (Column column in table.Columns)
                {
                    columnMapper.Create(column, persistentClassInfo);
                }
            }
            _dataStoreLogonObject = (IDataStoreLogonObject)XafTypesInfo.Instance.FindBussinessObjectType <IDataStoreLogonObject>().CreateInstance(new object[] { _persistentAssemblyInfo.Session, _dataStoreLogonObject });
            attributeMapper.Create(_persistentAssemblyInfo, _dataStoreLogonObject);
            Func <ITemplateInfo, bool> templateInfoPredicate = info => info.Name == ExtraInfoBuilder.SupportPersistentObjectsAsAPartOfACompositeKey;

            CodeEngine.SupportCompositeKeyPersistentObjects(_persistentAssemblyInfo, templateInfoPredicate);
        }