NDesk.DBus.MessageWriter.WriteComplex C# (CSharp) Method

WriteComplex() public method

public WriteComplex ( object val, Type type ) : void
val object
type System.Type
return void
        public void WriteComplex(object val, Type type)
        {
            if (type == typeof (void))
                return;

            if (type.IsArray) {
                WriteArray (val, type.GetElementType ());
            } else if (type.IsGenericType && (type.GetGenericTypeDefinition () == typeof (IDictionary<,>) || type.GetGenericTypeDefinition () == typeof (Dictionary<,>))) {
                Type[] genArgs = type.GetGenericArguments ();
                System.Collections.IDictionary idict = (System.Collections.IDictionary)val;
                WriteFromDict (genArgs[0], genArgs[1], idict);
            } else if (Mapper.IsPublic (type)) {
                WriteObject (type, val);
            } else if (!type.IsPrimitive && !type.IsEnum) {
                WriteValueType (val, type);
                /*
            } else if (type.IsGenericType && type.GetGenericTypeDefinition () == typeof (Nullable<>)) {
                //is it possible to support nullable types?
                Type[] genArgs = type.GetGenericArguments ();
                WriteVariant (genArgs[0], val);
                */
            } else {
                throw new Exception ("Can't write");
            }
        }