Exemplo n.º 1
0
        public override void Update() {
            var unitOfWork = new UnitOfWork(Session.DataLayer);

            if (unitOfWork.FindObject<PersistentAssemblyInfo>(null) != null)
                return;
            var persistentAssemblyInfo = new PersistentAssemblyInfo(unitOfWork){Name = "TestAssembly"};
            var persistentClassInfo = new PersistentClassInfo(unitOfWork){
                PersistentAssemblyInfo = persistentAssemblyInfo
            };
            persistentAssemblyInfo.PersistentClassInfos.Add(persistentClassInfo);
            persistentClassInfo.SetDefaultTemplate(TemplateType.Class);
            persistentClassInfo.Name = "TestClassInfo";
            persistentClassInfo.BaseType = typeof (Customer);
            persistentClassInfo.MergedObjectType = typeof (Customer);
            persistentClassInfo.TypeAttributes.Add(new PersistentDefaultClassOptionsAttribute(unitOfWork));
            persistentClassInfo.TypeAttributes.Add(new PersistentMapInheritanceAttribute(unitOfWork){
                MapInheritanceType = MapInheritanceType.ParentTable
            });
            var persistentCoreTypeMemberInfo = new PersistentCoreTypeMemberInfo(unitOfWork){
                DataType = DBColumnType.String,
                Name = "TestProp"
            };
            persistentClassInfo.OwnMembers.Add(persistentCoreTypeMemberInfo);
            persistentCoreTypeMemberInfo.SetDefaultTemplate(TemplateType.ReadWriteMember);
            

            unitOfWork.CommitChanges();
        }
 void IPersistentCollectionMemberInfo.SetCollectionTypeFullName(string s) {
     CollectionTypeFullName = s;
     if (_collectionType == null && _collectionClassInfo == null && s != null) {
         IPersistentClassInfo classInfo = PersistentClassInfoQuery.Find(Session, s);
         if (classInfo != null)
             _collectionClassInfo = (PersistentClassInfo) classInfo;
         else
             _collectionType = ReflectionHelper.GetType(s.Substring(s.LastIndexOf(".") + 1));
     }
 }
 void IPersistentReferenceMemberInfo.SetReferenceTypeFullName(string value) {
     ReferenceTypeFullName = value;
     if (_referenceType == null && _referenceClassInfo == null && value != null)
     {
         IPersistentClassInfo classInfo = PersistentClassInfoQuery.Find(Session, value);
         if (classInfo != null)
             _referenceClassInfo = (PersistentClassInfo)classInfo;
         else
             _referenceType = ReflectionHelper.GetType(value.Substring(value.LastIndexOf(".") + 1));
     }
 }
Exemplo n.º 4
0
 public ClassGeneratorHelper(IObjectSpace XPObjectSpace) {
     _persistentAssemblyInfo = XPObjectSpace.CreateObject<PersistentAssemblyInfo>();
     _persistentAssemblyInfo.Name = "PersistentAssemblyInfo";
     _persistentClassInfo = XPObjectSpace.CreateObject<PersistentClassInfo>();
     _persistentClassInfo.Name = "MainTable";
     _persistentAssemblyInfo.PersistentClassInfos.Add(_persistentClassInfo);
     _persistentClassInfo.SetDefaultTemplate(TemplateType.Class);
     _classGeneratorInfos = new Dictionary<string, ClassGeneratorInfo>();
     var classGeneratorInfo = new ClassGeneratorInfo(PersistentClassInfo, DbTable);
     _classGeneratorInfos.Add(PersistentClassInfo.Name, classGeneratorInfo);
 }
