BugzillaInterface.Query.AttemptStructDeserialization C# (CSharp) Method

AttemptStructDeserialization() public static method

Uses Reflection to deserialize objects from hashtables and structs. Specifically tested for use with the comment objects
public static AttemptStructDeserialization ( CookComputing.XmlRpc.XmlRpcStruct response, Type output ) : object
response CookComputing.XmlRpc.XmlRpcStruct /// A ///
output System.Type /// A ///
return object
        public static object AttemptStructDeserialization(XmlRpcStruct response, Type output)
        {
            MemberInfo[] outputMembers = output.GetMembers ();
            object result = Activator.CreateInstance (output);
            PropertyInfo[] properties = output.GetProperties ();
            foreach (PropertyInfo property in properties) {
                //Console.WriteLine (property.Name);
                if (response.ContainsKey (property.Name)) {
                    //Console.WriteLine("Declaring type:{0}, output type:{1}", property.PropertyType, response[property.Name].GetType());
                    if (Type.Equals (property.PropertyType, response[property.Name].GetType ())) {
                        //Console.WriteLine ("Identical Type! Woot! Value is " + response[property.Name]);
                        property.SetValue (result, response[property.Name], null);
                    }
                }
            }
            return result;
        }