public void One_Part_Names() { var act1 = ObjectIdentifierFactory.Create("Object"); var act2 = ObjectIdentifierFactory.Create("[Object]"); Assert.AreEqual("[Object]", act1.ToString()); Assert.AreEqual(act1.ToString(), act2.ToString()); Assert.IsFalse(act1.HasExternalParts); Assert.IsFalse(act2.HasExternalParts); Assert.AreEqual(1, act1.Parts.Count); Assert.AreEqual(1, act2.Parts.Count); }
public void Four_Part_Names() { var act1 = ObjectIdentifierFactory.Create("Server.Database.Schema.Object"); var act2 = ObjectIdentifierFactory.Create("[Server].[Database].[Schema].[Object]"); Assert.AreEqual("[Server].[Database].[Schema].[Object]", act1.ToString()); Assert.AreEqual(act1.ToString(), act2.ToString()); Assert.IsTrue(act1.HasExternalParts); Assert.IsTrue(act2.HasExternalParts); Assert.AreEqual(2, act1.Parts.Count); Assert.AreEqual(2, act2.Parts.Count); Assert.AreEqual(2, act1.ExternalParts.Count); Assert.AreEqual(2, act2.ExternalParts.Count); }
public object restoreObject(XmlReader xmlReader) { Object lastReadObject = null; try { while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { if (xmlReader.Name.Equals(SAVEABLE_ELEMENT)) { int version = 0; String versionStr = xmlReader.GetAttribute(VERSION_ATTIBUTE); if (versionStr != null) { version = NumberParser.ParseInt(versionStr); } ObjectIdentifier objectId = ObjectIdentifierFactory.CreateObjectIdentifier(NumberParser.ParseLong(xmlReader.GetAttribute(ID_ATTIBUTE)), xmlReader.GetAttribute(TYPE_ATTRIBUTE), typeFinder); loadControl.startDefiningObject(objectId, version); //If the element is empty do not bother to loop looking for elements. if (!xmlReader.IsEmptyElement) { while (!(xmlReader.Name == SAVEABLE_ELEMENT && xmlReader.NodeType == XmlNodeType.EndElement) && xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element) { valueReaders[xmlReader.Name].readValue(loadControl, xmlReader); } } } lastReadObject = loadControl.createCurrentObject(); } } } } finally { loadControl.reset(); } return(lastReadObject); }
public void Two_Part_Names() { var act1 = ObjectIdentifierFactory.Create("Schema.Object"); var act2 = ObjectIdentifierFactory.Create("[Schema].[Object]"); var act3 = ObjectIdentifierFactory.Create("Schema.[Object]"); var act4 = ObjectIdentifierFactory.Create("[Schema].Object"); Assert.AreEqual("[Schema].[Object]", act1.ToString()); Assert.AreEqual(act1.ToString(), act2.ToString()); Assert.AreEqual(act1.ToString(), act3.ToString()); Assert.AreEqual(act1.ToString(), act4.ToString()); Assert.IsFalse(act1.HasExternalParts); Assert.IsFalse(act2.HasExternalParts); Assert.IsFalse(act3.HasExternalParts); Assert.IsFalse(act4.HasExternalParts); Assert.AreEqual(2, act1.Parts.Count); Assert.AreEqual(2, act2.Parts.Count); Assert.AreEqual(2, act3.Parts.Count); Assert.AreEqual(2, act4.Parts.Count); }
/// <summary> /// Read the json header object, it must come first in any saveable object. The reader should /// be on the _saveable PropertyName. It will advance the reader to the node for the end of the /// header object. /// </summary> /// <param name="reader">This must currently be on the _saveable PropertyName</param> /// <param name="version">The version number of the object.</param> /// <returns></returns> private ObjectIdentifier ParseHeaderObject(JsonReader reader, ref int version) { if (reader.TokenType != JsonToken.PropertyName) { throw new InvalidOperationException($"Saveable Json Objects must start with a header object named with the type to load."); } version = 0; long id = 0; String type = reader.Value.ToString(); bool inHeaderObject = true; while (inHeaderObject && reader.Read()) { switch (reader.TokenType) { case JsonToken.PropertyName: var propName = reader.Value.ToString(); switch (propName) { case "version": version = reader.ReadAsInt32().Value; break; case "id": id = NumberParser.ParseLong(reader.ReadAsString()); break; } break; case JsonToken.EndObject: inHeaderObject = false; break; } } return(ObjectIdentifierFactory.CreateObjectIdentifier(id, type, typeFinder)); }
public static void Touch() { ObjectIdentifierFactory.AddCreationMethod("Medical.MedicalRmlSlide, Standalone", CreateObjectIdentifier); }