Beispiel #1
0
        /// <summary>
        /// Serialize this entity's live data to a binary stream
        /// </summary>
        /// <returns>the binary stream</returns>
        public override byte[] Serialize()
        {
            var settings = new XmlWriterSettings {
                OmitXmlDeclaration = true, Encoding = Encoding.UTF8
            };
            var charData = (IRoomData)DataTemplate;

            var entityData = new XDocument(
                new XElement("root",
                             new XAttribute("formattingVersion", liveDataVersion),
                             new XAttribute("Birthmark", BirthMark),
                             new XAttribute("Birthdate", Birthdate),
                             new XElement("BackingData",
                                          new XAttribute("ID", charData.ID),
                                          new XAttribute("Name", charData.Name),
                                          new XAttribute("Medium", charData.Medium.ID),
                                          new XAttribute("Zone", charData.ZoneAffiliation.ID),
                                          new XAttribute("LastRevised", charData.LastRevised),
                                          new XAttribute("Created", charData.Created),
                                          new XElement("Borders", charData.SerializeBorders())),
                             new XElement("LiveData",
                                          new XAttribute("Keywords", string.Join(",", Keywords)),
                                          new XElement("DimensionalModel",
                                                       new XAttribute("Length", Model.Length),
                                                       new XAttribute("Height", Model.Height),
                                                       new XAttribute("Width", Model.Width))),
                             new XElement("ObjectsInRoom"),
                             new XElement("MobilesInside")
                             ));

            foreach (var item in ObjectsInRoom.EntitiesContained())
            {
                entityData.Root.Element("ObjectsInRoom").Add(new XElement("Item", item.BirthMark));
            }

            foreach (var item in MobilesInside.EntitiesContained().Where(ent => ent.GetType() != typeof(Player)))
            {
                entityData.Root.Element("MobilesInside").Add(new XElement("Item", item.BirthMark));
            }

            //pathways will load themselves

            var entityBinaryConvert = new DataUtility.EntityFileData(entityData);

            using (var memoryStream = new MemoryStream())
                using (var xmlWriter = XmlWriter.Create(memoryStream, settings))
                {
                    entityData.WriteTo(xmlWriter);
                    xmlWriter.Flush();
                    entityBinaryConvert.XmlBinary = memoryStream.ToArray();
                }

            return(entityBinaryConvert.XmlBinary);
        }
Beispiel #2
0
        /// <summary>
        /// Serialize this entity's live data to a binary stream
        /// </summary>
        /// <returns>the binary stream</returns>
        public override byte[] Serialize()
        {
            var settings = new XmlWriterSettings {
                OmitXmlDeclaration = true, Encoding = Encoding.UTF8
            };
            var charData = (IPathwayData)DataTemplate;

            var entityData = new XDocument(
                new XElement("root",
                             new XAttribute("formattingVersion", liveDataVersion),
                             new XAttribute("Birthmark", BirthMark),
                             new XAttribute("Birthdate", Birthdate),
                             new XElement("BackingData",
                                          new XAttribute("ID", charData.ID),
                                          new XAttribute("Name", charData.Name),
                                          new XAttribute("LastRevised", charData.LastRevised),
                                          new XAttribute("Created", charData.Created),
                                          new XAttribute("DegreesFromNorth", charData.DegreesFromNorth),
                                          new XAttribute("ToLocationID", charData.ToLocationID),
                                          new XAttribute("ToLocationType", charData.ToLocationType),
                                          new XAttribute("FromLocationID", charData.FromLocationID),
                                          new XAttribute("FromLocationType", charData.FromLocationType),
                                          new XAttribute("MessageToActor", charData.MessageToActor),
                                          new XAttribute("MessageToOrigin", charData.MessageToOrigin),
                                          new XAttribute("MessageToDestination", charData.MessageToDestination),
                                          new XAttribute("AudibleToSurroundings", charData.AudibleToSurroundings),
                                          new XAttribute("AudibleStrength", charData.AudibleStrength),
                                          new XAttribute("VisibleToSurroundings", charData.VisibleToSurroundings),
                                          new XAttribute("VisibleStrength", charData.VisibleStrength)),
                             new XElement("LiveData",
                                          new XAttribute("Keywords", string.Join(",", Keywords)),
                                          new XAttribute("RoomTo", ToLocation.BirthMark),
                                          new XAttribute("RoomFrom", FromLocation.BirthMark),
                                          new XElement("DimensionalModel",
                                                       new XAttribute("Length", Model.Length),
                                                       new XAttribute("Height", Model.Height),
                                                       new XAttribute("Width", Model.Width),
                                                       new XAttribute("ID", charData.Model.ModelBackingData.ID),
                                                       new XElement("ModellingData", Model.ModelBackingData.SerializeModel()),
                                                       new XElement("MaterialCompositions", Model.SerializeMaterialCompositions())))
                             ));

            var entityBinaryConvert = new DataUtility.EntityFileData(entityData);

            using (var memoryStream = new MemoryStream())
                using (var xmlWriter = XmlWriter.Create(memoryStream, settings))
                {
                    entityData.WriteTo(xmlWriter);
                    xmlWriter.Flush();
                    entityBinaryConvert.XmlBinary = memoryStream.ToArray();
                }

            return(entityBinaryConvert.XmlBinary);
        }
