From 134f86e8d5c414409631b25b8c6f0ee45fbd8631 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 3 Nov 2016 21:44:39 +1000 Subject: Initial update to OpenSim 0.8.2.1 source code. --- OpenSim/Framework/EstateBan.cs | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'OpenSim/Framework/EstateBan.cs') 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 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; +using System.Collections.Generic; +using System.Reflection; + using OpenMetaverse; namespace OpenSim.Framework @@ -111,5 +115,50 @@ namespace OpenSim.Framework } } + public EstateBan() { } + + public Dictionary ToMap() + { + Dictionary map = new Dictionary(); + PropertyInfo[] properties = this.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); + foreach (PropertyInfo p in properties) + map[p.Name] = p.GetValue(this, null); + + return map; + } + + public EstateBan(Dictionary map) + { + foreach (KeyValuePair kvp in map) + { + PropertyInfo p = this.GetType().GetProperty(kvp.Key, BindingFlags.Public | BindingFlags.Instance); + if (p == null) + continue; + object value = p.GetValue(this, null); + if (value is String) + p.SetValue(this, map[p.Name], null); + else if (value is UInt32) + p.SetValue(this, UInt32.Parse((string)map[p.Name]), null); + else if (value is Boolean) + p.SetValue(this, Boolean.Parse((string)map[p.Name]), null); + else if (value is UUID) + p.SetValue(this, UUID.Parse((string)map[p.Name]), null); + } + } + + + /// + /// For debugging + /// + /// + public override string ToString() + { + Dictionary map = ToMap(); + string result = string.Empty; + foreach (KeyValuePair kvp in map) + result += string.Format("{0}: {1} {2}", kvp.Key, kvp.Value, Environment.NewLine); + + return result; + } } } -- cgit v1.1