예제 #1
0
        public void Change_Relation_n_m_Set_n_With_Remove()
        {
            using (IZetboxContext ctx = GetContext())
            {
                var prj = ctx.Create <Zetbox.App.Projekte.Projekt>();
                var ma  = ctx.Create <Zetbox.App.Projekte.Mitarbeiter>();
                var ma2 = ctx.Create <Zetbox.App.Projekte.Mitarbeiter>();

                prj.Mitarbeiter.Add(ma);

                Assert.That(prj.Mitarbeiter.Count, Is.EqualTo(1));
                Assert.That(prj.Mitarbeiter.First(), Is.SameAs(ma));
                Assert.That(ma.Projekte.Count, Is.EqualTo(1));
                Assert.That(ma.Projekte.First(), Is.SameAs(prj));

                prj.Mitarbeiter.Remove(ma);
                prj.Mitarbeiter.Add(ma2);

                Assert.That(prj.Mitarbeiter.Count, Is.EqualTo(1));
                Assert.That(prj.Mitarbeiter.First(), Is.SameAs(ma2));
                Assert.That(ma.Projekte.Count, Is.EqualTo(0));
                Assert.That(ma2.Projekte.Count, Is.EqualTo(1));
                Assert.That(ma2.Projekte.First(), Is.SameAs(prj));
            }
        }
예제 #2
0
        public override void SetUp()
        {
            base.SetUp();

            ctx = GetContext();
            var principalResolver = scope.Resolve<IPrincipalResolver>();

            var currentPrincipal = principalResolver.GetCurrent();

            Assert.That(currentPrincipal, Is.Not.Null, "No current identity found - try syncidentities or setup the current identity correctly");

            identity1 = ctx.Find<Identity>(currentPrincipal.ID);
            identity2 = ctx.GetQuery<Identity>().Where(i => i.ID != identity1.ID).First();

            parent = ctx.Create<SecurityTestParent>();
            parent.Name = "MyParent";

            child1 = ctx.Create<SecurityTestChild>();
            child1.Name = "Child1";
            child1.Identity = identity1;
            child1.Parent = parent;

            child2 = ctx.Create<SecurityTestChild>();
            child2.Name = "Child2";
            child2.Identity = identity2;
            child2.Parent = parent;

            ctx.SubmitChanges();
        }
예제 #3
0
        public override void SetUp()
        {
            base.SetUp();
            DeleteObjects();

            using (IZetboxContext ctx = GetContext())
            {
                Projekt prj1 = ctx.Create <Projekt>();
                prj1.Name = ProjectName1;

                Projekt prj2 = ctx.Create <Projekt>();
                prj2.Name = ProjectName2;

                for (int i = 0; i < Project1TaskCount; i++)
                {
                    SetUpCreateTask(ctx, prj1, i);
                }

                for (int i = 0; i < Project2TaskCount; i++)
                {
                    SetUpCreateTask(ctx, prj2, i);
                }

                ctx.SubmitChanges();

                Project1ID = prj1.ID;
                Project2ID = prj2.ID;
                Console.WriteLine("Workaround for mono: {0}, {1}", Project1ID, Project2ID);
            }
        }
예제 #4
0
        public override void SetUp()
        {
            base.SetUp();

            ctx = GetContext();
            var idResolver = scope.Resolve <IIdentityResolver>();

            var currentIdentity = idResolver.GetCurrent();

            Assert.That(currentIdentity, Is.Not.Null, "No current identity found - try syncidentities or setup the current identity correctly");

            identity1 = ctx.Find <Identity>(currentIdentity.ID);
            identity2 = ctx.GetQuery <Identity>().Where(i => i.ID != identity1.ID).First();

            parent      = ctx.Create <SecurityTestParent>();
            parent.Name = "MyParent";

            child1          = ctx.Create <SecurityTestChild>();
            child1.Name     = "Child1";
            child1.Identity = identity1;
            child1.Parent   = parent;

            child2          = ctx.Create <SecurityTestChild>();
            child2.Name     = "Child2";
            child2.Identity = identity2;
            child2.Parent   = parent;

            ctx.SubmitChanges();
        }
예제 #5
0
 public void InitTestObjects()
 {
     ctx    = GetContext();
     aSide1 = ctx.Create <N_to_M_relations_A>();
     aSide2 = ctx.Create <N_to_M_relations_A>();
     bSide1 = ctx.Create <N_to_M_relations_B>();
     bSide2 = ctx.Create <N_to_M_relations_B>();
 }
예제 #6
0
 public void InitTestObjects()
 {
     ctx = GetContext();
     aSide1 = ctx.Create<N_to_M_relations_A>();
     aSide2 = ctx.Create<N_to_M_relations_A>();
     bSide1 = ctx.Create<N_to_M_relations_B>();
     bSide2 = ctx.Create<N_to_M_relations_B>();
 }
예제 #7
0
 public virtual void InitTestObjects()
 {
     ctx = GetContext();
     oneSide1 = ctx.Create<RequiredParent>();
     oneSide2 = ctx.Create<RequiredParent>();
     oneSide3 = ctx.Create<RequiredParent>();
     nSide1 = ctx.Create<RequiredParentChild>();
     nSide2 = ctx.Create<RequiredParentChild>();
 }
예제 #8
0
 public virtual void InitTestObjects()
 {
     ctx = GetContext();
     oneSide1 = ctx.Create<One_to_N_relations_One>();
     oneSide2 = ctx.Create<One_to_N_relations_One>();
     oneSide3 = ctx.Create<One_to_N_relations_One>();
     nSide1 = ctx.Create<One_to_N_relations_N>();
     nSide2 = ctx.Create<One_to_N_relations_N>();
 }
예제 #9
0
 public virtual void InitTestObjects()
 {
     ctx      = GetContext();
     oneSide1 = ctx.Create <RequiredParent>();
     oneSide2 = ctx.Create <RequiredParent>();
     oneSide3 = ctx.Create <RequiredParent>();
     nSide1   = ctx.Create <RequiredParentChild>();
     nSide2   = ctx.Create <RequiredParentChild>();
 }
예제 #10
0
 public virtual void InitTestObjects()
 {
     ctx      = GetContext();
     oneSide1 = ctx.Create <One_to_N_relations_One>();
     oneSide2 = ctx.Create <One_to_N_relations_One>();
     oneSide3 = ctx.Create <One_to_N_relations_One>();
     nSide1   = ctx.Create <One_to_N_relations_N>();
     nSide2   = ctx.Create <One_to_N_relations_N>();
 }
