public void RecursiveArrayClass() { Type type = typeof(ExampleWithArray); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tStruct, rpcType); }
public void StructWithEnum() { Type type = typeof(struct2); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tStruct, rpcType, "struct doesn't map to XmlRpcType.tInvalid"); }
public void DBNull() { DBNull value = System.DBNull.Value; Type type = value.GetType(); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tStruct, rpcType, "GetXmlRpcType return DBNull as tStruct"); }
public void EnumXmlRpcType() { Assert.AreEqual(XmlRpcType.tInt32, XmlRpcTypeInfo.GetXmlRpcType(typeof(ByteEnum)), "byte"); Assert.AreEqual(XmlRpcType.tInt32, XmlRpcTypeInfo.GetXmlRpcType(typeof(SByteEnum)), "sbyte"); Assert.AreEqual(XmlRpcType.tInt32, XmlRpcTypeInfo.GetXmlRpcType(typeof(ShortEnum)), "short"); Assert.AreEqual(XmlRpcType.tInt32, XmlRpcTypeInfo.GetXmlRpcType(typeof(UShortEnum)), "ushort"); Assert.AreEqual(XmlRpcType.tInt32, XmlRpcTypeInfo.GetXmlRpcType(typeof(IntEnum)), "int"); Assert.AreEqual(XmlRpcType.tInt64, XmlRpcTypeInfo.GetXmlRpcType(typeof(UIntEnum)), "uint"); Assert.AreEqual(XmlRpcType.tInt64, XmlRpcTypeInfo.GetXmlRpcType(typeof(LongEnum)), "long"); Assert.AreEqual(XmlRpcType.tInvalid, XmlRpcTypeInfo.GetXmlRpcType(typeof(ULongEnum)), "ulong"); }
public void Void() { Type type = typeof(void); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tVoid, rpcType, "void doesn't map to XmlRpcType.tVoid"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "void", "void doesn't map to 'void'"); }
public void JaggedIntArray() { Type type = typeof(Int32[][]); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tArray, rpcType, "Int32[] doesn't map to XmlRpcType.tArray"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "array", "Int32[] doesn't map to 'array'"); }
public void Array() { Type type = typeof(Array); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tArray, rpcType, "Array doesn't map to XmlRpcType.tArray"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "array", "Array doesn't map to 'array'"); }
public void Base64() { Type type = typeof(byte[]); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tBase64, rpcType, "Byte[] doesn't map to XmlRpcType.tBase64"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "base64", "Byte[] doesn't map to 'base64'"); }
public void Int32() { Type type = typeof(int); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tInt32, rpcType, "Int32 doesn't map to XmlRpcType.tInt32"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "integer", "Int32 doesn't map to 'integer'"); }
public void Int64() { Type type = typeof(long); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tInt64, rpcType, "Int64 doesn't map to XmlRpcType.tInt64"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "i8", "Int64 doesn't map to 'i8'"); }
public void Double() { Type type = typeof(double); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tDouble, rpcType, "Double doesn't map to XmlRpcType.tDouble"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "double", "Double doesn't map to 'double'"); }
public void String() { Type type = typeof(string); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tString, rpcType, "String doesn't map to XmlRpcType.tString"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "string", "String doesn't map to 'string'"); }
public void XmlRpcBoolean() { Type type = typeof(bool?); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tBoolean, rpcType, "XmlRpcBoolean doesn't map to XmlRpcType.tBoolean"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "boolean", "XmlRpcBoolean doesn't map to 'boolean'"); }
public void XmlRpcStruct() { Type type = typeof(XmlRpcStruct); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tHashtable, rpcType, "XmlRpcStruct doesn't map to XmlRpcType.tHashtable"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "struct", "XmlRpcStruct doesn't map to 'struct'"); }
public void NullableStruct() { Type type = typeof(TestStruct?); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tStruct, rpcType, "TestStruct? doesn't map to XmlRpcType.tStruct"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "struct", "TestStruct? doesn't map to 'struct'"); }
public void NullableDateTime() { Type type = typeof(DateTime?); XmlRpcType rpcType = XmlRpcTypeInfo.GetXmlRpcType(type); Assert.AreEqual(XmlRpcType.tDateTime, rpcType, "DateTime? doesn't map to XmlRpcType.tDateTime"); string rpcString = XmlRpcTypeInfo.GetXmlRpcTypeString(type); Assert.AreEqual(rpcString, "dateTime", "DateTime? doesn't map to 'dateTime'"); }
private object MapArray(IEnumerator <Node> iter, Type valType, MappingStack mappingStack, MappingAction mappingAction, out Type mappedType) { mappedType = null; if (valType != null && !valType.IsArray && (valType != typeof(Array) && valType != typeof(object))) { throw new XmlRpcTypeMismatchException(mappingStack.MappingType + " contains array value where " + XmlRpcTypeInfo.GetXmlRpcTypeString(valType) + " expected " + StackDump(mappingStack)); } if (valType != null) { if (XmlRpcTypeInfo.GetXmlRpcType(valType) == XmlRpcType.tMultiDimArray) { (mappingStack).Push("array mapped to type " + valType.Name); return(MapMultiDimArray(iter, valType, mappingStack, mappingAction)); } else { (mappingStack).Push("array mapped to type " + valType.Name); } } else { (mappingStack).Push("array"); } List <object> list = new List <object>(); Type valType1 = DetermineArrayItemType(valType); bool flag = false; Type elementType = null; while (iter.MoveNext() && iter.Current is ValueNode) { (mappingStack).Push(string.Format("element {0}", list.Count)); object obj = MapValueNode(iter, valType1, mappingStack, mappingAction); list.Add(obj); mappingStack.Pop(); } foreach (object obj in list) { if (obj != null) { if (!flag) { elementType = obj.GetType(); flag = true; } else if (elementType != obj.GetType()) { elementType = null; } } } object[] args = new object[1] { list.Count }; object obj1 = valType == null || valType == typeof(Array) || valType == typeof(object) ? (elementType != null ? Array.CreateInstance(elementType, (int)args[0]) : CreateArrayInstance(typeof(object[]), args)) : CreateArrayInstance(valType, args); for (int index = 0; index < list.Count; ++index) { ((Array)obj1).SetValue(list[index], index); } mappingStack.Pop(); return(obj1); }