29 using System.Collections;
30 using System.Collections.Generic;
32 using System.Reflection;
35 using System.Xml.Schema;
36 using System.Xml.Serialization;
39 using OpenMetaverse.StructuredData;
41 namespace OpenSim.Framework
53 public class DAMap : IXmlSerializable
57 private static readonly
int MIN_NAMESPACE_LENGTH = 4;
65 set { m_map = value; }
79 ReadXml(reader.ReadInnerXml());
88 m_map = (
OSDMap)OSDParser.DeserializeLLSDXml(rawXml);
95 writer.WriteRaw(ToXml());
101 return OSDParser.SerializeLLSDXmlString(m_map);
113 data = OSDParser.SerializeLLSDXmlString(other.m_map);
122 m_map = (
OSDMap)OSDParser.DeserializeLLSDXml(data);
133 List<string> keysToRemove = null;
135 OSDMap namespacesMap = daMap.m_map;
137 foreach (
string key in namespacesMap.Keys)
140 if (!(namespacesMap[key] is
OSDMap))
142 if (keysToRemove == null)
143 keysToRemove =
new List<string>();
145 keysToRemove.Add(
key);
149 if (keysToRemove != null)
151 foreach (
string key
in keysToRemove)
154 namespacesMap.Remove(
key);
158 foreach (
OSD nsOsd
in namespacesMap.Values)
163 foreach (
string key
in nsOsdMap.Keys)
165 if (!(nsOsdMap[key] is
OSDMap))
167 if (keysToRemove == null)
168 keysToRemove =
new List<string>();
170 keysToRemove.Add(
key);
174 if (keysToRemove != null)
175 foreach (
string key
in keysToRemove)
176 nsOsdMap.Remove(
key);
183 public int CountNamespaces {
get { lock (
this) {
return m_map.Count; } } }
188 public int CountStores
196 foreach (
OSD osdNamespace
in m_map)
198 count += ((
OSDMap)osdNamespace).Count;
218 if (m_map.TryGetValue(ns, out namespaceOsd))
222 if (((
OSDMap)namespaceOsd).TryGetValue(storeName, out store))
238 ValidateNamespace(ns);
243 if (!m_map.ContainsKey(ns))
249 nsMap = (
OSDMap)m_map[ns];
252 nsMap[storeName] = store;
262 if (ns.Length < MIN_NAMESPACE_LENGTH)
263 throw new Exception(
"Minimum namespace length is " + MIN_NAMESPACE_LENGTH);
272 if (m_map.TryGetValue(ns, out namespaceOsd))
274 return ((
OSDMap)namespaceOsd).ContainsKey(storeName);
287 if (m_map.TryGetValue(ns, out namespaceOsd))
291 bool result = ((
OSDMap)namespaceOsd).TryGetValue(storeName, out storeOsd);
314 if (m_map.TryGetValue(ns, out namespaceOsd))
317 namespaceOsdMap.Remove(storeName);
320 if (namespaceOsdMap.Count <= 0)
OSDMap GetStore(string ns, string storeName)
Retrieve a Dynamic Attribute store
bool TryGetStore(string ns, string storeName, out OSDMap store)
void WriteXml(XmlWriter writer)
OpenMetaverse.StructuredData.OSDMap OSDMap
int CountNamespaces
Get the number of namespaces
void SetStore(string ns, string storeName, OSDMap store)
Saves a Dynamic attribute store
OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString key
void ReadXml(XmlReader reader)
static DAMap FromXml(string rawXml)
static void ValidateNamespace(string ns)
Validate the key used for storing separate data stores.
bool RemoveStore(string ns, string storeName)
This class stores and retrieves dynamic attributes.
void ReadXml(string rawXml)
OpenMetaverse.StructuredData.OSD OSD
void CopyFrom(DAMap other)
static void SanitiseMap(DAMap daMap)
Sanitise the map to remove any namespaces or stores that are not OSDMap.
bool ContainsStore(string ns, string storeName)