예제 #11
0
        /// <summary>
        /// Creates a few new test objects
        /// </summary>
        /// <param name="ctx">this context is used to create the objects</param>
        public static void CreateTestData(IZetboxContext ctx)
        {
            var kunde = ctx.Create <Kunde>();

            kunde.EMails.Add("*****@*****.**");
            kunde.EMails.Add("*****@*****.**");
            kunde.Kundenname = "com Kunde";
            kunde.PLZ        = "1111";

            kunde = ctx.Create <Kunde>();
            kunde.EMails.Add("*****@*****.**");
            kunde.Kundenname = "net Kunde";
            kunde.PLZ        = "2222";

            kunde            = ctx.Create <Kunde>();
            kunde.Kundenname = "empty Kunde";
            kunde.PLZ        = "3333";

            kunde = ctx.Create <Kunde>();
            kunde.EMails.Add("*****@*****.**");
            kunde.EMails.Add("*****@*****.**");
            kunde.EMails.Add("*****@*****.**");
            kunde.EMails.Add("*****@*****.**");
            kunde.Kundenname = "org Kunde";
            kunde.PLZ        = "4444";

            var prj = ctx.Create <Projekt>();

            prj.Name = "Zetbox";

            var task1 = ctx.Create <Task>();

            task1.Name    = "task1";
            task1.Projekt = prj;

            var task2 = ctx.Create <Task>();

            task2.Name    = "task2";
            task2.Projekt = prj;

            var ma1 = ctx.Create <Mitarbeiter>();

            ma1.Geburtstag    = new DateTime(1960, 01, 02);
            ma1.Name          = "Mitarbeiter Alpha";
            ma1.SVNr          = "123456789";
            ma1.TelefonNummer = "+43664123456789";

            var ma2 = ctx.Create <Mitarbeiter>();

            ma2.Geburtstag    = new DateTime(1970, 12, 30);
            ma2.Name          = "Mitarbeiter Beta";
            ma2.SVNr          = "987654321";
            ma2.TelefonNummer = "+43664987654321";

            // Make nHibernate happy
            ctx.SubmitChanges();

            ma2.Projekte.Add(prj);
            ma1.Projekte.Add(prj);
        }
예제 #12
0
        /// <summary>
        /// Creates a few new test objects
        /// </summary>
        /// <param name="ctx">this context is used to create the objects</param>
        public static void CreateTestData(IZetboxContext ctx)
        {
            var kunde = ctx.Create<Kunde>();
            kunde.EMails.Add("*****@*****.**");
            kunde.EMails.Add("*****@*****.**");
            kunde.Kundenname = "com Kunde";
            kunde.PLZ = "1111";

            kunde = ctx.Create<Kunde>();
            kunde.EMails.Add("*****@*****.**");
            kunde.Kundenname = "net Kunde";
            kunde.PLZ = "2222";

            kunde = ctx.Create<Kunde>();
            kunde.Kundenname = "empty Kunde";
            kunde.PLZ = "3333";

            kunde = ctx.Create<Kunde>();
            kunde.EMails.Add("*****@*****.**");
            kunde.EMails.Add("*****@*****.**");
            kunde.EMails.Add("*****@*****.**");
            kunde.EMails.Add("*****@*****.**");
            kunde.Kundenname = "org Kunde";
            kunde.PLZ = "4444";

            var prj = ctx.Create<Projekt>();
            prj.Name = "Zetbox";

            var task1 = ctx.Create<Task>();
            task1.Name = "task1";
            task1.Projekt = prj;

            var task2 = ctx.Create<Task>();
            task2.Name = "task2";
            task2.Projekt = prj;

            var ma1 = ctx.Create<Mitarbeiter>();
            ma1.Geburtstag = new DateTime(1960, 01, 02);
            ma1.Name = "Mitarbeiter Alpha";
            ma1.SVNr = "123456789";
            ma1.TelefonNummer = "+43664123456789";

            var ma2 = ctx.Create<Mitarbeiter>();
            ma2.Geburtstag = new DateTime(1970, 12, 30);
            ma2.Name = "Mitarbeiter Beta";
            ma2.SVNr = "987654321";
            ma2.TelefonNummer = "+43664987654321";

            // Make nHibernate happy
            ctx.SubmitChanges();

            ma2.Projekte.Add(prj);
            ma1.Projekte.Add(prj);
        }
예제 #13
0
        public override void SetUp()
        {
            base.SetUp();

            ctx = GetContext();

            one = ctx.Create<One_to_N_relations_One>();
            n1 = ctx.Create<One_to_N_relations_N>();
            n2 = ctx.Create<One_to_N_relations_N>();

            one.NSide.Add(n1);
            one.NSide.Add(n2);

            ctx.SubmitChanges();
        }
예제 #14
0
        public override void SetUp()
        {
            base.SetUp();

            ctx = GetContext();

            one = ctx.Create <One_to_N_relations_One>();
            n1  = ctx.Create <One_to_N_relations_N>();
            n2  = ctx.Create <One_to_N_relations_N>();

            one.NSide.Add(n1);
            one.NSide.Add(n2);

            ctx.SubmitChanges();
        }
예제 #15
0
        public override void SetUp()
        {
            base.SetUp();

            ctx = GetContext();

            a1 = ctx.Create <N_to_M_relations_A>();
            b1 = ctx.Create <N_to_M_relations_B>();
            b2 = ctx.Create <N_to_M_relations_B>();

            a1.BSide.Add(b1);
            a1.BSide.Add(b2);

            ctx.SubmitChanges();
        }
예제 #16
0
        public override void SetUp()
        {
            base.SetUp();

            ctx = GetContext();

            a1 = ctx.Create<N_to_M_relations_A>();
            b1 = ctx.Create<N_to_M_relations_B>();
            b2 = ctx.Create<N_to_M_relations_B>();

            a1.BSide.Add(b1);
            a1.BSide.Add(b2);

            ctx.SubmitChanges();
        }
