public IncorrectTypeException(Udbus.Types.dbus_type expectedType, object providedValue, Udbus.Types.dbus_type[] providedTypes)
     : base(CreateMessage(expectedType, providedValue, providedTypes))
 {
     this.expectedType = expectedType;
     this.providedValue = providedValue;
     this.providedTypes = providedTypes;
 }
 public IncorrectTypeException(Udbus.Types.dbus_type expectedType, object providedValue, Udbus.Types.dbus_type[] providedTypes)
     : base(CreateMessage(expectedType, providedValue, providedTypes))
 {
     this.expectedType  = expectedType;
     this.providedValue = providedValue;
     this.providedTypes = providedTypes;
 }
        static void WriteSnippets()
        {
            //string structSig = "(bs)";
            Udbus.Types.dbus_type[] terminator  = new Udbus.Types.dbus_type[] { Udbus.Types.dbus_type.DBUS_INVALID };
            Udbus.Types.dbus_type[] structSig   = new Udbus.Types.dbus_type[] { Udbus.Types.dbus_type.DBUS_STRUCT_BEGIN, Udbus.Types.dbus_type.DBUS_BOOLEAN, Udbus.Types.dbus_type.DBUS_STRING, Udbus.Types.dbus_type.DBUS_STRUCT_END };
            Udbus.Types.dbus_type[] structTypes = structSig.Concat(terminator).ToArray();
            //object[] astruct = new object[] { dbus_union.CreateStruct(new object[] { true, "One" }, structTypes),
            //    dbus_union.CreateStruct(new object[] { false, "Two" }, structTypes)
            //};
            object[] astruct = new object[] { new object[] { true, "One" },
                                              new object[] { false, "Two" } };
            object[] adict = new object[] {
                new object[] { 1, new object[] { true, "One" } },
                new object[] { 2, new object[] { false, "Two" } }
            };
            Udbus.Types.dbus_type[] dictTypes = new Udbus.Types.dbus_type[] { Udbus.Types.dbus_type.DBUS_ARRAY, Udbus.Types.dbus_type.DBUS_DICT_BEGIN, Udbus.Types.dbus_type.DBUS_INT32 }
            .Concat(structSig)
            .Concat(new Udbus.Types.dbus_type[] { Udbus.Types.dbus_type.DBUS_DICT_END })
            .Concat(terminator)
            .ToArray();
            dbus_union s = dbus_union.CreateStruct(astruct, structTypes);
            dbus_union d = dbus_union.Create(adict, dictTypes);

            //UdbusMessageBuilder builder = new UdbusMessageBuilder();
            //MarshalWriteObjectDelegate del = UdbusMessageBuilder.BodyAdd_String;
        }
 public InvalidVariantCastException(Udbus.Types.dbus_type underlyingType, string underlyingValue, Udbus.Types.dbus_type requestedType, string message)
     : base(message)
 {
     this.underlyingType  = underlyingType;
     this.underlyingValue = underlyingValue;
     this.requestedType   = requestedType;
 }
 public IncorrectTypeException(Udbus.Types.dbus_type expectedType, object providedValue, Udbus.Types.dbus_type[] providedTypes, string message)
     : base(message)
 {
     this.expectedType = expectedType;
     this.providedValue = providedValue;
     this.providedTypes = providedTypes;
 }
 public IncorrectTypeException(Udbus.Types.dbus_type expectedType, object providedValue, Udbus.Types.dbus_type[] providedTypes, string message)
     : base(message)
 {
     this.expectedType  = expectedType;
     this.providedValue = providedValue;
     this.providedTypes = providedTypes;
 }
 public IncorrectTypeException(Udbus.Types.dbus_type expectedType, object providedValue, Udbus.Types.dbus_type[] providedTypes,
                               System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
     : base(info, context)
 {
     this.expectedType  = expectedType;
     this.providedValue = providedValue;
     this.providedTypes = providedTypes;
 }
 public InvalidVariantCastException(Udbus.Types.dbus_type underlyingType, string underlyingValue, Udbus.Types.dbus_type requestedType,
                                    System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
     : base(info, context)
 {
     this.underlyingType  = underlyingType;
     this.underlyingValue = underlyingValue;
     this.requestedType   = requestedType;
 }
 /// <summary>
 /// Throws an exception if types invalid.
 /// </summary>
 /// <param name="value">Value being set.</param>
 /// <param name="requestedType">Type being requested.</param>
 /// <param name="types">Requested types for value.</param>
 /// <param name="index">Index of type to check.</param>
 static private void CheckTypesForSet(object value, Udbus.Types.dbus_type requestedType, Udbus.Types.dbus_type[] types, int index)
 {
     if (types.Length <= index) // Else if index too large
     {
         throw new IndexOutOfRangeException(string.Format("Types index out of range. Requested index {0}, Types length {1}",
                                                          index, types.Length));
     } // Ends else if index too large
     else if (types[index] != requestedType) // Else if not correct type
     {
         throw new Exceptions.IncorrectTypeException(requestedType, value, types);
     } // Ends else if not correct type
 }
        public dbus_primitive(string value, StringType stringtype)
        {
            switch (stringtype)
            {
            case StringType.DBUS_STRING:
                this.Type       = Udbus.Types.dbus_type.DBUS_STRING;
                this.dbusString = value;
                this.dbusValue  = value;
                break;

            case StringType.DBUS_OBJECTPATH:
                this.Type           = Udbus.Types.dbus_type.DBUS_OBJECTPATH;
                this.dbusObjectPath = new Udbus.Types.UdbusObjectPath(value);
                //this.dbusObjectPath = value;
                this.dbusValue = value;
                break;
                //case StringType.DBUS_SIGNATURE:
                //    this.Type = Udbus.Types.dbus_type.DBUS_SIGNATURE;
                //    this.dbusSignature = value;
                //    this.dbusValue = value;
                //    break;
            }
        }
        //public static implicit operator Int32(dbus_primitive primitive)
        //{
        //    if (primitive.Type != Udbus.Types.dbus_type.DBUS_INT32)
        //    {
        //        throw primitive.CreateCastException(dbus_type.DBUS_INT32);
        //    }
        //    return primitive.dbusInt32;
        //}
        #endregion // Casting

        #region Exceptions
        protected Exceptions.InvalidVariantCastException CreateCastException(Udbus.Types.dbus_type requestedType)
        {
            return(Exceptions.InvalidVariantCastException.Create(this.Type, this.ValueAsString(), requestedType));
        }
 public dbus_primitive(string value)
 {
     this.Type       = Udbus.Types.dbus_type.DBUS_STRING;
     this.dbusString = value;
     this.dbusValue  = value;
 }
 public dbus_primitive()
 {
     this.Type        = Udbus.Types.dbus_type.DBUS_INVALID;
     this.dbusInvalid = Invalid;
     this.dbusValue   = Invalid;
 }
 public InvalidVariantCastException(Udbus.Types.dbus_type underlyingType, string underlyingValue, Udbus.Types.dbus_type requestedType)
     : base(CreateMessage(underlyingType, underlyingValue, requestedType))
 {
     this.underlyingType = underlyingType;
     this.underlyingValue = underlyingValue;
     this.requestedType = requestedType;
 }
 protected virtual void AddType(Udbus.Types.dbus_type type)
 {
     this.type = type;
 }
 public virtual void AddType(Udbus.Types.dbus_type type)
 {
     // Add and terminate with DBUS_INVALID.
     this.types[this.types.Count - 1] = type;
     this.types.Add(Udbus.Types.dbus_type.DBUS_INVALID);
 }
 internal void AddType(Udbus.Types.dbus_type type)
 {
     // Tell the outside object about the type field.
     this.owner.AddType(type);
 }
 public InvalidVariantCastException(Udbus.Types.dbus_type underlyingType, string underlyingValue, Udbus.Types.dbus_type requestedType, string message,
     Exception inner)
     : base(message, inner)
 {
     this.underlyingType = underlyingType;
     this.underlyingValue = underlyingValue;
     this.requestedType = requestedType;
 }
 /// <summary>
 /// Check that first type is as requested.
 /// </summary>
 /// <param name="value">Value being set.</param>
 /// <param name="requestedType">Type being requested.</param>
 /// <param name="types">Requested types for value.</param>
 static private void CheckTypesForSetStart(object value, Udbus.Types.dbus_type requestedType, Udbus.Types.dbus_type[] types)
 {
     CheckTypesForSet(value, requestedType, types, 0);
 }
 public InvalidVariantCastException(Udbus.Types.dbus_type underlyingType, string underlyingValue, Udbus.Types.dbus_type requestedType,
     System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
     : base(info, context)
 {
     this.underlyingType = underlyingType;
     this.underlyingValue = underlyingValue;
     this.requestedType = requestedType;
 }
 public static InvalidVariantCastException Create(Udbus.Types.dbus_type underlyingType, string underlyingValue, Udbus.Types.dbus_type requestedType)
 {
     return(Create(underlyingType, underlyingValue, requestedType,
                   CreateMessage(underlyingType, underlyingValue, requestedType)));
 }
 public static string CreateMessage(Udbus.Types.dbus_type underlyingType, string underlyingValue, Udbus.Types.dbus_type requestedType)
 {
     return(string.Format("Trying to retrieve {0} (value={1}) as {2}", underlyingType, underlyingValue, requestedType));
 }
 public dbus_union(Udbus.Types.dbus_type type)
     : this(new Udbus.Types.dbus_type[] { type, Udbus.Types.dbus_type.DBUS_INVALID })
 {
 }
 internal extern static int dbus_msg_body_get_array(NMessageHandle.UdbusMessageHandle msg, Udbus.Types.dbus_type element, ref dbus_array_reader ar);
 public IncorrectTypeException(Udbus.Types.dbus_type expectedType, object providedValue, Udbus.Types.dbus_type[] providedTypes,
     System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
     : base(info, context)
 {
     this.expectedType = expectedType;
     this.providedValue = providedValue;
     this.providedTypes = providedTypes;
 }
 /// <summary>
 /// Check that last type is as requested.
 /// </summary>
 /// <param name="value">Value being set.</param>
 /// <param name="requestedType">Type being requested.</param>
 /// <param name="types">Requested types for value.</param>
 static private void CheckTypesForSetEnd(object value, Udbus.Types.dbus_type requestedType, Udbus.Types.dbus_type[] types)
 {
     CheckTypesForSet(value, requestedType, types, types.Length - 1);
 }
 public static string CreateMessage(Udbus.Types.dbus_type expectedType, object providedValue, Udbus.Types.dbus_type[] providedTypes)
 {
     return(string.Format("Type specified as '{0}' (value={1}) but expected '{2}'", expectedType, providedValue, Udbus.Types.dbus_sig.ToString(providedTypes)));
 }
 protected override void AddType(Udbus.Types.dbus_type type)
 {
     base.AddType(type);
     this.owner.AddType(type);
 }
 public static IncorrectTypeException Create(Udbus.Types.dbus_type expectedType, object providedValue, Udbus.Types.dbus_type[] providedTypes,
                                             string message)
 {
     return(new IncorrectTypeException(expectedType, providedValue, providedTypes, message));
 }
 protected virtual void AddType(Udbus.Types.dbus_type type)
 {
     this.type = type;
 }
 public static IncorrectTypeException Create(Udbus.Types.dbus_type expectedType, object providedValue, Udbus.Types.dbus_type[] providedTypes)
 {
     return(Create(expectedType, providedValue, providedTypes,
                   CreateMessage(expectedType, providedValue, providedTypes)));
 }
 public override void AddType(Udbus.Types.dbus_type type)
 {
     base.AddType(type);
     owner.AddType(type);
 }
 internal extern static int dbus_msg_body_add_array_begin(NMessageHandle.UdbusMessageHandle msg, Udbus.Types.dbus_type element, ref dbus_array_writer ptr);