public override void Add(object key, object value) { if (!(key is string)) { throw new ArgumentException("XmlRpcStruct key must be a string."); } if (XmlRpcServiceInfo.GetXmlRpcType(value.GetType()) == XmlRpcType.tInvalid) { throw new ArgumentException(String.Format( "Type {0} cannot be mapped to an XML-RPC type", value.GetType())); } base.Add(key, value); _keys.Add(key); _values.Add(value); }
public override object this[object key] { get { return(base[key]); } set { if (!(key is string)) { throw new ArgumentException("XmlRpcStruct key must be a string."); } if (XmlRpcServiceInfo.GetXmlRpcType(value.GetType()) == XmlRpcType.tInvalid) { throw new ArgumentException(String.Format( "Type {0} cannot be mapped to an XML-RPC type", value.GetType())); } base[key] = value; _keys.Add(key); _values.Add(value); } }
public static XmlRpcServiceInfo CreateServiceInfo(Type type) { XmlRpcServiceInfo svcInfo = new XmlRpcServiceInfo(); // extract service info XmlRpcServiceAttribute svcAttr = (XmlRpcServiceAttribute) Attribute.GetCustomAttribute(type, typeof(XmlRpcServiceAttribute)); if (svcAttr != null && svcAttr.Description != "") { svcInfo.doc = svcAttr.Description; } if (svcAttr != null && svcAttr.Name != "") { svcInfo.Name = svcAttr.Name; } else { svcInfo.Name = type.Name; } // extract method info Hashtable methods = new Hashtable(); foreach (Type itf in type.GetInterfaces()) { XmlRpcServiceAttribute itfAttr = (XmlRpcServiceAttribute) Attribute.GetCustomAttribute(itf, typeof(XmlRpcServiceAttribute)); if (itfAttr != null) { svcInfo.doc = itfAttr.Description; } InterfaceMapping imap = type.GetInterfaceMap(itf); foreach (MethodInfo mi in imap.InterfaceMethods) { ExtractMethodInfo(methods, mi, itf); } } foreach (MethodInfo mi in type.GetMethods()) { ArrayList mthds = new ArrayList(); mthds.Add(mi); MethodInfo curMi = mi; while (true) { MethodInfo baseMi = curMi.GetBaseDefinition(); if (baseMi.DeclaringType == curMi.DeclaringType) { break; } mthds.Insert(0, baseMi); curMi = baseMi; } foreach (MethodInfo mthd in mthds) { ExtractMethodInfo(methods, mthd, type); } } svcInfo.methodInfos = new XmlRpcMethodInfo[methods.Count]; methods.Values.CopyTo(svcInfo.methodInfos, 0); Array.Sort(svcInfo.methodInfos); return(svcInfo); }