Beispiel #3
0
        /// <summary>
        /// Deserialize binary stream to this entity
        /// </summary>
        /// <param name="bytes">the binary to turn into an entity</param>
        /// <returns>the entity</returns>
        public override IEntity DeSerialize(byte[] bytes)
        {
            var entityBinaryConvert = new DataUtility.EntityFileData(bytes);
            var xDoc = entityBinaryConvert.XDoc;

            var backingData = new PathwayData();
            var newEntity   = new Pathway();

            var versionFormat = xDoc.Root.GetSafeAttributeValue <int>("formattingVersion");

            newEntity.BirthMark = xDoc.Root.GetSafeAttributeValue("Birthmark");
            newEntity.Birthdate = xDoc.Root.GetSafeAttributeValue <DateTime>("Birthdate");

            backingData.ID                    = xDoc.Root.Element("BackingData").GetSafeAttributeValue <long>("ID");
            backingData.Name                  = xDoc.Root.Element("BackingData").GetSafeAttributeValue("Name");
            backingData.LastRevised           = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("LastRevised");
            backingData.Created               = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("Created");
            backingData.DegreesFromNorth      = xDoc.Root.Element("BackingData").GetSafeAttributeValue <int>("DegreesFromNorth");
            backingData.ToLocationID          = xDoc.Root.Element("BackingData").GetSafeAttributeValue("ToLocationID");
            backingData.ToLocationType        = xDoc.Root.Element("BackingData").GetSafeAttributeValue("ToLocationType");
            backingData.FromLocationID        = xDoc.Root.Element("BackingData").GetSafeAttributeValue("FromLocationID");
            backingData.FromLocationType      = xDoc.Root.Element("BackingData").GetSafeAttributeValue("FromLocationType");
            backingData.MessageToActor        = xDoc.Root.Element("BackingData").GetSafeAttributeValue("MessageToActor");
            backingData.MessageToOrigin       = xDoc.Root.Element("BackingData").GetSafeAttributeValue("MessageToOrigin");
            backingData.MessageToDestination  = xDoc.Root.Element("BackingData").GetSafeAttributeValue("MessageToDestination");
            backingData.AudibleToSurroundings = xDoc.Root.Element("BackingData").GetSafeAttributeValue("AudibleToSurroundings");
            backingData.AudibleStrength       = xDoc.Root.Element("BackingData").GetSafeAttributeValue <int>("AudibleStrength");
            backingData.VisibleToSurroundings = xDoc.Root.Element("BackingData").GetSafeAttributeValue("VisibleToSurroundings");
            backingData.VisibleStrength       = xDoc.Root.Element("BackingData").GetSafeAttributeValue <int>("VisibleStrength");

            var obj = new Room();

            obj.BirthMark = xDoc.Root.Element("LiveData").GetSafeAttributeValue("RoomFrom");

            newEntity.FromLocation = obj;

            var toObj = new Room();

            toObj.BirthMark = xDoc.Root.Element("LiveData").GetSafeAttributeValue("RoomTo");

            newEntity.ToLocation = toObj;

            //keywords is last
            newEntity.Keywords = xDoc.Root.Element("LiveData").GetSafeAttributeValue("Keywords").Split(new char[] { ',' });

            //Add new version transformations here, they are meant to be iterative, hence < 1
            Transform_V1(backingData, newEntity, xDoc.Root, versionFormat < 1);

            newEntity.DataTemplate = backingData;

            return(newEntity);
        }