예제 #17
0
 public override void SetUp()
 {
     base.SetUp();
     ctx = GetContext();
     obj = ctx.Create<TestObjClass>();
     obj.StringProp = "Some String";
 }
        public static BaseValueViewModel Create <TObject, TRole>(IViewModelFactory mdlFactory, IZetboxContext ctx, IFrozenContext frozenCtx, ViewModel parent, string label, IDataObject obj, Expression <Func <TObject, PartyRole> > property)
            where TRole : class, PartyRole
            where TObject : class, IDataObject
        {
            var me       = (MemberExpression)property.Body;
            var propInfo = (PropertyInfo)me.Member;

            var initialPartyRole = (PartyRole)propInfo.GetValue(obj, null);

            var mdl = new ObjectReferenceValueModel(label, "", false, false, (ObjectClass)NamedObjects.Base.Classes.Zetbox.Basic.Parties.Party.Find(frozenCtx));

            mdl.Value            = initialPartyRole != null ? initialPartyRole.Party : null;
            mdl.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Value")
                {
                    if (mdl.Value != null)
                    {
                        var party     = (Party)mdl.Value;
                        var partyRole = party.PartyRole.OfType <TRole>().SingleOrDefault();
                        if (partyRole == null)
                        {
                            partyRole       = ctx.Create <TRole>();
                            partyRole.Party = party;
                        }
                        propInfo.SetValue(obj, partyRole, null);
                    }
                    else
                    {
                        propInfo.SetValue(obj, null, null);
                    }
                }
            };
            return(mdlFactory.CreateViewModel <ObjectReferenceViewModel.Factory>().Invoke(ctx, parent, mdl));
        }
예제 #19
0
        public void NewObject()
        {
            int      ID;
            double   aufwand = 1.0;
            DateTime datum   = DateTime.Now;
            Projekt  p;

            using (IZetboxContext ctx = GetContext())
            {
                p = ctx.GetQuery <Projekt>().First(prj => prj.Name == ProjectName1);
                var obj = ctx.Create <Task>();

                obj.Name     = "NUnit Test Task";
                obj.Aufwand  = aufwand;
                obj.DatumVon = datum;
                obj.DatumBis = datum.AddDays(1);
                obj.Projekt  = p;

                ctx.SubmitChanges();
                ID = obj.ID;
                Assert.That(ID, Is.Not.EqualTo(Zetbox.API.Helper.INVALIDID));
            }

            using (IZetboxContext checkctx = GetContext())
            {
                var obj = checkctx.GetQuery <Task>().Single(o => o.ID == ID);
                Assert.That(obj, Is.Not.Null);
                Assert.That(obj.Aufwand, Is.EqualTo(aufwand));
                Assert.That(obj.Projekt.ID, Is.EqualTo(p.ID));
            }
        }
예제 #20
0
        public void Relation_1_1_Set_Right()
        {
            using (IZetboxContext ctx = GetContext())
            {
                var prop = ctx.Create <Zetbox.App.Base.IntProperty>();
                Assert.That(prop.DefaultValue, Is.Null);

                var dv = ctx.Create <Zetbox.App.Base.NewGuidDefaultValue>();
                Assert.That(dv.Property, Is.Null);

                dv.Property = prop;

                Assert.That(prop.DefaultValue, Is.SameAs(dv));
                Assert.That(dv.Property, Is.SameAs(prop));
            }
        }
예제 #21
0
        public void NewObject()
        {
            int      ID;
            double   aufwand = 1.0;
            DateTime datum   = DateTime.Now;

            Zetbox.App.Projekte.Projekt p;
            p = ctx.GetQuery <Zetbox.App.Projekte.Projekt>().ToList()[0];
            var obj = ctx.Create <Zetbox.App.Projekte.Task>();

            obj.Name     = "NUnit Test Task";
            obj.Aufwand  = aufwand;
            obj.DatumVon = datum;
            obj.DatumBis = datum.AddDays(1);
            obj.Projekt  = p;

            ctx.SubmitChanges();
            ID = obj.ID;
            Assert.That(ID, Is.Not.EqualTo(Zetbox.API.Helper.INVALIDID));

            IZetboxContext checkctx = GetContext();
            var            checkObj = checkctx.GetQuery <Zetbox.App.Projekte.Task>().First(o => o.ID == ID);

            Assert.That(checkObj, Is.Not.Null);
            Assert.That(checkObj.Aufwand, Is.EqualTo(aufwand));
            Assert.That(checkObj.Projekt.ID, Is.EqualTo(p.ID));
        }
예제 #22
0
        public void SyncIdentities()
        {
            using (Log.InfoTraceMethodCall("SyncIdentities"))
                using (var subContainer = container.BeginLifetimeScope())
                {
                    IZetboxContext ctx      = subContainer.Resolve <IZetboxContext>();
                    var            userList = subContainer.Resolve <IIdentitySource>().GetAllIdentities();

                    var identities = ctx.GetQuery <Zetbox.App.Base.Identity>().ToLookup(k => k.UserName.ToUpper());
                    var everyone   = Zetbox.NamedObjects.Base.Groups.Everyone.Find(ctx);

                    foreach (var user in userList)
                    {
                        if (!identities.Contains(user.UserName.ToUpper()))
                        {
                            var id = ctx.Create <Zetbox.App.Base.Identity>();
                            id.UserName    = user.UserName;
                            id.DisplayName = user.DisplayName;
                            id.Groups.Add(everyone);
                            Log.InfoFormat("Adding Identity {0} ({1})", id.DisplayName, id.UserName);
                        }
                    }

                    ctx.SubmitChanges();
                }
        }
예제 #23
0
        public void Init()
        {
            using (IZetboxContext localCtx = GetContext())
            {
                var result = localCtx.GetQuery <TestObjClass>();
                var list   = result.ToList();

                while (list.Count < 2)
                {
                    var newObj = localCtx.Create <TestObjClass>();
                    //newObj.ObjectProp = localCtx.GetQuery<Kunde>().First();
                    list.Add(newObj);
                }

                list[0].StringProp   = "First";
                list[0].TestEnumProp = TestEnum.First;

                list[1].StringProp   = "Second";
                list[1].TestEnumProp = TestEnum.Second;

                localCtx.SubmitChanges();
            }

            ctx = GetContext();
        }
예제 #24
0
        private static TypeRef CreateTypeRef(Type t, IZetboxContext ctx)
        {
            var result = ctx.Create <TypeRef>();
            var a      = t.Assembly.ToRef(ctx);

            result.Assembly = a;

            if (t.IsGenericType)
            {
                var genericDefinition = t.GetGenericTypeDefinition();
                result.FullName = genericDefinition.FullName;
                result.GenericArguments.Clear();
                foreach (var arg in t.GetGenericArguments())
                {
                    result.GenericArguments.Add(arg.ToRef(ctx));
                }
            }
            else
            {
                result.FullName = t.FullName;
            }

            if (t.BaseType != null)
            {
                result.Parent = t.BaseType.ToRef(ctx);
            }
            return(result);
        }
