29 using System.Collections.Generic;
31 using System.Reflection;
36 using OpenSim.Framework;
38 namespace OpenSim.Framework.Serialization.External
47 private static Dictionary<string, Action<LandData, XmlReader>> m_ldProcessors
48 =
new Dictionary<string, Action<LandData, XmlReader>>();
50 private static Dictionary<string, Action<LandAccessEntry, XmlReader>> m_laeProcessors
51 =
new Dictionary<string, Action<LandAccessEntry, XmlReader>>();
57 "Area", (ld, xtr) => ld.Area = Convert.ToInt32(xtr.ReadElementString(
"Area")));
59 "AuctionID", (ld, xtr) => ld.AuctionID = Convert.ToUInt32(xtr.ReadElementString(
"AuctionID")));
61 "AuthBuyerID", (ld, xtr) => ld.AuthBuyerID = UUID.Parse(xtr.ReadElementString(
"AuthBuyerID")));
63 "Category", (ld, xtr) => ld.Category = (ParcelCategory)Convert.ToSByte(xtr.ReadElementString(
"Category")));
65 "ClaimDate", (ld, xtr) => ld.ClaimDate = Convert.ToInt32(xtr.ReadElementString(
"ClaimDate")));
67 "ClaimPrice", (ld, xtr) => ld.ClaimPrice = Convert.ToInt32(xtr.ReadElementString(
"ClaimPrice")));
69 "GlobalID", (ld, xtr) => ld.GlobalID = UUID.Parse(xtr.ReadElementString(
"GlobalID")));
71 "GroupID", (ld, xtr) => ld.GroupID = UUID.Parse(xtr.ReadElementString(
"GroupID")));
73 "IsGroupOwned", (ld, xtr) => ld.IsGroupOwned = Convert.ToBoolean(xtr.ReadElementString(
"IsGroupOwned")));
75 "Bitmap", (ld, xtr) => ld.Bitmap = Convert.FromBase64String(xtr.ReadElementString(
"Bitmap")));
77 "Description", (ld, xtr) => ld.Description = xtr.ReadElementString(
"Description"));
79 "Flags", (ld, xtr) => ld.Flags = Convert.ToUInt32(xtr.ReadElementString(
"Flags")));
81 "LandingType", (ld, xtr) => ld.LandingType = Convert.ToByte(xtr.ReadElementString(
"LandingType")));
83 "Name", (ld, xtr) => ld.Name = xtr.ReadElementString(
"Name"));
85 "Status", (ld, xtr) => ld.Status = (ParcelStatus)Convert.ToSByte(xtr.ReadElementString(
"Status")));
87 "LocalID", (ld, xtr) => ld.LocalID = Convert.ToInt32(xtr.ReadElementString(
"LocalID")));
89 "MediaAutoScale", (ld, xtr) => ld.MediaAutoScale = Convert.ToByte(xtr.ReadElementString(
"MediaAutoScale")));
91 "MediaID", (ld, xtr) => ld.MediaID = UUID.Parse(xtr.ReadElementString(
"MediaID")));
93 "MediaURL", (ld, xtr) => ld.MediaURL = xtr.ReadElementString(
"MediaURL"));
95 "MusicURL", (ld, xtr) => ld.MusicURL = xtr.ReadElementString(
"MusicURL"));
97 "OwnerID", (ld, xtr) => ld.OwnerID = UUID.Parse(xtr.ReadElementString(
"OwnerID")));
100 "ParcelAccessList", ProcessParcelAccessList);
103 "PassHours", (ld, xtr) => ld.PassHours = Convert.ToSingle(xtr.ReadElementString(
"PassHours")));
105 "PassPrice", (ld, xtr) => ld.PassPrice = Convert.ToInt32(xtr.ReadElementString(
"PassPrice")));
107 "SalePrice", (ld, xtr) => ld.SalePrice = Convert.ToInt32(xtr.ReadElementString(
"SalePrice")));
109 "SnapshotID", (ld, xtr) => ld.SnapshotID = UUID.Parse(xtr.ReadElementString(
"SnapshotID")));
111 "UserLocation", (ld, xtr) => ld.UserLocation = Vector3.Parse(xtr.ReadElementString(
"UserLocation")));
113 "UserLookAt", (ld, xtr) => ld.UserLookAt = Vector3.Parse(xtr.ReadElementString(
"UserLookAt")));
119 "OtherCleanTime", (ld, xtr) => ld.OtherCleanTime = Convert.ToInt32(xtr.ReadElementString(
"OtherCleanTime")));
123 "AgentID", (lae, xtr) => lae.AgentID = UUID.Parse(xtr.ReadElementString(
"AgentID")));
125 "Time", (lae, xtr) =>
129 xtr.ReadElementString(
"Time");
134 "AccessList", (lae, xtr) => lae.Flags = (AccessList)Convert.ToUInt32(xtr.ReadElementString(
"AccessList")));
139 if (!xtr.IsEmptyElement)
141 while (xtr.Read() && xtr.NodeType != XmlNodeType.EndElement)
145 xtr.ReadStartElement(
"ParcelAccessEntry");
147 ExternalRepresentationUtils.ExecuteReadProcessors<
LandAccessEntry>(lae, m_laeProcessors, xtr);
149 xtr.ReadEndElement();
151 ld.ParcelAccessList.Add(lae);
166 return Deserialize(Encoding.UTF8.GetString(serializedLandData, 0, serializedLandData.Length));
179 using (XmlTextReader reader =
new XmlTextReader(
new StringReader(serializedLandData)))
181 reader.ReadStartElement(
"LandData");
183 ExternalRepresentationUtils.ExecuteReadProcessors<
LandData>(landData, m_ldProcessors, reader);
185 reader.ReadEndElement();
202 StringWriter sw =
new StringWriter();
203 XmlTextWriter xtw =
new XmlTextWriter(sw);
204 xtw.Formatting = Formatting.Indented;
206 xtw.WriteStartDocument();
207 xtw.WriteStartElement(
"LandData");
209 xtw.WriteElementString(
"Area", Convert.ToString(landData.Area));
210 xtw.WriteElementString(
"AuctionID", Convert.ToString(landData.AuctionID));
211 xtw.WriteElementString(
"AuthBuyerID", landData.AuthBuyerID.ToString());
212 xtw.WriteElementString(
"Category", Convert.ToString((sbyte)landData.
Category));
213 xtw.WriteElementString(
"ClaimDate", Convert.ToString(landData.ClaimDate));
214 xtw.WriteElementString(
"ClaimPrice", Convert.ToString(landData.ClaimPrice));
215 xtw.WriteElementString(
"GlobalID", landData.GlobalID.ToString());
217 UUID groupID = options.ContainsKey(
"wipe-owners") ? UUID.Zero : landData.
GroupID;
218 xtw.WriteElementString(
"GroupID", groupID.ToString());
220 bool isGroupOwned = options.ContainsKey(
"wipe-owners") ?
false : landData.
IsGroupOwned;
221 xtw.WriteElementString(
"IsGroupOwned", Convert.ToString(isGroupOwned));
223 xtw.WriteElementString(
"Bitmap", Convert.ToBase64String(landData.Bitmap));
224 xtw.WriteElementString(
"Description", landData.Description);
225 xtw.WriteElementString(
"Flags", Convert.ToString((uint)landData.
Flags));
226 xtw.WriteElementString(
"LandingType", Convert.ToString((byte)landData.
LandingType));
227 xtw.WriteElementString(
"Name", landData.Name);
228 xtw.WriteElementString(
"Status", Convert.ToString((sbyte)landData.
Status));
229 xtw.WriteElementString(
"LocalID", landData.LocalID.ToString());
230 xtw.WriteElementString(
"MediaAutoScale", Convert.ToString(landData.MediaAutoScale));
231 xtw.WriteElementString(
"MediaID", landData.MediaID.ToString());
232 xtw.WriteElementString(
"MediaURL", landData.MediaURL);
233 xtw.WriteElementString(
"MusicURL", landData.MusicURL);
235 UUID ownerID = options.ContainsKey(
"wipe-owners") ? UUID.Zero : landData.
OwnerID;
236 xtw.WriteElementString(
"OwnerID", ownerID.ToString());
238 xtw.WriteStartElement(
"ParcelAccessList");
241 xtw.WriteStartElement(
"ParcelAccessEntry");
242 xtw.WriteElementString(
"AgentID", pal.AgentID.ToString());
243 xtw.WriteElementString(
"Time", pal.Expires.ToString());
244 xtw.WriteElementString(
"AccessList", Convert.ToString((uint)pal.
Flags));
245 xtw.WriteEndElement();
247 xtw.WriteEndElement();
249 xtw.WriteElementString(
"PassHours", Convert.ToString(landData.PassHours));
250 xtw.WriteElementString(
"PassPrice", Convert.ToString(landData.PassPrice));
251 xtw.WriteElementString(
"SalePrice", Convert.ToString(landData.SalePrice));
252 xtw.WriteElementString(
"SnapshotID", landData.SnapshotID.ToString());
253 xtw.WriteElementString(
"UserLocation", landData.UserLocation.ToString());
254 xtw.WriteElementString(
"UserLookAt", landData.UserLookAt.ToString());
255 xtw.WriteElementString(
"Dwell",
"0");
256 xtw.WriteElementString(
"OtherCleanTime", Convert.ToString(landData.OtherCleanTime));
258 xtw.WriteEndElement();
263 return sw.ToString();
static LandData Deserialize(byte[] serializedLandData)
Reify/deserialize landData
ParcelStatus Status
Status of Parcel, Leased, Abandoned, For Sale
static void ProcessParcelAccessList(LandData ld, XmlReader xtr)
static string Serialize(LandData landData, Dictionary< string, object > options)
Serialize land data
UUID GroupID
Unique ID of the Group that owns
Details of a Parcel of land
byte LandingType
Determines if people are able to teleport where they please on the parcel or if they get constrainted...
ParcelCategory Category
Category of parcel. Used for classifying the parcel in classified listings
bool IsGroupOwned
Returns true if the Land Parcel is owned by a group
uint Flags
Parcel settings. Access flags, Fly, NoPush, Voice, Scripts allowed, etc. ParcelFlags ...
Serialize and deserialize LandData as an external format.
static LandData Deserialize(string serializedLandData)
Reify/deserialize landData
UUID OwnerID
Owner Avatar or Group of the parcel. Naturally, all land masses must be owned by someone ...