public void Query_Bug_with_reduced_fields([Random(1, 415555, 5)] int id) { var bugzilla = XmlRpcProxyGen.Create <IBugzilla>(); var fields = new[] { "id", "creator", "summary" }; var rpcStruct = bugzilla.GetBug(new[] { id }, fields); var bugsArray = rpcStruct["bugs"] as object[]; Assert.That(bugsArray, Is.Not.Null); if (bugsArray.Length == 0) { Assert.Inconclusive("No bugs available"); } var bugItem = (XmlRpcStruct)bugsArray.First(); foreach (var field in bugItem.Keys.OfType <string>()) { Assert.That(fields.Any(f => field.StartsWith(f)), Is.True, "Field {0} not requested", field); } dynamic rpcResult = new DynamicRpcObject(rpcStruct); foreach (var bug in rpcResult.Bugs) { Log.InfoFormat("{0} was created by {1}: {2}", bug.Id, bug.Creator, bug.Summary); } }
public override bool TryGetMember(GetMemberBinder binder, out object result) { result = RpcStruct[binder.Name] ?? RpcStruct[binder.Name.ToLower()]; if (result is XmlRpcStruct) { result = new DynamicRpcObject((XmlRpcStruct)result); } var array = result as Array; if (array != null) { for (var idx = 0; idx < array.Length; idx++) { var arrayItem = array.GetValue(idx) as XmlRpcStruct; if (arrayItem != null) { array.SetValue(new DynamicRpcObject(arrayItem), idx); } } } return(result != null || base.TryGetMember(binder, out result)); }
public override bool TryGetMember(GetMemberBinder binder, out object result) { result = RpcStruct[binder.Name] ?? RpcStruct[binder.Name.ToLower()]; if (result is XmlRpcStruct) result = new DynamicRpcObject((XmlRpcStruct)result); var array = result as Array; if (array != null) { for (var idx = 0; idx < array.Length; idx++) { var arrayItem = array.GetValue(idx) as XmlRpcStruct; if (arrayItem != null) array.SetValue(new DynamicRpcObject(arrayItem), idx); } } return result != null || base.TryGetMember(binder, out result); }
public void Query_Bug_with_reduced_fields([Random(1, 415555, 5)] int id) { var bugzilla = XmlRpcProxyGen.Create<IBugzilla>(); var fields = new[] { "id", "creator", "summary" }; var rpcStruct = bugzilla.GetBug(new[] { id }, fields); var bugsArray = rpcStruct["bugs"] as object[]; Assert.That(bugsArray, Is.Not.Null); if (bugsArray.Length == 0) Assert.Inconclusive("No bugs available"); var bugItem = (XmlRpcStruct)bugsArray.First(); foreach (var field in bugItem.Keys.OfType<string>()) { Assert.That(fields.Any(f => field.StartsWith(f)), Is.True, "Field {0} not requested", field); } dynamic rpcResult = new DynamicRpcObject(rpcStruct); foreach (var bug in rpcResult.Bugs) Log.InfoFormat("{0} was created by {1}: {2}", bug.Id, bug.Creator, bug.Summary); }