예제 #25
0
 private static void CreateViewModelDescriptors(IZetboxContext ctx, Dictionary <int, TypeRef> newTypes)
 {
     using (Logging.Log.InfoTraceMethodCallFormat("CreateViewModelDescriptors", "Creating ViewModelDescriptors"))
     {
         foreach (var tr in newTypes.Values)
         {
             var type = tr.AsType(false);
             if (type != null)
             {
                 object attr;
                 // http://blogs.msdn.com/b/kaevans/archive/2005/10/24/484186.aspx
                 if (type.Assembly.ReflectionOnly)
                 {
                     attr = System.Reflection.CustomAttributeData.GetCustomAttributes(type).FirstOrDefault(i => i.Constructor.DeclaringType.FullName == typeof(ViewModelDescriptorAttribute).FullName);
                 }
                 else
                 {
                     attr = type.GetCustomAttributes(typeof(ViewModelDescriptorAttribute), false).FirstOrDefault() as ViewModelDescriptorAttribute;
                 }
                 if (attr != null)
                 {
                     var descr = ctx.GetQuery <ViewModelDescriptor>().FirstOrDefault(i => i.ViewModelRef == tr);
                     if (descr == null)
                     {
                         descr = ctx.Create <ViewModelDescriptor>();
                         descr.ViewModelRef = tr;
                         descr.Description  = "TODO: Add description";
                     }
                 }
             }
         }
     }
 }
예제 #26
0
        protected virtual void CreateTestData()
        {
            using (IZetboxContext create_ctx = GetContext())
            {
                TestCustomObject create_obj;

                create_obj                            = create_ctx.Create <TestCustomObject>();
                create_obj.Birthday                   = DateTime.Now;
                create_obj.PersonName                 = "First Person";
                create_obj.PhoneNumberMobile          = create_ctx.CreateCompoundObject <TestPhoneCompoundObject>();
                create_obj.PhoneNumberMobile.AreaCode = "1";
                create_obj.PhoneNumberMobile.Number   = "11111111";
                create_obj.PhoneNumberOffice.AreaCode = "o1";
                create_obj.PhoneNumberOffice.Number   = "o11111111";
                AddPhoneNumberOther(create_ctx, create_obj, MINLISTCOUNT);

                create_obj                            = create_ctx.Create <TestCustomObject>();
                create_obj.Birthday                   = DateTime.Now;
                create_obj.PersonName                 = "Second Person";
                create_obj.PhoneNumberMobile          = create_ctx.CreateCompoundObject <TestPhoneCompoundObject>();
                create_obj.PhoneNumberMobile.AreaCode = "2";
                create_obj.PhoneNumberMobile.Number   = TEST_MOBILE_NUMBER;
                create_obj.PhoneNumberOffice.AreaCode = "o1";
                create_obj.PhoneNumberOffice.Number   = "o2222222";
                AddPhoneNumberOther(create_ctx, create_obj, MINLISTCOUNT + 5);

                create_obj            = create_ctx.Create <TestCustomObject>();
                create_obj.Birthday   = DateTime.Now;
                create_obj.PersonName = "No Mobile";
                create_obj.PhoneNumberOffice.AreaCode = "o1";
                create_obj.PhoneNumberOffice.Number   = "o2222222";
                AddPhoneNumberOther(create_ctx, create_obj, MINLISTCOUNT + 2);

                create_obj                            = create_ctx.Create <TestCustomObject>();
                create_obj.Birthday                   = DateTime.Now;
                create_obj.PersonName                 = "Third Person";
                create_obj.PhoneNumberMobile          = create_ctx.CreateCompoundObject <TestPhoneCompoundObject>();
                create_obj.PhoneNumberMobile.AreaCode = "3";
                create_obj.PhoneNumberMobile.Number   = "3333333";
                create_obj.PhoneNumberOffice.AreaCode = "o3";
                create_obj.PhoneNumberOffice.Number   = "o3333333";
                AddPhoneNumberOther(create_ctx, create_obj, MINLISTCOUNT + 10);

                create_ctx.SubmitChanges();
            }
        }
예제 #27
0
 public override void SetUp()
 {
     base.SetUp();
     ctx = scope.Resolve<IZetboxContext>();
     ilvm = vmf.CreateViewModel<InstanceListViewModel.Factory>().Invoke(ctx, null, (ObjectClass)NamedObjects.Base.Classes.Zetbox.App.Test.One_to_N_relations_N.Find(ctx), null);
     obj = ctx.Create<One_to_N_relations_N>();
     ctx.SubmitChanges();
 }
예제 #28
0
 public void InitTestObjects()
 {
     ctx = GetContext();
     oneSide1 = ctx.Create<One_to_N_relations_One>();
     oneSide2 = ctx.Create<One_to_N_relations_One>();
     oneSide3 = ctx.Create<One_to_N_relations_One>();
     nSide1 = ctx.Create<One_to_N_relations_N>();
     nSide1.OneSide = oneSide3;
     nSide2 = ctx.Create<One_to_N_relations_N>();
     nSide2.OneSide = oneSide3;
     ctx.SubmitChanges();
     ctx = GetContext();
     oneSide1 = ctx.Find<One_to_N_relations_One>(oneSide1.ID);
     oneSide2 = ctx.Find<One_to_N_relations_One>(oneSide2.ID);
     oneSide3 = ctx.Find<One_to_N_relations_One>(oneSide3.ID);
     nSide1 = ctx.Find<One_to_N_relations_N>(nSide1.ID);
     nSide2 = ctx.Find<One_to_N_relations_N>(nSide2.ID);
 }
예제 #29
0
        private Property CreateProperty(IZetboxContext ctx, int unique)
        {
            var result = ctx.Create <IntProperty>();

            result.Module = ctx.FindPersistenceObject <Module>(_moduleGuid);
            result.Name   = "property" + unique;
            result.ValueModelDescriptor = ctx.FindPersistenceObject <ViewModelDescriptor>(_valueDescGuid);
            return(result);
        }
예제 #30
0
 private void CreateTasks(IZetboxContext ctx, Projekt p)
 {
     for (int i = 0; i < task_projectCount; i++)
     {
         var t = ctx.Create <Task>();
         t.Name = "Task " + i;
         p.Tasks.Add(t);
     }
 }
예제 #31
0
 public void Create_ObjectType()
 {
     using (IZetboxContext ctx = GetContext())
     {
         TestObjClass newObj = ctx.Create(iftFactory(typeof(TestObjClass))) as TestObjClass;
         Assert.That(newObj, Is.Not.Null);
         Assert.That(newObj.Context, Is.Not.Null);
     }
 }
