예제 #1
0
        public void should_createobject_nullable()
        {
            int ID = Zetbox.API.Helper.INVALIDID;

            using (Zetbox.API.IZetboxContext ctx = GetContext())
            {
                var obj = ctx.Create <Zetbox.App.Test.TestCustomObject>();
                obj.PersonName = "TestPerson " + rnd.Next();
                obj.Birthday   = DateTime.Now;

                Assert.That(obj.PhoneNumberMobile, Is.Not.Null);
                Assert.That(obj.PhoneNumberOffice, Is.Not.Null);

                obj.PhoneNumberOffice.AreaCode = "2";
                obj.PhoneNumberOffice.Number   = testNumber;

                Assert.That(ctx.SubmitChanges(), Is.EqualTo(1));

                ID = obj.ID;
            }

            using (Zetbox.API.IZetboxContext ctx = GetContext())
            {
                var obj = ctx.Find <Zetbox.App.Test.TestCustomObject>(ID);
                Assert.That(obj, Is.Not.Null);
                Assert.That(obj.PhoneNumberMobile, Is.Not.Null);
                Assert.That(obj.PhoneNumberOffice, Is.Not.Null);
                Assert.That(obj.PhoneNumberOffice.Number, Is.EqualTo(testNumber));
            }
        }
예제 #2
0
        public void GetListOfInheritedObjects()
        {
            using (Zetbox.API.IZetboxContext ctx = GetContext())
            {
                bool intFound    = false;
                bool stringFound = false;

                var list = ctx.GetQuery <Zetbox.App.Base.Property>().ToList();
                Assert.That(list.Count, Is.GreaterThan(0));

                foreach (Zetbox.App.Base.Property bp in list)
                {
                    if (bp is Zetbox.App.Base.IntProperty)
                    {
                        intFound = true;
                    }
                    if (bp is Zetbox.App.Base.StringProperty)
                    {
                        stringFound = true;
                    }
                }

                Assert.That(intFound, Is.True);
                Assert.That(stringFound, Is.True);
            }
        }
예제 #3
0
 public ProjectFile(Arebis.CodeGeneration.IGenerationHost _host, Zetbox.API.IZetboxContext ctx, string projectGuid, List <string> fileNames, IEnumerable <ISchemaProvider> schemaProviders)
     : base(_host)
 {
     this.ctx             = ctx;
     this.projectGuid     = projectGuid;
     this.fileNames       = fileNames;
     this.schemaProviders = schemaProviders;
 }
예제 #4
0
        public static void Call(Arebis.CodeGeneration.IGenerationHost _host, Zetbox.API.IZetboxContext ctx, string projectGuid, List <string> fileNames, IEnumerable <ISchemaProvider> schemaProviders)
        {
            if (_host == null)
            {
                throw new global::System.ArgumentNullException("_host");
            }

            _host.CallTemplate("ProjectFile", ctx, projectGuid, fileNames, schemaProviders);
        }
예제 #5
0
        public static void Call(Arebis.CodeGeneration.IGenerationHost _host, Zetbox.API.IZetboxContext ctx)
        {
            if (_host == null)
            {
                throw new global::System.ArgumentNullException("_host");
            }

            _host.CallTemplate("AssemblyInfoTemplate", ctx);
        }
예제 #6
0
        public ProjectFile(Arebis.CodeGeneration.IGenerationHost _host, Zetbox.API.IZetboxContext ctx, string projectGuid, List<string> fileNames, IEnumerable<ISchemaProvider> schemaProviders)
            : base(_host)
        {
			this.ctx = ctx;
			this.projectGuid = projectGuid;
			this.fileNames = fileNames;
			this.schemaProviders = schemaProviders;

        }
예제 #7
0
        protected override IEnumerable <string> Generate_Other(Zetbox.API.IZetboxContext ctx)
        {
            using (log4net.NDC.Push("NhGenerateOther"))
            {
                var otherFileNames = new List <string>();

                otherFileNames.AddRange(CreateMappings(ctx));

                return(base.Generate_Other(ctx).Concat(otherFileNames));
            }
        }
예제 #8
0
        private List <string> CreateMappings(Zetbox.API.IZetboxContext ctx)
        {
            this.RunTemplateWithExtension(ctx, "Mappings.CollectionEntriesHbm", "CollectionEntries", "hbm.xml");
            foreach (var oc in ctx.GetQuery <ObjectClass>().Where(i => i.BaseObjectClass == null))
            {
                this.RunTemplateWithExtension(ctx, "Mappings.ObjectClassHbm", oc.Name, "hbm.xml",
                                              Templates.Mappings.ObjectClassHbm.MakeArgs(ctx, oc, new NameValueCollection()
                {
                    { "extrasuffix", ExtraSuffix }
                }));
            }

            // Mapping files are picked up automatically by the ProjectFile
            // so we don't need to keep track of them.
            return(new List <string>());
        }
예제 #9
0
        protected override IEnumerable <string> Generate_Other(Zetbox.API.IZetboxContext ctx)
        {
            using (log4net.NDC.Push("EfGenerateOther"))
            {
                var otherFileNames = new List <string>();

                // those are not compilable, therefore don't add them to otherFileNames.
                // should be handled separately in the ProjectFile Template
                this.RunTemplate(ctx, "EfModel.ModelCsdl", "Model.csdl");
                this.RunTemplate(ctx, "EfModel.ModelMsl", "Model.msl");
                foreach (var schemaProvider in SchemaProviders.Where(sp => sp.IsStorageProvider))
                {
                    this.RunTemplate(ctx, "EfModel.ModelSsdl", String.Format("Model.{0}.ssdl", schemaProvider.ConfigName), schemaProvider);
                }
                otherFileNames.Add(this.RunTemplateWithExtension(ctx, "ObjectClasses.AssociationSetAttributes", "AssociationSetAttributes", "cs"));

                return(base.Generate_Other(ctx).Concat(otherFileNames));
            }
        }
예제 #10
0
 public Template(Arebis.CodeGeneration.IGenerationHost _host, Zetbox.API.IZetboxContext ctx, ObjectClass cls)
     : base(_host, ctx, cls)
 {
 }
예제 #11
0
 public AssemblyInfoTemplate(Arebis.CodeGeneration.IGenerationHost _host, Zetbox.API.IZetboxContext ctx)
     : base(_host, ctx)
 {
 }
예제 #12
0
        public AssemblyInfoTemplate(Arebis.CodeGeneration.IGenerationHost _host, Zetbox.API.IZetboxContext ctx)
            : base(_host)
        {
			this.ctx = ctx;

        }
예제 #13
0
 public ProjectFile(Arebis.CodeGeneration.IGenerationHost _host, Zetbox.API.IZetboxContext ctx, string projectGuid, List <string> fileNames, IEnumerable <ISchemaProvider> schemaProviders)
     : base(_host, ctx, projectGuid, fileNames, schemaProviders)
 {
 }
예제 #14
0
 public ListProperty(Arebis.CodeGeneration.IGenerationHost _host, Zetbox.API.IZetboxContext ctx, Templates.Serialization.SerializationMembersList list, DataType containingType, String name, Property property)
     : base(_host, ctx, list, containingType, name, property)
 {
 }