예제 #1
0
        private static void InitInlineObjectSetupReference(INakedObject nakedObject, ObjectData data, INakedObjectAssociation field)
        {
            var          fieldData    = (Data)data.GetField(field.Id);
            IOid         referenceOid = fieldData.Oid;
            INakedObject reference    = SetupReference(field, referenceOid, fieldData, nakedObject);

            Persistor.InitInlineObject(nakedObject.Object, reference.Object);
        }
예제 #2
0
        private void InitObjectSetupReference(INakedObject nakedObject, ObjectData data, INakedObjectAssociation field)
        {
            var referenceOid = (IOid)data.GetField(field.Id);

            if (referenceOid != null)
            {
                Data         fieldData = dataManager.LoadData(referenceOid);
                INakedObject reference = SetupReference(field, referenceOid, fieldData, nakedObject);
            }
        }
예제 #3
0
        public virtual void TestInsertObjectWithFields()
        {
            ObjectData data = CreateData(typeof(Role), 99, new FileVersion("user", 13));

            data.SetField("Person", SerialOid.CreatePersistent(101, typeof(Person).FullName));
            Assert.IsNotNull(data.GetField("Person"));
            data.SetField("Name", "Harry");
            Assert.IsNotNull(data.Value("Name"));

            manager.InsertObject(data);

            ObjectData read = manager.LoadObjectData(data.Oid);

            Assert.AreEqual(data.Oid, read.Oid);
            Assert.AreEqual(data.ClassName, read.ClassName);

            Assert.AreEqual(data.GetField("Person"), read.GetField("Person"));
            Assert.AreEqual(data.Value("Name"), read.Value("Name"));
        }
예제 #4
0
        public virtual void TestSaveObject()
        {
            data[2].SetField("Person", SerialOid.CreatePersistent(231, typeof(Person).FullName));
            data[2].SetField("Name", "Fred");
            manager.Save(data[2]);

            Assert.IsTrue(Enumerable.Contains(manager.GetInstances(system.GetSpecification(typeof(object))), data[2]));
            ObjectData read = manager.LoadObjectData(oids[2]);

            Assert.AreEqual(data[2], read);
            Assert.AreEqual(data[2].Value("Name"), read.Value("Name"));
            Assert.AreEqual(data[2].GetField("Person"), read.GetField("Person"));
        }
예제 #5
0
        private void InitObjectSetupCollection(INakedObject nakedObject, ObjectData data, INakedObjectAssociation field)
        {
            /*
             * The internal collection is already a part of the object, and therefore cannot be recreated, but its
             * oid must be set
             */
            IList <IOid> refs       = (IList <IOid>)data.GetField(field.Id) ?? new List <IOid>();
            INakedObject collection = field.GetNakedObject(nakedObject);

            collection.ResolveState.Handle(Events.StartResolvingEvent);

            var elements = new List <INakedObject>();

            foreach (IOid elementOid in refs)
            {
                INakedObject adapter = Persistor.GetAdapterFor(elementOid) ?? GetObject(elementOid, null);
                elements.Add(adapter);
            }
            ICollectionFacet facet = collection.GetCollectionFacetFromSpec();

            facet.Init(collection, elements.ToArray());
            collection.ResolveState.Handle(Events.EndResolvingEvent);
        }