예제 #32
0
        private TestObjClass CreateTestObjClass(IZetboxContext ctx)
        {
            var result = ctx.Create <TestObjClass>();

            result.MyIntProperty = 1;
            result.StringProp    = "test";
            result.TestEnumProp  = TestEnum.First;
            return(result);
        }
예제 #33
0
 public void InitTestObjects()
 {
     ctx            = GetContext();
     oneSide1       = ctx.Create <One_to_N_relations_One>();
     oneSide2       = ctx.Create <One_to_N_relations_One>();
     oneSide3       = ctx.Create <One_to_N_relations_One>();
     nSide1         = ctx.Create <One_to_N_relations_N>();
     nSide1.OneSide = oneSide3;
     nSide2         = ctx.Create <One_to_N_relations_N>();
     nSide2.OneSide = oneSide3;
     ctx.SubmitChanges();
     ctx      = GetContext();
     oneSide1 = ctx.Find <One_to_N_relations_One>(oneSide1.ID);
     oneSide2 = ctx.Find <One_to_N_relations_One>(oneSide2.ID);
     oneSide3 = ctx.Find <One_to_N_relations_One>(oneSide3.ID);
     nSide1   = ctx.Find <One_to_N_relations_N>(nSide1.ID);
     nSide2   = ctx.Find <One_to_N_relations_N>(nSide2.ID);
 }
예제 #34
0
        private void SetUpCreateTask(IZetboxContext ctx, Projekt prj, int i)
        {
            Task t = ctx.Create <Task>();

            t.Name     = prj.Name + " - Task " + (i + 1);
            t.DatumVon = DateTime.Today.AddDays(i);
            t.DatumBis = DateTime.Today.AddDays(2 * i);
            t.Aufwand  = (i + 1);
            prj.Tasks.Add(t);
        }
예제 #35
0
        private void WriteLog(string srcTbl, long srcRows, string dstTbl, long dstRows)
        {
            var log = _logCtx.Create <MigrationLog>();

            log.Timestamp       = DateTime.Now;
            log.Source          = srcTbl;
            log.SourceRows      = (int)srcRows;
            log.Destination     = dstTbl;
            log.DestinationRows = (int)dstRows;
            _logCtx.SubmitChanges();
        }
예제 #36
0
        public void AttachedObjects()
        {
            using (IZetboxContext ctx = GetContext())
            {
                TestObjClass obj = new TestObjClassEfImpl(null);
                ctx.Attach(obj);
                ctx.Create <TestObjClass>();

                Assert.That(ctx.AttachedObjects.Count(), Is.EqualTo(2));
            }
        }
예제 #37
0
        public override void SetUp()
        {
            base.SetUp();

            ctx = GetContext();

            one1 = ctx.Create<One_to_N_relations_One>();
            one2 = ctx.Create<One_to_N_relations_One>();
            n1 = ctx.Create<One_to_N_relations_N>();
            n2 = ctx.Create<One_to_N_relations_N>();

            one1.Name = "One1";
            one2.Name = "One2";
            n1.Name = "N1";
            n2.Name = "N2";

            one1.NSide.Add(n1);
            one1.NSide.Add(n2);

            ctx.SubmitChanges();
        }
예제 #38
0
        public void Import(IZetboxContext ctx, Account account, string fileName)
        {
            List <ImportedTransaction> importedTransactions = Read(fileName);
            var min = importedTransactions.Min(i => i.Date).AddDays(-7);
            var max = importedTransactions.Max(i => i.Date).AddDays(7);

            var transactions = ctx.GetQuery <Transaction>()
                               .Where(i => i.Account == account)
                               .Where(i => i.Date >= min && i.Date <= max)
                               .ToLookup(k => k.ImportHash);

            foreach (var impTx in importedTransactions)
            {
                if (!transactions.Contains(impTx.ImportHash))
                {
                    var newTx = ctx.Create <Transaction>();
                    newTx.Account    = account;
                    newTx.Date       = impTx.Date;
                    newTx.Amount     = impTx.Ammount;
                    newTx.Comment    = impTx.Text;
                    newTx.ImportHash = impTx.ImportHash;

                    foreach (var receipt in impTx.Receipts)
                    {
                        var file = ctx.Create <at.dasz.DocumentManagement.File>();
                        file.IsFileReadonly = true;
                        file.Name           = string.Format("Receipt {0}.txt", impTx.Date.ToShortDateString());
                        using (var stream = new MemoryStream())
                            using (var sw = new StreamWriter(stream))
                            {
                                sw.Write(receipt);
                                sw.Flush();
                                stream.Seek(0, SeekOrigin.Begin);
                                file.Blob = ctx.Find <Blob>(ctx.CreateBlob(stream, file.Name, "text/plain"));
                            }
                        newTx.Documents.Add(file);
                    }
                }
            }
        }
예제 #39
0
        public void ContainsObject_Not()
        {
            using (IZetboxContext ctx = GetContext())
            {
                TestObjClass obj = new TestObjClassEfImpl(null)
                {
                    ID = 10
                };
                ctx.Create <TestObjClass>();
                Assert.That(ctx.AttachedObjects.Count(), Is.EqualTo(1));

                Assert.That(ctx.ContainsObject(ctx.GetInterfaceType(obj), obj.ID), Is.Null);
            }
        }
예제 #40
0
        public void when_setting_N_side_via_index()
        {
            var cls = ctx.GetQuery <ObjectClass>().First();
            var m1  = ctx.Create <Method>();

            m1.Name        = "TestMethod1";
            m1.ObjectClass = cls;
            m1.Module      = cls.Module;
            var m2 = ctx.Create <Method>();

            m2.Name        = "TestMethod2";
            m2.ObjectClass = cls;
            m2.Module      = cls.Module;
            var p1 = ctx.Create <StringParameter>();

            p1.Name   = "p1";
            p1.Method = m1;
            var p2 = ctx.Create <StringParameter>();

            p2.Name   = "p1";
            p2.Method = m2;

            ctx.SubmitChanges();

            Assert.That(p1.Method, Is.SameAs(m1), "first Parent wrong");
            Assert.That(m1.Parameter.ToArray(), Is.EquivalentTo(new[] { p1 }), "first Parameter collection wrong");

            m1.Parameter[0] = p2;

            Assert.That(p1.Method, Is.Null, "first Parent not reset");
            Assert.That(p2.Method, Is.SameAs(m1), "second Parent wrong");
            Assert.That(m1.Parameter.ToArray(), Is.EquivalentTo(new[] { p2 }), "second Parameter collection wrong");

            Assert.That(m1.ObjectState, Is.EqualTo(DataObjectState.Modified));
            Assert.That(p1.ObjectState, Is.EqualTo(DataObjectState.Modified));
            Assert.That(p2.ObjectState, Is.EqualTo(DataObjectState.Modified));
        }