Exemplo n.º 5
0
 public CompoundPKMemberGeneratorHelper(IObjectSpace XPObjectSpace)
     : base(XPObjectSpace) {
     _dbColumn1 = new DBColumn { Name = "DBColumn1", ColumnType = DBColumnType.Int32 };
     _dbColumn2 = new DBColumn { Name = "DBColumn2", ColumnType = DBColumnType.Int32 };
     var dbColumns = new[] { _dbColumn1, _dbColumn2 };
     DbTable.Columns.AddRange(dbColumns);
     DbTable.PrimaryKey = new DBPrimaryKey(dbColumns);
     _structPersistentClassInfo = XPObjectSpace.CreateObject<PersistentClassInfo>();
     _structPersistentClassInfo.Name = "MainTable" + TableMapper.KeyStruct;
     _structPersistentClassInfo.PersistentAssemblyInfo = (PersistentAssemblyInfo)PersistentAssemblyInfo;
     _structPersistentClassInfo.SetDefaultTemplate(TemplateType.Struct);
     ClassGeneratorInfos.Add(_structPersistentClassInfo.Name, new ClassGeneratorInfo(StructPersistentClassInfo, DbTable));
 }
Exemplo n.º 6
0
        public override void Update(){
            if (Session.FindObject<PersistentAssemblyInfo>(info => info.Name == "OneToMany") == null) {
                var persistentAssemblyInfo = new PersistentAssemblyInfo(Session){Name = "OneToMany"};

                var projectCassInfo = new PersistentClassInfo(Session);
                persistentAssemblyInfo.PersistentClassInfos.Add(projectCassInfo);
                projectCassInfo.Name = "Project";
                projectCassInfo.SetDefaultTemplate(TemplateType.Class);
                projectCassInfo.TypeAttributes.Add(new PersistentDefaultClassOptionsAttribute(Session));
                
                var persistentCoreTypeMemberInfo = new PersistentCoreTypeMemberInfo(Session);
                projectCassInfo.OwnMembers.Add(persistentCoreTypeMemberInfo);
                persistentCoreTypeMemberInfo.Name = "Name";
                persistentCoreTypeMemberInfo.DataType=DBColumnType.String;
                persistentCoreTypeMemberInfo.SetDefaultTemplate(TemplateType.ReadWriteMember);
                
                var contributorCassInfo = new PersistentClassInfo(Session);
                persistentAssemblyInfo.PersistentClassInfos.Add(contributorCassInfo);
                contributorCassInfo.Name = "Contributor";
                contributorCassInfo.SetDefaultTemplate(TemplateType.Class);

                persistentCoreTypeMemberInfo = new PersistentCoreTypeMemberInfo(Session);
                contributorCassInfo.OwnMembers.Add(persistentCoreTypeMemberInfo);
                persistentCoreTypeMemberInfo.Name = "Name";
                persistentCoreTypeMemberInfo.DataType = DBColumnType.String;
                persistentCoreTypeMemberInfo.SetDefaultTemplate(TemplateType.ReadWriteMember);

                var collectionMemberInfo = new PersistentCollectionMemberInfo(Session);
                projectCassInfo.OwnMembers.Add(collectionMemberInfo);
                collectionMemberInfo.CollectionClassInfo = contributorCassInfo;
                collectionMemberInfo.Name = "Contributors";
                var associationAttribute = new PersistentAssociationAttribute(Session);
                collectionMemberInfo.TypeAttributes.Add(associationAttribute);
                associationAttribute.AssociationName = "Project-Contributors";
                collectionMemberInfo.SetDefaultTemplate(TemplateType.XPCollectionMember);

                var referenceMemberInfo = new PersistentReferenceMemberInfo(Session);
                contributorCassInfo.OwnMembers.Add(referenceMemberInfo);
                referenceMemberInfo.Name = "Project";
                referenceMemberInfo.ReferenceClassInfo = projectCassInfo;
                associationAttribute = new PersistentAssociationAttribute(Session);
                referenceMemberInfo.TypeAttributes.Add(associationAttribute);
                associationAttribute.AssociationName = "Project-Contributors";
                referenceMemberInfo.SetDefaultTemplate(TemplateType.ReadWriteMember);

//                ObjectSpace.CommitChanges();
            }

        }