Beispiel #4
0
        /// <summary>
        /// Deserialize binary stream to this entity
        /// </summary>
        /// <param name="bytes">the binary to turn into an entity</param>
        /// <returns>the entity</returns>
        public override IEntity DeSerialize(byte[] bytes)
        {
            var entityBinaryConvert = new DataUtility.EntityFileData(bytes);
            var xDoc = entityBinaryConvert.XDoc;

            var backingData = new RoomData();
            var newEntity   = new Room();

            var versionFormat = xDoc.Root.GetSafeAttributeValue <int>("formattingVersion");

            //This block represents "version zero" stuff we get from the xml
            newEntity.BirthMark = xDoc.Root.GetSafeAttributeValue("Birthmark");
            newEntity.Birthdate = xDoc.Root.GetSafeAttributeValue <DateTime>("Birthdate");

            backingData.ID          = xDoc.Root.Element("BackingData").GetSafeAttributeValue <long>("ID");
            backingData.Name        = xDoc.Root.Element("BackingData").GetSafeAttributeValue("Name");
            backingData.LastRevised = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("LastRevised");
            backingData.Created     = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("Created");

            //Add a fake entity to get the birthmark over to the next place
            foreach (var item in xDoc.Root.Element("ObjectsInRoom").Elements("Item"))
            {
                var obj = new Inanimate();
                obj.BirthMark = item.Value;

                newEntity.ObjectsInRoom.Add(obj);
            }

            //Add a fake entity to get the birthmark over to the next place
            foreach (var item in xDoc.Root.Element("MobilesInside").Elements("Item"))
            {
                var obj = new Intelligence();
                obj.BirthMark = item.Value;

                newEntity.MobilesInside.Add(obj);
            }

            //keywords is last
            newEntity.Keywords = xDoc.Root.Element("LiveData").GetSafeAttributeValue <string>("Keywords").Split(new char[] { ',' });

            //Add new version transformations here, they are meant to be iterative, hence < 1
            Transform_V1(backingData, newEntity, xDoc.Root, versionFormat < 1);

            newEntity.DataTemplate = backingData;

            return(newEntity);
        }
Beispiel #5
0
        /// <summary>
        /// Deserialize binary stream to this entity
        /// </summary>
        /// <param name="bytes">the binary to turn into an entity</param>
        /// <returns>the entity</returns>
        public override IEntity DeSerialize(byte[] bytes)
        {
            var entityBinaryConvert = new DataUtility.EntityFileData(bytes);
            var xDoc = entityBinaryConvert.XDoc;

            var backingData = new Character();
            var newEntity   = new Player();

            var versionFormat = xDoc.Root.GetSafeAttributeValue <int>("formattingVersion");

            newEntity.BirthMark = xDoc.Root.GetSafeAttributeValue("Birthmark");
            newEntity.Birthdate = xDoc.Root.GetSafeAttributeValue <DateTime>("Birthdate");

            backingData.ID = xDoc.Root.Element("BackingData").GetSafeAttributeValue <long>("ID");

            //we have the ID, we don't want anything else from here we just want to go get the object from the db for player characters.
            var backChar = DataWrapper.GetOne <Character>(backingData.ID);

            if (backChar != null)
            {
                backingData = backChar;
            }
            else
            {
                //we can still use this as a failover to restore data from backups
                backingData.Name                  = xDoc.Root.Element("BackingData").GetSafeAttributeValue("Name");
                backingData.SurName               = xDoc.Root.Element("BackingData").GetSafeAttributeValue("Surname");
                backingData.AccountHandle         = xDoc.Root.Element("BackingData").GetSafeAttributeValue("AccountHandle");
                backingData.LastRevised           = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("LastRevised");
                backingData.Created               = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("Created");
                backingData.Gender                = xDoc.Root.Element("BackingData").GetSafeAttributeValue("Gender");
                backingData.GamePermissionsRank   = (StaffRank)Enum.ToObject(typeof(StaffRank), xDoc.Root.Element("BackingData").GetSafeAttributeValue <short>("GamePermissionsRank"));
                backingData.LastKnownLocation     = xDoc.Root.Element("BackingData").GetSafeAttributeValue("LastKnownLocation");
                backingData.LastKnownLocationType = xDoc.Root.Element("BackingData").GetSafeAttributeValue("LastKnownLocationType");
            }

            //keywords is last
            newEntity.Keywords = xDoc.Root.Element("LiveData").Attribute("Keywords").Value.Split(new char[] { ',' });

            //Add new version transformations here, they are meant to be iterative, hence < 1
            Transform_V1(backingData, newEntity, xDoc.Root, versionFormat < 1);

            newEntity.DataTemplate = backingData;

            return(newEntity);
        }