예제 #41
0
        public void Create_T()
        {
            TestObjClass obj = ctx.Create <TestObjClass>();

            Assert.That(obj, Is.Not.Null);
            Assert.That(obj.ID, Is.LessThan(Helper.INVALIDID));
            Assert.That(obj.ObjectState, Is.EqualTo(DataObjectState.New));
            Assert.That(obj.Context, Is.EqualTo(ctx));
        }
예제 #42
0
 public virtual void InitTestObjects()
 {
     ctx = GetContext();
     oneSide1 = ctx.Create<OrderedOneEnd>();
     oneSide2 = ctx.Create<OrderedOneEnd>();
     oneSide3 = ctx.Create<OrderedOneEnd>();
     nSide1 = ctx.Create<OrderedNEnd>();
     nSide2 = ctx.Create<OrderedNEnd>();
     nSide3 = ctx.Create<OrderedNEnd>();
 }
예제 #43
0
파일: App.cs 프로젝트: jrgcubano/zetbox
        private static Assembly FetchOrCreateAssembly(
            IZetboxContext ctx,
            Module guiModule,
            string aName)
        {
            Assembly result = ctx.GetQuery<Assembly>()
                .Where(a => a.Name == aName)
                .ToList()
                .SingleOrDefault();

            if (result == null)
            {
                result = ctx.Create<Assembly>();
                result.Name = aName;
                result.Module = guiModule;
            }

            return result;
        }
예제 #44
0
 private void SetUpCreateTask(IZetboxContext ctx, Projekt prj, int i)
 {
     Task t = ctx.Create<Task>();
     t.Name = prj.Name + " - Task " + (i + 1);
     t.DatumVon = DateTime.Today.AddDays(i);
     t.DatumBis = DateTime.Today.AddDays(2 * i);
     t.Aufwand = (i + 1);
     prj.Tasks.Add(t);
 }
예제 #45
0
        /// <summary>
        /// returns a zetbox Assembly for a given CLR-Assembly, creating it if necessary
        /// </summary>
        public static Assembly ToRef(this System.Reflection.Assembly ass, IZetboxContext ctx)
        {
            if (ass == null) { throw new ArgumentNullException("ass"); }
            if (ctx == null) { throw new ArgumentNullException("ctx"); }

            Assembly result = ass.ToRefOrDefault(ctx);
            if (result == null)
            {
                result = ctx.Create<Assembly>();
                result.Name = ass.FullName;
                // Leave module empty. Must be set external
                // result.Module = ctx.GetQuery<Module>().Single(m => m.Name == "ZetboxBase");
                result.DeploymentRestrictions = DeploymentRestriction.ClientOnly;
            }
            return result;
        }
예제 #46
0
        private static TypeRef CreateTypeRef(Type t, IZetboxContext ctx)
        {
            var result = ctx.Create<TypeRef>();
            var a = t.Assembly.ToRef(ctx);
            result.Assembly = a;

            if (t.IsGenericType)
            {
                var genericDefinition = t.GetGenericTypeDefinition();
                result.FullName = genericDefinition.FullName;
                result.GenericArguments.Clear();
                foreach (var arg in t.GetGenericArguments())
                {
                    result.GenericArguments.Add(arg.ToRef(ctx));
                }
            }
            else
            {
                result.FullName = t.FullName;
            }

            if (t.BaseType != null)
            {
                result.Parent = t.BaseType.ToRef(ctx);
            }
            return result;
        }
예제 #47
0
        public DataObjectViewModel GetDataObject(IZetboxContext ctx)
        {
            if (ctx == null) { throw new ArgumentNullException("ctx"); }

            IDataObject obj;

            if (ID <= Helper.INVALIDID)
            {
                obj = ctx.Create(ZetboxContextManagerModule.IftFactory(Type.GetSystemType()));
                ID = obj.ID;
            }
            else
            {
                obj = (IDataObject)ctx.Find(ZetboxContextManagerModule.IftFactory(Type.GetSystemType()), ID);
            }

            return DataObjectViewModel.Fetch(ZetboxContextManagerModule.ViewModelFactory, ctx, null, obj);
        }
예제 #48
0
        private static void CreateViewModelDescriptors(IZetboxContext ctx, SR.Assembly srAssembly)
        {
            using (Logging.Log.InfoTraceMethodCallFormat("CreateViewModelDescriptors", "Creating ViewModelDescriptors"))
            {
                var liveDescriptors = new HashSet<ViewModelDescriptor>();

                foreach (var type in GetTypes(srAssembly))
                {
                    object attr;
                    // http://blogs.msdn.com/b/kaevans/archive/2005/10/24/484186.aspx
                    if (type.Assembly.ReflectionOnly)
                    {
                        attr = SR.CustomAttributeData.GetCustomAttributes(type).FirstOrDefault(i => i.Constructor.DeclaringType.FullName == typeof(ViewModelDescriptorAttribute).FullName);
                    }
                    else
                    {
                        attr = type.GetCustomAttributes(typeof(ViewModelDescriptorAttribute), false).FirstOrDefault() as ViewModelDescriptorAttribute;
                    }
                    if (attr != null)
                    {
                        var typeName = type.GetSimpleName();
                        var descr = ctx.GetQuery<ViewModelDescriptor>().FirstOrDefault(i => i.ViewModelTypeRef == typeName);
                        if (descr == null)
                        {
                            descr = ctx.Create<ViewModelDescriptor>();
                            descr.ViewModelTypeRef = typeName;
                            descr.Description = "TODO: Add description";
                        }
                        else
                        {
                            descr.Deleted = false;
                        }

                        liveDescriptors.Add(descr);
                    }
                }

                var simpleAssemblyName = srAssembly.GetSimpleName();
                var deadDescriptors = ctx
                    .GetQuery<ViewModelDescriptor>()
                    .ToList()
                    .Where(vmd => TypeSpec.Parse(vmd.ViewModelTypeRef).AssemblyName.IfNullOrWhiteSpace(string.Empty).Split(',').FirstOrDefault().IfNullOrWhiteSpace(string.Empty).Trim() == simpleAssemblyName)
                    .Except(liveDescriptors);

                foreach (var d in deadDescriptors)
                {
                    d.Deleted = true;
                }
            }
        }