Exemplo n.º 7
0
 void IPersistentReferenceMemberInfo.SetReferenceTypeFullName(string value)
 {
     ReferenceTypeFullName = value;
     if (_referenceType == null && _referenceClassInfo == null && value != null)
     {
         IPersistentClassInfo classInfo = PersistentClassInfoQuery.Find(Session, value);
         if (classInfo != null)
         {
             _referenceClassInfo = (PersistentClassInfo)classInfo;
         }
         else
         {
             _referenceType = ReflectionHelper.GetType(value.Substring(value.LastIndexOf(".") + 1));
         }
     }
 }
 void IPersistentCollectionMemberInfo.SetCollectionTypeFullName(string s)
 {
     CollectionTypeFullName = s;
     if (_collectionType == null && _collectionClassInfo == null && s != null)
     {
         IPersistentClassInfo classInfo = PersistentClassInfoQuery.Find(Session, s);
         if (classInfo != null)
         {
             _collectionClassInfo = (PersistentClassInfo)classInfo;
         }
         else
         {
             _collectionType = ReflectionHelper.GetType(s.Substring(s.LastIndexOf(".") + 1));
         }
     }
 }
Exemplo n.º 9
0
 void IPersistentReferenceMemberInfo.SetReferenceTypeFullName(string value)
 {
     ReferenceTypeFullName = value;
     if (_referenceType == null && _referenceClassInfo == null && value != null)
     {
         IPersistentClassInfo classInfo = Session.FindReferenceClassInfo(value);
         if (classInfo != null)
         {
             _referenceClassInfo = (PersistentClassInfo)classInfo;
         }
         else
         {
             _referenceType =
                 ReflectionHelper.GetType(value.Substring(value.LastIndexOf(".", StringComparison.Ordinal) + 1));
         }
     }
 }
Exemplo n.º 10
0
 void IPersistentCollectionMemberInfo.SetCollectionTypeFullName(string s)
 {
     CollectionTypeFullName = s;
     if (_collectionType == null && _collectionClassInfo == null && s != null)
     {
         var classInfo = Session.FindReferenceClassInfo(s);
         if (classInfo != null)
         {
             _collectionClassInfo = (PersistentClassInfo)classInfo;
         }
         else
         {
             _collectionType =
                 ReflectionHelper.GetType(s.Substring(s.LastIndexOf(".", StringComparison.Ordinal) + 1));
         }
     }
 }
Exemplo n.º 11
0
 static void createClass() {
     var persistentClassInfo = new PersistentClassInfo(UnitOfWork) { PersistentAssemblyInfo = _persistentAssemblyInfo, CodeTemplateInfo = new CodeTemplateInfo(UnitOfWork) };
     var codeTemplate = new CodeTemplate(UnitOfWork) { TemplateType = TemplateType.Class, CodeDomProvider = CodeDomProvider.VB };
     codeTemplate.SetDefaults();
     persistentClassInfo.CodeTemplateInfo.TemplateInfo = codeTemplate;
 }
Exemplo n.º 12
0
        public RefMemberGeneratorHelper(IObjectSpace XPObjectSpace)
            : base(XPObjectSpace) {
            var column = new DBColumn("Oid", false, "int", 0, DBColumnType.Int32);
            DbTable.PrimaryKey = new DBPrimaryKey(new[] { column });
            var dbColumn = new DBColumn { Name = "DBColumn", ColumnType = DBColumnType.Int32 };
            DbTable.Columns.Add(dbColumn);
            DbTable.Columns.Add(column);
            var refDbColumn = new DBColumn { Name = "refDbColumn", ColumnType = DBColumnType.Int32, IsKey = true };
            DbTable.Columns.Add(refDbColumn);
            var primaryKeyTableKeyColumns = new StringCollection { "refDbColumn" };
            DbTable.ForeignKeys.Add(new DBForeignKey(new List<DBColumn> { refDbColumn }, _refDbTable.Name, primaryKeyTableKeyColumns));

            var item = new DBColumn("Oid", true, "int", 0, DBColumnType.Int32);
            _refDbTable.Columns.Add(item);
            _refDbTable.PrimaryKey = new DBPrimaryKey(new[] { item });
            _refPersistentClassInfo = XPObjectSpace.CreateObject<PersistentClassInfo>();
            _refPersistentClassInfo.Name = RefDbTable.Name;
            PersistentAssemblyInfo.PersistentClassInfos.Add(_refPersistentClassInfo);
            _refPersistentClassInfo.SetDefaultTemplate(TemplateType.Class);


            ClassGeneratorInfos.Add(_refPersistentClassInfo.Name, new ClassGeneratorInfo(_refPersistentClassInfo, RefDbTable));
        }