Exemple #1
0
        private static object ConvertVariant(IJsonValue arg)
        {
            JsonObject obj = arg.GetObject();

            string          signatureString = obj.Keys.Single();
            ITypeDefinition signature       = AllJoynTypeDefinition.CreateTypeDefintions(signatureString).Single();

            return(Convert(signature, obj.Values.Single()));
        }
Exemple #2
0
        internal IList <object> ToParameter()
        {
            var t        = AllJoynTypeDefinition.CreateTypeDefintions("(ssssxsssa{ss}a{sv}v)").First();
            var argument = new AllJoynMessageArgStructure(t);

            // var count = paramDef.Fields.Count;
            // string[] types = paramDef.Fields.Select(f => f.Type.ToString()).ToArray();
            // List<object> argument = new List<object>();
            argument.Add(Url);
            argument.Add(Title ?? " ");
            argument.Add(Artist ?? " ");
            argument.Add(ThumbnailUrl?.OriginalString ?? " ");
            argument.Add((long)Duration.TotalMilliseconds);
            argument.Add(MediaType ?? " ");
            argument.Add(Album ?? " ");
            argument.Add(Genre ?? " ");

            // Other data: a{ss}
            var otherData = new Dictionary <object, object>();

            if (OtherData != null)
            {
                foreach (var item in OtherData)
                {
                    otherData.Add(item.Key, item.Value);
                }
            }

            argument.Add(otherData.ToList());

            // medium desc: a{sv}
            var mediumDesc = new Dictionary <object, object>();

            if (OtherData != null)
            {
                foreach (var item in OtherData)
                {
                    mediumDesc.Add(item.Key, item.Value);
                }
            }

            argument.Add(mediumDesc.ToList());

            // AllJoynMessageArgVariant v = new AllJoynMessageArgVariant();
            // var arg = new DeviceProviders.AllJoynMessageArgVariant(AllJoynTypeDefinition.CreateTypeDefintions("v").First(), 0);
            // arg.Value = "upnp";
            argument.Add(UserData ?? "upnp"); // Variant: userdata
            return(argument);
        }
Exemple #3
0
        internal IList <object> ToParameter()
        {
            var t = AllJoynTypeDefinition.CreateTypeDefintions("(ssssxsssa{ss}a{sv}v)").First();

            // ITypeDefinition.h -->
            // public enum class TypeId
            //    {
            //        Invalid = 0,
            //    Boolean = 'b',                               // maps to ALLJOYN_BOOLEAN
            //    Double = 'd',                                // maps to ALLJOYN_DOUBLE
            //    Dictionary = 'e',                            // maps to an array of ALLJOYN_DICT_ENTRY: a{**}
            //    Signature = 'g',                             // maps to ALLJOYN_SIGNATURE (string)
            //    Int32 = 'i',                                 // maps to ALLJOYN_INT32
            //    Int16 = 'n',                                 // maps to ALLJOYN_INT16
            //    ObjectPath = 'o',                            // maps to ALLJOYN_OBJECT_PATH (string)
            //    Uint16 = 'q',                                // maps to ALLLJOYN_UINT16
            //    Struct = 'r',                                // maps to ALLJOYN_STRUCT
            //    String = 's',                                // maps to ALLJOYN_STRING
            //    Uint64 = 't',                                // maps to ALLJOYN_UINT64
            //    Uint32 = 'u',                                // maps to ALLJOYN_UINT32
            //    Variant = 'v',                               // maps to ALLJOYN_VARIANT
            //    Int64 = 'x',                                 // maps to ALLJOYN_INT64
            //    Uint8 = 'y',                                 // maps to ALLJOYN_BYTE
            //    ArrayByte = 'a',
            //    ArrayByteMask = 0xFF,
            //    BooleanArray    = ('b' << 8) | ArrayByte,    // maps to ALLJOYN_BOOLEAN_ARRAY
            //    DoubleArray     = ('d' << 8) | ArrayByte,    // maps to ALLJOYN_DOUBLE_ARRAY
            //    Int32Array      = ('i' << 8) | ArrayByte,    // maps to ALLJOYN_INT32_ARRAY
            //    Int16Array      = ('n' << 8) | ArrayByte,    // maps to ALLJOYN_INT16_ARRAY
            //    Uint16Array     = ('q' << 8) | ArrayByte,    // maps to ALLJOYN_UINT16_ARRAY
            //    Uint64Array     = ('t' << 8) | ArrayByte,    // maps to ALLJOYN_UINT64_ARRAY
            //    Uint32Array     = ('u' << 8) | ArrayByte,    // maps to ALLJOYN_UINT32_ARRAY
            //    VariantArray    = ('v' << 8) | ArrayByte,    // no AllJoyn typeid equivalent defined
            //    Int64Array      = ('x' << 8) | ArrayByte,    // maps to ALLJOYN_INT64_ARRAY
            //    Uint8Array      = ('y' << 8) | ArrayByte,    // maps to ALLJOYN_BYTE_ARRAY
            //    SignatureArray  = ('g' << 8) | ArrayByte,    // no AllJoyn typeid equivalent defined
            //    ObjectPathArray = ('o' << 8) | ArrayByte,    // no AllJoyn typeid equivalent defined
            //    StringArray     = ('s' << 8) | ArrayByte,    // no AllJoyn typeid equivalent defined
            //    StructArray     = ('r' << 8) | ArrayByte,    // no AllJoyn typeid equivalent defined
            // };
            var argument = new AllJoynMessageArgStructure(t);

            // var count = paramDef.Fields.Count;
            // string[] types = paramDef.Fields.Select(f => f.Type.ToString()).ToArray();
            // List<object> argument = new List<object>();
            argument.Add(Url);
            argument.Add(Title ?? " ");
            argument.Add(Artist ?? " ");
            argument.Add(ThumbnailUrl?.OriginalString ?? " ");
            argument.Add((long)Duration.TotalMilliseconds);
            argument.Add(MediaType ?? " ");
            argument.Add(Album ?? " ");
            argument.Add(Genre ?? " ");

            // Other data: a{ss}
            var otherData = new Dictionary <object, object>();

            if (OtherData != null)
            {
                foreach (var item in OtherData)
                {
                    otherData.Add(item.Key, item.Value);
                }
            }

            argument.Add(otherData.ToList());

            // medium desc: a{sv}
            var mediumDesc = new Dictionary <object, object>();

            if (OtherData != null)
            {
                foreach (var item in OtherData)
                {
                    mediumDesc.Add(item.Key, item.Value);
                }
            }

            argument.Add(mediumDesc.ToList());

            // AllJoynMessageArgVariant v = new AllJoynMessageArgVariant();
            // var arg = new DeviceProviders.AllJoynMessageArgVariant(AllJoynTypeDefinition.CreateTypeDefintions("v").First(), 0);
            // arg.Value = "upnp";
            argument.Add(UserData ?? "upnp"); // Variant: userdata
            return(argument);
        }