Beispiel #6
0
        /// <summary>
        /// Deserialize binary stream to this entity
        /// </summary>
        /// <param name="bytes">the binary to turn into an entity</param>
        /// <returns>the entity</returns>
        public override IEntity DeSerialize(byte[] bytes)
        {
            var entityBinaryConvert = new DataUtility.EntityFileData(bytes);
            var xDoc = entityBinaryConvert.XDoc;

            var backingData = new NonPlayerCharacter();
            var newEntity   = new Intelligence();

            var versionFormat = xDoc.Root.GetSafeAttributeValue <int>("formattingVersion");

            newEntity.BirthMark = xDoc.Root.GetSafeAttributeValue("Birthmark");
            newEntity.Birthdate = xDoc.Root.GetSafeAttributeValue <DateTime>("Birthdate");

            backingData.ID          = xDoc.Root.Element("BackingData").GetSafeAttributeValue <long>("ID");
            backingData.Name        = xDoc.Root.Element("BackingData").GetSafeAttributeValue("Name");
            backingData.SurName     = xDoc.Root.Element("BackingData").GetSafeAttributeValue("Surname");
            backingData.LastRevised = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("LastRevised");
            backingData.Created     = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("Created");
            backingData.Gender      = xDoc.Root.Element("BackingData").GetSafeAttributeValue("Gender");

            //Add a fake entity to get the birthmark over to the next place
            foreach (var item in xDoc.Root.Element("Inventory").Elements("Item"))
            {
                var obj = new Inanimate();
                obj.BirthMark = item.Value;

                newEntity.Inventory.Add(obj);
            }


            //keywords is last
            newEntity.Keywords = xDoc.Root.Element("LiveData").GetSafeAttributeValue("Keywords").Split(new char[] { ',' });

            //Add new version transformations here, they are meant to be iterative, hence < 1
            Transform_V1(backingData, newEntity, xDoc.Root, versionFormat < 1);

            newEntity.DataTemplate = backingData;

            return(newEntity);
        }
Beispiel #7
0
        /// <summary>
        /// Serialize this entity's live data to a binary stream
        /// </summary>
        /// <returns>the binary stream</returns>
        public override byte[] Serialize()
        {
            var settings = new XmlWriterSettings {
                OmitXmlDeclaration = true, Encoding = Encoding.UTF8
            };
            var charData = (ICharacter)DataTemplate;

            var entityData = new XDocument(
                new XElement("root",
                             new XAttribute("formattingVersion", liveDataVersion),
                             new XAttribute("Birthmark", BirthMark),
                             new XAttribute("Birthdate", Birthdate),
                             new XElement("BackingData",
                                          new XAttribute("ID", charData.ID),
                                          new XAttribute("Name", charData.Name),
                                          new XAttribute("Surname", charData.SurName),
                                          new XAttribute("AccountHandle", charData.AccountHandle),
                                          new XAttribute("LastRevised", charData.LastRevised),
                                          new XAttribute("Created", charData.Created),
                                          new XAttribute("Gender", charData.Gender),
                                          new XAttribute("LastKnownLocationType", charData.LastKnownLocationType),
                                          new XAttribute("LastKnownLocation", charData.LastKnownLocation),
                                          new XAttribute("GamePermissionsRank", charData.GamePermissionsRank),
                                          new XElement("Race",
                                                       new XAttribute("ID", charData.RaceData.ID),
                                                       new XAttribute("Head", charData.RaceData.Head.ID),
                                                       new XAttribute("Torso", charData.RaceData.Torso.ID),
                                                       new XAttribute("SanguinaryMaterial", charData.RaceData.SanguinaryMaterial.ID),
                                                       new XAttribute("Breathes", (short)charData.RaceData.Breathes),
                                                       new XAttribute("DietaryNeeds", (short)charData.RaceData.DietaryNeeds),
                                                       new XAttribute("EmergencyLocation", charData.RaceData.EmergencyLocation.ID),
                                                       new XAttribute("StartingLocation", charData.RaceData.StartingLocation.ID),
                                                       new XAttribute("TeethType", (short)charData.RaceData.TeethType),
                                                       new XAttribute("TemperatureToleranceLow", charData.RaceData.TemperatureTolerance.Item1),
                                                       new XAttribute("TemperatureToleranceHigh", charData.RaceData.TemperatureTolerance.Item2),
                                                       new XAttribute("VisionRangeLow", charData.RaceData.VisionRange.Item1),
                                                       new XAttribute("VisionRangeHigh", charData.RaceData.VisionRange.Item2),
                                                       new XElement("Arms",
                                                                    new XAttribute("ID", charData.RaceData.Arms.Item1.ID),
                                                                    new XAttribute("Amount", charData.RaceData.Arms.Item2)),
                                                       new XElement("Legs",
                                                                    new XAttribute("ID", charData.RaceData.Legs.Item1.ID),
                                                                    new XAttribute("Amount", charData.RaceData.Legs.Item2)),
                                                       new XElement("BodyParts", JsonConvert.SerializeObject(charData.RaceData.BodyParts)))),
                             new XElement("LiveData",
                                          new XAttribute("Keywords", string.Join(",", Keywords))),
                             new XElement("Inventory")
                             ));

            foreach (var item in Inventory.EntitiesContained())
            {
                entityData.Root.Element("Inventory").Add(new XElement("Item", item.BirthMark));
            }

            var entityBinaryConvert = new DataUtility.EntityFileData(entityData);

            using (var memoryStream = new MemoryStream())
                using (var xmlWriter = XmlWriter.Create(memoryStream, settings))
                {
                    entityData.WriteTo(xmlWriter);
                    xmlWriter.Flush();
                    entityBinaryConvert.XmlBinary = memoryStream.ToArray();
                }

            return(entityBinaryConvert.XmlBinary);
        }
