/// <summary> /// Save the data for an object and adds the reference to a list of instances /// </summary> public void InsertObject(ObjectData data) { if (data.Oid == null) { throw new ArgumentException("Oid must be non-null"); } string type = data.ClassName; IOid oid = data.Oid; AddData(oid, type, data); AddInstance(oid, type); }
public virtual void TestValueField() { FileVersion.Clock = new TestClock(); TestProxySpecification type = new TestProxySpecification(typeof (string)); ObjectData objectData = new ObjectData(type, SerialOid.CreatePersistent(13, typeof(string).FullName), new FileVersion("")); Assert.AreEqual(null, objectData.Value("name")); objectData.SetField("name", "value"); Assert.AreEqual("value", objectData.Value("name")); IEnumerator<string> e = objectData.Fields(); Assert.IsTrue(e.MoveNext()); Assert.IsNotNull(e.Current); Assert.IsFalse(e.MoveNext()); }
public override void SetUp() { base.SetUp(); manager = new XmlDataManager(); XmlFile.DirectoryName = XmlDataManagerTest.testDir; ClearTestDirectory(); FileVersion.Clock = new TestClock(); oids = new SerialOid[SIZE]; data = new ObjectData[SIZE]; INakedObjectSpecification type = system.GetSpecification(typeof(object)); pattern = new ObjectData(type, null, new FileVersion("user", 13)); for (int i = 0; i < SIZE; i++) { oids[i] = SerialOid.CreatePersistent(i, typeof(object).FullName); data[i] = new ObjectData(type, oids[i], new FileVersion("user", 13)); manager.InsertObject(data[i]); } }
public virtual int NumberOfInstances(ObjectData pattern) { return 5; }
public void InsertObject(ObjectData data) {}
public virtual void AddInline(ObjectData fieldContent, string fieldId) { SetField(fieldId, fieldContent); }
public void LoadNode(XElement Node, ref CollectionData collection, ref ObjectData objectData, ref string fieldName) { string tag = Node.Name.LocalName; if (objectData != null) { if (tag.Equals("value")) { fieldName = Node.Attribute("field").Value; objectData.SetField(fieldName, Node.Value); } else if (tag.Equals("inline")) { CollectionData sinkCollection = null; ObjectData inlineObjectData = null; string sinkName = ""; fieldName = Node.Attribute("field").Value; LoadNode(Node.Element("naked-object"), ref sinkCollection, ref inlineObjectData, ref sinkName); objectData.SetField(fieldName, inlineObjectData); } else if (tag.Equals("association")) { fieldName = Node.Attribute("field").Value; long id = Convert.ToInt64(Node.Attribute("ref").Value, 16); objectData.SetField(fieldName, SerialOid.CreatePersistent(id, Node.Attribute("Type").Value)); } else if (tag.Equals("element")) { long id = Convert.ToInt64(Node.Attribute("ref").Value, 16); objectData.AddElement(fieldName, SerialOid.CreatePersistent(id, Node.Attribute("Type").Value)); } else if (tag.Equals("multiple-association")) { fieldName = Node.Attribute("field").Value; objectData.InitCollection(fieldName); } } else if (collection != null) { if (tag.Equals("element")) { long id = Convert.ToInt64(Node.Attribute("ref").Value, 16); collection.AddElement(SerialOid.CreatePersistent(id, Node.Attribute("Type").Value)); } } else { if (tag.Equals("naked-object")) { string type = Node.Attribute("Type").Value; string user = Node.Attribute("user").Value; IVersion version = GetVersion(Node, user); IOid oid = GetOid(Node, type); INakedObjectSpecification spec = NakedObjectsContext.Reflector.LoadSpecification(type); objectData = new ObjectData(spec, oid, version); } else if (tag.Equals("collection")) { string type = Node.Attribute("Type").Value; long version = Convert.ToInt64(Node.Attribute("ver").Value, 16); string user = Node.Attribute("user").Value; long id = Convert.ToInt64(Node.Attribute("id").Value, 16); INakedObjectSpecification spec = NakedObjectsContext.Reflector.LoadSpecification(type); IOid oid = SerialOid.CreatePersistent(id, type); collection = new CollectionData(spec, oid, new FileVersion(user, version)); } else { throw new XmlException("Invalid data"); } } }
public virtual int NumberOfInstances(ObjectData pattern) { return(5); }
public void InsertObject(ObjectData data) { }