private void WriteParticle(UniqueID uid, IAether particle) { string particleName = Engine.GetParticleName(particle); uid.Save(this); bool isParticleSerialized = serialisedParticles.Contains(uid); writer.Write(isParticleSerialized); if (!isParticleSerialized) { if (!uid.Equals(UniqueID.Unknown)) { serialisedParticles.Add(uid); } writer.Write(particleName); //name Type particleType = particle.GetType(); string typeName = particleType.FullName + ", " + particleType.Assembly.GetName().Name; writer.Write(typeName); //type IAetherSerialization serialisableParticle = particle as IAetherSerialization; bool isSerialisableParticle = serialisableParticle != null; writer.Write(isSerialisableParticle); //mark whether Particle has data to serialize if (isSerialisableParticle) { serialisableParticle.Save(this); } } return; }
public override bool Equals(object obj) { if (obj == null || !(obj is AdvicesEntity)) { return(false); } return(UniqueID.Equals((obj as AdvicesEntity).UniqueID)); }
public override bool Equals(object obj) { if (obj == null) { return(false); } RoomEditNode other = obj as RoomEditNode; if (other == null) { return(false); } return(UniqueID.Equals(other.UniqueID)); }
private void ReadParticle(out UniqueID uid, out IAether particle) { uid = new UniqueID(); uid.Load(this); bool isParticleSerialized = reader.ReadBoolean(); if (isParticleSerialized) { particle = deserialisedParticles[uid]; return; } string particleName = reader.ReadString(); string AssemblyQualifiedName = reader.ReadString(); if (Engine.ContainsName(particleName)) { particle = Engine[particleName]; } else { particle = TypeResolver.CreateInstance(AssemblyQualifiedName); } if (!uid.Equals(UniqueID.Unknown)) { deserialisedParticles.Add(uid, particle); } bool isSerialisableParticle = reader.ReadBoolean(); if (isSerialisableParticle) { IAetherSerialization serialisableParticle = particle as IAetherSerialization; serialisableParticle.Load(this); } if (particleName != string.Empty) { Engine.SetParticleName(particle, particleName); } return; }
private void WriteParticle(UniqueID uid, IAether particle) { string particleName = Engine.GetParticleName(particle); if (serialisedParticles.Contains(uid)) { writer.WriteStartElement("AetherParticleRef"); writer.WriteStartAttribute("UID"); uid.Save(this); writer.WriteEndAttribute(); if (particleName != String.Empty) { writer.WriteAttributeString("Name", particleName); } writer.WriteEndElement(); return; } else { Type particleType = particle.GetType(); if (!uid.Equals(UniqueID.Unknown)) { serialisedParticles.Add(uid); } writer.WriteStartElement("AetherParticle"); writer.WriteStartAttribute("UID"); uid.Save(this); writer.WriteEndAttribute(); if (particleName != String.Empty) { writer.WriteAttributeString("Name", particleName); } string typeName = particleType.FullName + ", " + particleType.Assembly.GetName().Name; writer.WriteAttributeString("Type", typeName); IAetherSerialization serialisableParticle = particle as IAetherSerialization; if (serialisableParticle != null) { serialisableParticle.Save(this); } writer.WriteEndElement(); } return; }
public UniqueID RegisterParticle(IAether particle) { // check if particle is allready registered UniqueID uid = FindUniqueId(particle); if (!uid.Equals(UniqueID.Unknown)) { return(uid); } //create new uid and add particle uid = EngineData.NextUniqueID.GetNext(); EngineData.NextUniqueID = uid; this.Add(uid, particle); //notify managers foreach (IAetherManager particleManager in Managers) { particleManager.RegisterParticle(uid, particle); } return(uid); }
private void ReadParticle(out UniqueID uid, out IAether particle) { uid = new UniqueID(); particle = null; string elementName = reader.Name; //read attribute string particleName = string.Empty; string typeName = string.Empty; while (reader.MoveToNextAttribute()) { switch (reader.Name) { case "UID": uid.Load(this); break; case "Name": particleName = reader.ReadContentAsString(); break; case "Type": typeName = reader.ReadContentAsString(); break; } } reader.MoveToElement(); bool isEmptyElement = reader.IsEmptyElement; reader.ReadStartElement(); if (elementName == "AetherParticleRef") { particle = deserialisedParticles[uid]; } else if (elementName == "AetherParticle") { if (Engine.ContainsName(particleName)) { //TOD: is this even possible? //isn't it a bug to deserialize an object using a name for cache key? //System.Diagnostics.Debug.Assert(false); particle = Engine[particleName]; } else { particle = TypeResolver.CreateInstance(typeName); } if (!uid.Equals(UniqueID.Unknown)) { deserialisedParticles.Add(uid, particle); } //particle = (IAetherParticle)FormatterServices.GetUninitializedObject(particleType); //this behaves the same the build in Serialisation. Not available on WP7 IAetherSerialization serialisableParticle = particle as IAetherSerialization; if (serialisableParticle != null) { serialisableParticle.Load(this); } particle = TypeResolver.Convert(particle); deserialisedParticles[uid] = particle; // update converted particle if (particleName != string.Empty) { Engine.SetParticleName(particle, particleName); } if (!isEmptyElement) { reader.ReadEndElement(); } } return; }