Beispiel #8
0
        /// <summary>
        /// Deserialize binary stream to this entity
        /// </summary>
        /// <param name="bytes">the binary to turn into an entity</param>
        /// <returns>the entity</returns>
        public override IEntity DeSerialize(byte[] bytes)
        {
            var entityBinaryConvert = new DataUtility.EntityFileData(bytes);
            var xDoc = entityBinaryConvert.XDoc;

            var newEntity = new Inanimate();

            var versionFormat = xDoc.Root.GetSafeAttributeValue <int>("formattingVersion");

            newEntity.BirthMark = xDoc.Root.GetSafeAttributeValue("Birthmark");
            newEntity.Birthdate = xDoc.Root.GetSafeAttributeValue <DateTime>("Birthdate");

            var internalCompositions = xDoc.Root.Element("BackingData").GetSafeAttributeValue("InternalComposition");
            var backingData          = new InanimateData(internalCompositions);

            backingData.ID          = xDoc.Root.Element("BackingData").GetSafeAttributeValue <long>("ID");
            backingData.Name        = xDoc.Root.Element("BackingData").GetSafeAttributeValue("Name");
            backingData.LastRevised = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("LastRevised");
            backingData.Created     = xDoc.Root.Element("BackingData").GetSafeAttributeValue <DateTime>("Created");

            foreach (var item in xDoc.Root.Element("BackingData").Element("InanimateContainers").Elements("Item"))
            {
                var newContainer = new EntityContainerData <IInanimate>();
                newContainer.CapacityVolume = item.GetSafeAttributeValue <long>("CapacityVolume");
                newContainer.CapacityWeight = item.GetSafeAttributeValue <long>("CapacityWeight");
                newContainer.Name           = item.GetSafeAttributeValue("Name");

                backingData.InanimateContainers.Add(newContainer);
            }

            //Add a fake entity to get the birthmark over to the next place
            foreach (var item in xDoc.Root.Element("BackingData").Element("MobileContainers").Elements("Item"))
            {
                var newContainer = new EntityContainerData <IMobile>();
                newContainer.CapacityVolume = item.GetSafeAttributeValue <long>("CapacityVolume");
                newContainer.CapacityWeight = item.GetSafeAttributeValue <long>("CapacityWeight");
                newContainer.Name           = item.GetSafeAttributeValue("Name");

                backingData.MobileContainers.Add(newContainer);
            }

            //Add a fake entity to get the birthmark over to the next place
            foreach (var item in xDoc.Root.Element("MobilesInside").Elements("Item"))
            {
                var obj = new Intelligence();
                obj.BirthMark = item.GetSafeAttributeValue("Birthmark");
                var containerName = item.GetSafeAttributeValue("Container");

                if (!String.IsNullOrWhiteSpace(containerName))
                {
                    newEntity.MobilesInside.Add(obj, containerName);
                }
                else
                {
                    newEntity.MobilesInside.Add(obj);
                }
            }


            //Add a fake entity to get the birthmark over to the next place
            foreach (var item in xDoc.Root.Element("Contents").Elements("Item"))
            {
                var obj = new Inanimate();
                obj.BirthMark = item.GetSafeAttributeValue("Birthmark");
                var containerName = item.GetSafeAttributeValue("Container");

                if (!String.IsNullOrWhiteSpace(containerName))
                {
                    newEntity.Contents.Add(obj, containerName);
                }
                else
                {
                    newEntity.Contents.Add(obj);
                }
            }

            //Add new version transformations here, they are meant to be iterative, hence < 1
            Transform_V1(backingData, newEntity, xDoc.Root, versionFormat < 1);

            newEntity.DataTemplate = backingData;

            //keywords is last
            newEntity.Keywords = xDoc.Root.Element("LiveData").Attribute("Keywords").Value.Split(new char[] { ',' });

            return(newEntity);
        }