예제 #49
0
 public override void SetUp()
 {
     base.SetUp();
     ctx = GetContext();
     obj = ctx.Create<Assembly>();
     obj.Name = "TestAssembly";
     obj.Module = ctx.GetQuery<Module>().First(m => m.Name == "TestModule");
 }
예제 #50
0
 private void CreateTasks(IZetboxContext ctx, Projekt p)
 {
     for (int i = 0; i < task_projectCount; i++)
     {
         var t = ctx.Create<Task>();
         t.Name = "Task " + i;
         p.Tasks.Add(t);
     }
 }
예제 #51
0
 private static void CreateViewModelDescriptors(IZetboxContext ctx, Dictionary<int, TypeRef> newTypes)
 {
     using (Logging.Log.InfoTraceMethodCallFormat("CreateViewModelDescriptors", "Creating ViewModelDescriptors"))
     {
         foreach (var tr in newTypes.Values)
         {
             var type = tr.AsType(false);
             if (type != null)
             {
                 object attr;
                 // http://blogs.msdn.com/b/kaevans/archive/2005/10/24/484186.aspx
                 if (type.Assembly.ReflectionOnly)
                 {
                     attr = System.Reflection.CustomAttributeData.GetCustomAttributes(type).FirstOrDefault(i => i.Constructor.DeclaringType.FullName == typeof(ViewModelDescriptorAttribute).FullName);
                 }
                 else
                 {
                     attr = type.GetCustomAttributes(typeof(ViewModelDescriptorAttribute), false).FirstOrDefault() as ViewModelDescriptorAttribute;
                 }
                 if (attr != null)
                 {
                     var descr = ctx.GetQuery<ViewModelDescriptor>().FirstOrDefault(i => i.ViewModelRef == tr);
                     if (descr == null)
                     {
                         descr = ctx.Create<ViewModelDescriptor>();
                         descr.ViewModelRef = tr;
                         descr.Description = "TODO: Add description";
                     }
                 }
             }
         }
     }
 }
예제 #52
0
        private static void CreateViewDescriptors(IZetboxContext ctx, SR.Assembly srAssembly)
        {
            using (Logging.Log.InfoTraceMethodCallFormat("CreateViewDescriptors", "Creating ViewDescriptors"))
            {
                var liveDescriptors = new HashSet<ViewDescriptor>();

                foreach (var type in GetTypes(srAssembly))
                {
                    object attr;
                    Toolkit? tk = null;
                    // http://blogs.msdn.com/b/kaevans/archive/2005/10/24/484186.aspx
                    if (type.Assembly.ReflectionOnly)
                    {
                        attr = SR.CustomAttributeData.GetCustomAttributes(type).FirstOrDefault(i => i.Constructor.DeclaringType.FullName == typeof(ViewDescriptorAttribute).FullName);
                        if (attr != null) tk = (Toolkit)((SR.CustomAttributeData)attr).ConstructorArguments.Single().Value;
                    }
                    else
                    {
                        attr = type.GetCustomAttributes(typeof(ViewDescriptorAttribute), false).FirstOrDefault() as ViewDescriptorAttribute;
                        if (attr != null) tk = ((ViewDescriptorAttribute)attr).Toolkit;
                    }
                    if (attr != null)
                    {
                        var typeName = type.GetSimpleName();

                        // if a view can be used under multiple ControlKinds, it needs to have multiple ViewDescriptors
                        var descrList = ctx.GetQuery<ViewDescriptor>().Where(i => i.ControlTypeRef == typeName).ToList();
                        if (descrList.Count == 0)
                        {
                            var descr = ctx.Create<ViewDescriptor>();
                            descr.ControlTypeRef = typeName;
                            if (tk != null) descr.Toolkit = tk.Value;
                            liveDescriptors.Add(descr);
                        }
                        else
                        {
                            foreach (var descr in descrList)
                            {
                                descr.Deleted = false;
                                liveDescriptors.Add(descr);
                            }
                        }
                    }
                }

                var simpleAssemblyName = srAssembly.GetSimpleName();
                var deadDescriptors = ctx
                    .GetQuery<ViewDescriptor>()
                    .ToList()
                    .Where(vmd => TypeSpec.Parse(vmd.ControlTypeRef).AssemblyName.IfNullOrWhiteSpace(string.Empty).Split(',').FirstOrDefault().IfNullOrWhiteSpace(string.Empty).Trim() == simpleAssemblyName)
                    .Except(liveDescriptors);
                foreach (var d in deadDescriptors)
                {
                    d.Deleted = true;
                }
            }
        }
예제 #53
0
 private TestObjClass CreateTestObjClass(IZetboxContext ctx)
 {
     var result = ctx.Create<TestObjClass>();
     result.MyIntProperty = 1;
     result.StringProp = "test";
     result.TestEnumProp = TestEnum.First;
     return result;
 }
