aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/EstateBan.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/EstateBan.cs')
-rw-r--r--OpenSim/Framework/EstateBan.cs49
1 files changed, 49 insertions, 0 deletions
diff --git a/OpenSim/Framework/EstateBan.cs b/OpenSim/Framework/EstateBan.cs
index de9ebf6..ebed794 100644
--- a/OpenSim/Framework/EstateBan.cs
+++ b/OpenSim/Framework/EstateBan.cs
@@ -25,6 +25,10 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31
28using OpenMetaverse; 32using OpenMetaverse;
29 33
30namespace OpenSim.Framework 34namespace OpenSim.Framework
@@ -111,5 +115,50 @@ namespace OpenSim.Framework
111 } 115 }
112 } 116 }
113 117
118 public EstateBan() { }
119
120 public Dictionary<string, object> ToMap()
121 {
122 Dictionary<string, object> map = new Dictionary<string, object>();
123 PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
124 foreach (PropertyInfo p in properties)
125 map[p.Name] = p.GetValue(this, null);
126
127 return map;
128 }
129
130 public EstateBan(Dictionary<string, object> map)
131 {
132 foreach (KeyValuePair<string, object> kvp in map)
133 {
134 PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance);
135 if (p == null)
136 continue;
137 object value = p.GetValue(this, null);
138 if (value is String)
139 p.SetValue(this, map[p.Name], null);
140 else if (value is UInt32)
141 p.SetValue(this, UInt32.Parse((string)map[p.Name]), null);
142 else if (value is Boolean)
143 p.SetValue(this, Boolean.Parse((string)map[p.Name]), null);
144 else if (value is UUID)
145 p.SetValue(this, UUID.Parse((string)map[p.Name]), null);
146 }
147 }
148
149
150 /// <summary>
151 /// For debugging
152 /// </summary>
153 /// <returns></returns>
154 public override string ToString()
155 {
156 Dictionary<string, object> map = ToMap();
157 string result = string.Empty;
158 foreach (KeyValuePair<string, object> kvp in map)
159 result += string.Format("{0}: {1} {2}", kvp.Key, kvp.Value, Environment.NewLine);
160
161 return result;
162 }
114 } 163 }
115} 164}