Beispiel #9
0
        /// <summary>
        /// Serialize this entity's live data to a binary stream
        /// </summary>
        /// <returns>the binary stream</returns>
        public override byte[] Serialize()
        {
            var settings = new XmlWriterSettings {
                OmitXmlDeclaration = true, Encoding = Encoding.UTF8
            };
            var charData = (IInanimateData)DataTemplate;

            var entityData = new XDocument(
                new XElement("root",
                             new XAttribute("formattingVersion", liveDataVersion),
                             new XAttribute("Birthmark", BirthMark),
                             new XAttribute("Birthdate", Birthdate),
                             new XElement("BackingData",
                                          new XAttribute("ID", charData.ID),
                                          new XAttribute("Name", charData.Name),
                                          new XAttribute("LastRevised", charData.LastRevised),
                                          new XAttribute("Created", charData.Created),
                                          new XElement("MobileContainers"),
                                          new XElement("InanimateContainers"),
                                          new XElement("InternalComposition", JsonConvert.SerializeObject(charData.InternalComposition))),
                             new XElement("LiveData",
                                          new XAttribute("Keywords", string.Join(",", Keywords)),
                                          new XElement("DimensionalModel",
                                                       new XAttribute("Length", Model.Length),
                                                       new XAttribute("Height", Model.Height),
                                                       new XAttribute("Width", Model.Width),
                                                       new XAttribute("ID", charData.Model.ModelBackingData.ID),
                                                       new XElement("ModellingData", Model.ModelBackingData.SerializeModel()),
                                                       new XElement("MaterialCompositions", Model.SerializeMaterialCompositions()))),
                             new XElement("Contents"),
                             new XElement("MobilesInside")
                             ));

            foreach (var item in Contents.EntitiesContainedByName())
            {
                entityData.Root.Element("Contents").Add(new XElement("Item",
                                                                     new XAttribute("Birthmark", item.Item2.BirthMark),
                                                                     new XAttribute("Container", item.Item1)));
            }

            foreach (var item in MobilesInside.EntitiesContainedByName().Where(ent => ent.Item2.GetType() != typeof(Player)))
            {
                entityData.Root.Element("MobilesInside").Add(new XElement("Item",
                                                                          new XAttribute("Birthmark", item.Item2.BirthMark),
                                                                          new XAttribute("Container", item.Item1)));
            }

            foreach (var item in charData.MobileContainers)
            {
                entityData.Root.Element("BackingData").Element("MobileContainers").Add(new XElement("Container",
                                                                                                    new XAttribute("Name", item.Name),
                                                                                                    new XAttribute("CapacityVolume", item.CapacityVolume),
                                                                                                    new XAttribute("CapacityWeight", item.CapacityWeight)));
            }
            foreach (var item in charData.InanimateContainers)
            {
                entityData.Root.Element("BackingData").Element("InanimateContainers").Add(new XElement("Container",
                                                                                                       new XAttribute("Name", item.Name),
                                                                                                       new XAttribute("CapacityVolume", item.CapacityVolume),
                                                                                                       new XAttribute("CapacityWeight", item.CapacityWeight)));
            }

            var entityBinaryConvert = new DataUtility.EntityFileData(entityData);

            using (var memoryStream = new MemoryStream())
                using (var xmlWriter = XmlWriter.Create(memoryStream, settings))
                {
                    entityData.WriteTo(xmlWriter);
                    xmlWriter.Flush();
                    entityBinaryConvert.XmlBinary = memoryStream.ToArray();
                }

            return(entityBinaryConvert.XmlBinary);
        }