예제 #54
0
        private static Property ShowCreatePropertyDialog(IZetboxContext ctx, ObjectClass propCls, Module targetModule, out bool show)
        {
            var ifType = propCls.GetDescribedInterfaceType();

            var dlg = _vmf.CreateDialog(ctx, string.Format(Zetbox.App.Projekte.Client.ZetboxBase.Strings.CreatePropertyDlg_Title, ifType.Type.Name))
                .AddString("name", NamedObjects.Base.Classes.Zetbox.App.Base.Property_Properties.Name.Find(_frozenCtx).GetLabel())
                .AddString("label", NamedObjects.Base.Classes.Zetbox.App.Base.Property_Properties.Label.Find(_frozenCtx).GetLabel(), allowNullInput: true)
                .AddString("description", NamedObjects.Base.Classes.Zetbox.App.Base.Property_Properties.Description.Find(_frozenCtx).GetLabel(), allowNullInput: true)
                .AddString("categorytags", NamedObjects.Base.Classes.Zetbox.App.Base.Property_Properties.CategoryTags.Find(_frozenCtx).GetLabel(), allowNullInput: true, vmdesc: NamedObjects.Gui.ViewModelDescriptors.Zetbox_Client_Presentables_ZetboxBase_TagPropertyEditorViewModel.Find(_frozenCtx))
                .AddObjectReference("module", NamedObjects.Base.Classes.Zetbox.App.Base.Property_Properties.Module.Find(_frozenCtx).GetLabel(), typeof(Module).GetObjectClass(_frozenCtx), value: targetModule)
                .AddBool("isNullable", Zetbox.App.Projekte.Client.ZetboxBase.Strings.IsNullable, value: true);

            if (typeof(StringProperty).IsAssignableFrom(ifType.Type))
            {
                var p = NamedObjects.Base.Classes.Zetbox.App.Base.StringRangeConstraint_Properties.MaxLength.Find(_frozenCtx);
                dlg.AddInt("str_maxlengt", p.GetLabel(), allowNullInput: true, description: p.GetDescription());
            }
            if (typeof(DateTimeProperty).IsAssignableFrom(ifType.Type))
            {
                var p = NamedObjects.Base.Classes.Zetbox.App.Base.DateTimeProperty_Properties.DateTimeStyle.Find(_frozenCtx);
                dlg.AddEnumeration("dt_style", p.GetLabel(), _frozenCtx.FindPersistenceObject<Enumeration>(new Guid("1385e46d-3e5b-4d91-bf9a-94a740f08ba1")), description: p.GetDescription(), value: (int)DateTimeStyles.Date);
            }
            if (typeof(DecimalProperty).IsAssignableFrom(ifType.Type))
            {
                var p = NamedObjects.Base.Classes.Zetbox.App.Base.DecimalProperty_Properties.Precision.Find(_frozenCtx);
                var s = NamedObjects.Base.Classes.Zetbox.App.Base.DecimalProperty_Properties.Scale.Find(_frozenCtx);
                dlg.AddInt("decimal_precision", p.GetLabel(), description: p.GetDescription(), value: 10);
                dlg.AddInt("decimal_scale", s.GetLabel(), description: s.GetDescription(), value: 2);
            }
            if (typeof(EnumerationProperty).IsAssignableFrom(ifType.Type))
            {
                var p = NamedObjects.Base.Classes.Zetbox.App.Base.EnumerationProperty_Properties.Enumeration.Find(_frozenCtx);
                dlg.AddObjectReference("enum", p.GetLabel(), typeof(Enumeration).GetObjectClass(_frozenCtx), description: p.GetDescription());
            }
            if (typeof(CompoundObjectProperty).IsAssignableFrom(ifType.Type))
            {
                var p = NamedObjects.Base.Classes.Zetbox.App.Base.CompoundObjectProperty_Properties.CompoundObjectDefinition.Find(_frozenCtx);
                dlg.AddObjectReference("cp_def", p.GetLabel(), typeof(CompoundObject).GetObjectClass(_frozenCtx), description: p.GetDescription());
            }
            if (typeof(IntProperty).IsAssignableFrom(ifType.Type))
            {
                var min = NamedObjects.Base.Classes.Zetbox.App.Base.IntegerRangeConstraint_Properties.Min.Find(_frozenCtx);
                var max = NamedObjects.Base.Classes.Zetbox.App.Base.IntegerRangeConstraint_Properties.Max.Find(_frozenCtx);
                dlg.AddInt("int_min", min.GetLabel(), description: min.GetDescription(), allowNullInput: true);
                dlg.AddInt("int_max", max.GetLabel(), description: max.GetDescription(), allowNullInput: true);
            }

            dlg.AddBool("show", Zetbox.App.Projekte.Client.ZetboxBase.Strings.ShowPropertyWhenFinished, value: false, description: Zetbox.App.Projekte.Client.ZetboxBase.Strings.ShowPropertyWhenFinishedDescription);

            Property newProp = null;
            bool localShow = false;
            dlg.Show(((values) =>
            {
                newProp = (Property)ctx.Create(ifType);
                newProp.Name = (string)values["name"];
                newProp.Label = (string)values["label"];
                newProp.Description = (string)values["description"];
                newProp.CategoryTags = (string)values["categorytags"];
                newProp.Module = (Module)values["module"];
                if (!(bool)values["isNullable"])
                {
                    newProp.Constraints.Add(ctx.Create<NotNullableConstraint>());
                }

                if (values.ContainsKey("str_maxlengt"))
                {
                    var c = ctx.Create<StringRangeConstraint>();
                    c.MinLength = 0;
                    c.MaxLength = (int?)values["str_maxlengt"];
                    newProp.Constraints.Add(c);
                }
                if (values.ContainsKey("int_min") && values.ContainsKey("int_max") && values["int_min"] != null && values["int_max"] != null)
                {
                    var c = ctx.Create<IntegerRangeConstraint>();
                    c.Min = (int)values["int_min"];
                    c.Max = (int)values["int_max"];
                    newProp.Constraints.Add(c);
                }
                if (values.ContainsKey("dt_style"))
                {
                    ((DateTimeProperty)newProp).DateTimeStyle = (DateTimeStyles)values["dt_style"];
                }
                if (values.ContainsKey("decimal_precision"))
                {
                    ((DecimalProperty)newProp).Precision = (int)values["decimal_precision"];
                }
                if (values.ContainsKey("decimal_scale"))
                {
                    ((DecimalProperty)newProp).Scale = (int)values["decimal_scale"];
                }
                if (values.ContainsKey("enum"))
                {
                    ((EnumerationProperty)newProp).Enumeration = (Enumeration)values["enum"];
                }
                if (values.ContainsKey("cp_def"))
                {
                    ((CompoundObjectProperty)newProp).CompoundObjectDefinition = (CompoundObject)values["cp_def"];
                }

                if (newProp is CompoundObjectProperty)
                {
                    ((CompoundObjectProperty)newProp).IsList = false;
                    ((CompoundObjectProperty)newProp).HasPersistentOrder = false;
                }

                localShow = (bool)values["show"];
            }));

            show = localShow;
            return newProp;
        }
 private SavedListConfiguration GetSavedConfig(IZetboxContext ctx)
 {
     var config = ctx.GetQuery<SavedListConfiguration>()
         .Where(i => i.Type.ExportGuid == Parent.DataType.ExportGuid) // Parent.DataType might be from FrozenContext
         .Where(i => i.Owner.ID == this.CurrentPrincipal.ID)
         .FirstOrDefault();
     if (config == null)
     {
         config = ctx.Create<SavedListConfiguration>();
         config.Owner = ctx.Find<Identity>(CurrentPrincipal.ID);
         config.Type = ctx.FindPersistenceObject<ObjectClass>(Parent.DataType.ExportGuid);  // Parent.DataType might be from FrozenContext
     }
     return config;
 }
예제 #56
0
 protected override void CreateTestData()
 {
     base.CreateTestData();
     newCtx = GetContext();
     newObj = newCtx.Create<TestCustomObject>();
 }