示例#1
0
        /// <summary>
        /// Creates new instance of media.
        /// </summary>
        /// <typeparam name="T">Type of media to create</typeparam>
        /// <param name="input">The media input string</param>
        /// <param name="options">Optional media options</param>
        /// <returns>Newly created media</returns>
        public T CreateMedia <T>(string input, params string[] options) where T : IMedia
        {
            T media = ObjectFactory.Build <T>(m_hMediaLib);

            media.Input = input;
            media.AddOptions(options);

            return(media);
        }
        /// <summary>
        /// Creates new instance of media.
        /// </summary>
        /// <typeparam name="T">Type of media to create</typeparam>
        /// <param name="input">The media input string</param>
        /// <param name="options">Optional media options</param>
        /// <returns>Newly created media</returns>
        public T CreateMedia <T>(string input, params string[] options) where T : IMedia
        {
            T media = ObjectFactory.Build <T>(m_hMediaLib);

            media.Input = input;
            //media.AddOptions(options); // just optiuni-vlc, nu si media --> null params

            return(media);
        }
示例#3
0
        /// <summary>
        /// Creates new instance of media with custom input source
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TSource"></typeparam>
        /// <param name="source"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public T CreateMedia <T, TSource>(TSource source, params string[] options) where T : ICustomSourceMedia <TSource>
        {
            T media = ObjectFactory.Build <T>(m_hMediaLib);

            media.Source = source;
            media.AddOptions(options);

            return(media);
        }
        private void WriteObject(JsonWriter writer, APObject obj)
        {
            var serializer = ObjectFactory.Build <IJsonSerializer>();
            var bytes      = serializer.Serialize(obj);

            using (var reader = new StreamReader(new MemoryStream(bytes), Encoding.UTF8))
            {
                writer.WriteRawValue(reader.ReadToEnd());
            }
        }
示例#5
0
        public static Status Parse(byte[] data)
        {
            if (data == null || data.Length == 0)
            {
                return(null);
            }
            var serializer = ObjectFactory.Build <IJsonSerializer>();

            return(serializer.Deserialize <Status>(data));
        }
 public async Task Start()
 {
     if (this.Transport != null)
     {
         return;
     }
     this.Transport           = ObjectFactory.Build <IRealTimeTransport>();
     this.Transport.Received += OnReceive;
     await this.Transport.Start();
 }
示例#7
0
 public async static Task SendMessageAsync(object message, params string[] userIds)
 {
     var serializer = ObjectFactory.Build <IJsonSerializer>();
     var msg        = new SendToUsers
     {
         Users   = userIds,
         Payload = JObject.FromObject(message)
     };
     await App.SendMessageAsync(msg);
 }
示例#8
0
 public async static Task SendMessageAsync(object message, string hub)
 {
     var serializer = ObjectFactory.Build <IJsonSerializer>();
     var msg        = new SendToHub
     {
         Hub     = hub,
         Payload = JObject.FromObject(message)
     };
     await App.SendMessageAsync(msg);
 }
示例#9
0
    /// <summary>
    /// Crée le GameObject correspondant à une porte.
    /// </summary>
    /// <param name="gateStruct"></param>
    private GateObject CreateGateObject(Circuit.GateStruct gateStruct)
    {
        Gate gate = gateStruct.gate;

        GateObject gateObject = ObjectFactory.Build(gate, _gridGame.transform);

        gateObject.gateStruct = gateStruct;

        return(gateObject);
    }
示例#10
0
        /// <summary>
        /// Creates new instance of media list.
        /// </summary>
        /// <typeparam name="T">Type of media list</typeparam>
        /// <param name="mediaItems">Collection of media inputs</param>
        /// <returns>Newly created media list</returns>
        public T CreateMediaList <T>(IEnumerable <string> mediaItems) where T : IMediaList
        {
            T mediaList = ObjectFactory.Build <T>(m_hMediaLib);

            foreach (var file in mediaItems)
            {
                mediaList.Add(this.CreateMedia <IMedia>(file));
            }

            return(mediaList);
        }
        private APObject BuildNewInstance(JObject json, Type objectType)
        {
            // What is the spec for building a new instance
            // We look for type in the json. If it does not exist then we defer to the type passed.
            string type;

            type = GetType(json);
            ICreateInstanceBehaviorFactory factory = ObjectFactory.Build <ICreateInstanceBehaviorFactory>();

            return(factory.GetBehavior(type, objectType).CreateInstance(type, json));
        }
        public override string ToString()
        {
            var serializer = ObjectFactory.Build <IJsonSerializer>();
            var bytes      = serializer.Serialize(this);

            using (var memStream = new MemoryStream(bytes))
            {
                using (var reader = new StreamReader(memStream))
                {
                    return(reader.ReadToEnd());
                }
            }
        }
 public void SetUser(APUser user)
 {
     if (user == null)
     {
         this.GetSession()[SessionKeys.ForUser()] = null;
     }
     else
     {
         var serializer = ObjectFactory.Build <IJsonSerializer>();
         var bytes      = serializer.Serialize(user);
         this.GetSession()[SessionKeys.ForUser()] = bytes;
     }
 }
        public APUser GetUser()
        {
            var session   = GetSession();
            var userBytes = session[SessionKeys.ForUser()] as byte[];

            if (userBytes == null || userBytes.Length == 0)
            {
                return(null);
            }
            var serializer = ObjectFactory.Build <IJsonSerializer>();

            return(serializer.Deserialize <APUser>(userBytes));
        }
示例#15
0
        /// <summary>
        /// Creates new instance of media.
        /// </summary>
        /// <typeparam name="T">Type of media to create</typeparam>
        /// <param name="input">The media input string</param>
        /// <param name="options">Optional media options</param>
        /// <returns>Newly created media</returns>
        public T CreateMedia <T>(string input, params string[] options) where T : IMedia
        {
            if (input.StartsWith("//"))
            {
                input = "file:" + input;
            }
            T media = ObjectFactory.Build <T>(m_hMediaLib);

            media.Input = input;
            media.AddOptions(options);

            return(media);
        }
        public void RegisterEventForTypeAndInvoke()
        {
            var invoked = false;
            IEventDispatcher dispatcher = ObjectFactory.Build <IEventDispatcher>();

            dispatcher.Subscribe("test", "test", m =>
            {
                invoked = true;
            });
            dispatcher.Notify(new ObjectUpdatedMessage
            {
                EventType = "test",
                Type      = "test"
            });
            Assert.IsTrue(invoked);
        }
        private void OnReceive(string obj)
        {
            var copy = _onReceive;

            if (copy == null)
            {
                return;
            }
            var serializer = ObjectFactory.Build <IJsonSerializer>();
            var message    = serializer.Deserialize <RealTimeMessage>(Encoding.UTF8.GetBytes(obj));

            if (message != null)
            {
                copy(message);
            }
        }
示例#18
0
        internal static void Remove(ITopic topic, Action <RealTimeMessage> handler)
        {
            var subscriptionManager = ObjectFactory.Build <ISubscriptionManager>();

            lock (_lock)
            {
                var sub = subscriptionManager.Get(topic);
                if (sub == null)
                {
                    return;
                }
                sub.Triggered -= handler;
                if (sub.IsEmpty == true)
                {
                    subscriptionManager.Unsubscribe(topic);
                }
            }
        }
示例#19
0
        public void SerializerIconicTilePushNotificationTest()
        {
            var msg = PushNotification
                      .Broadcast("This is a test message.")
                      .WithBadge("+1")
                      .WithExpiry(100000)
                      .WithPlatformOptions(new IOsOptions {
                SoundFile = "soundfile"
            })
                      .WithPlatformOptions(new AndroidOptions {
                NotificationTitle = "title"
            })
                      .WithPlatformOptions(
                new WindowsPhoneOptions
            {
                Notification = TileNotification.CreateNewIconicTile(
                    new IconicTile
                {
                    BackgroundColor = "bc",
                    WideContent1    = "wc1",
                    WideContent2    = "wc2",
                    FrontTitle      = "front title"
                },
                    new FlipTile
                {
                    BackBackgroundImage  = "bbimage",
                    BackContent          = "back content",
                    BackTitle            = "back title",
                    FrontBackgroundImage = "fbi",
                    FrontCount           = "front count",
                    FrontTitle           = "front title",
                    SmallBackgroundImage = "sbi",
                    TileId = "tileid",
                    WideBackBackgroundImage = "wbi",
                    WideBackContent         = "wbc",
                    WideBackgroundImage     = "wbi"
                })
            });
            var serializer = ObjectFactory.Build <IJsonSerializer>();

            Console.WriteLine(Encoding.UTF8.GetString(serializer.Serialize(msg)));
        }
        public void TestForDoubleInvocation()
        {
            var typeInvoked             = false;
            var typeAndIdInvoked        = false;
            IEventDispatcher dispatcher = ObjectFactory.Build <IEventDispatcher>();

            dispatcher.Subscribe("test", "test", m =>
            {
                typeInvoked = true;
            });
            dispatcher.Subscribe("test", "test", "1", m =>
            {
                typeAndIdInvoked = true;
            });
            dispatcher.Notify(new ObjectUpdatedMessage
            {
                EventType = "test",
                Type      = "test",
                ObjectId  = "1"
            });
            Assert.IsTrue(typeInvoked);
            Assert.IsTrue(typeAndIdInvoked);
        }
        public void DoubleRegistrationShouldFailTest()
        {
            Articles.Subscribe("update", "user", e =>
            {
            });
            IEventDispatcher dispatcher = ObjectFactory.Build <IEventDispatcher>();

            dispatcher.Subscribe("test", "test", m =>
            {
                // Do something
            });
            try
            {
                dispatcher.Subscribe("test", "test", m =>
                {
                    // Do something
                });
                Assert.Fail("Subscription did not fail on multiple subscriptions to same event.");
            }
            catch
            {
            }
        }
示例#22
0
        public void SerializerRawPushNotificationTest()
        {
            var msg = PushNotification
                      .Broadcast("This is a test message.")
                      .WithBadge("+1")
                      .WithExpiry(100000)
                      .WithPlatformOptions(new IOsOptions {
                SoundFile = "soundfile"
            })
                      .WithPlatformOptions(new AndroidOptions {
                NotificationTitle = "title"
            })
                      .WithPlatformOptions(
                new WindowsPhoneOptions
            {
                Notification = new RawNotification
                {
                    RawData = "raw string data.."
                }
            });
            var serializer = ObjectFactory.Build <IJsonSerializer>();

            Console.WriteLine(Encoding.UTF8.GetString(serializer.Serialize(msg)));
        }
示例#23
0
        public override byte[] ToBytes()
        {
            var serializer = ObjectFactory.Build <IJsonSerializer>();

            return(serializer.Serialize(this.Connection));
        }
示例#24
0
 /// <summary>
 /// Creates media list instance with no media items
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public T CreateMediaList <T>() where T : IMediaList
 {
     return(ObjectFactory.Build <T>(m_hMediaLib));
 }
示例#25
0
        public virtual byte[] ToBytes()
        {
            IJsonSerializer serializer = ObjectFactory.Build <IJsonSerializer>();

            return(serializer.Serialize(this));
        }
        private static T Parse <T>(byte[] bytes)
        {
            var serializer = ObjectFactory.Build <IJsonSerializer>();

            return(serializer.Deserialize <T>(bytes));
        }
示例#27
0
 /// <summary>
 /// Creates media library
 /// </summary>
 /// <returns></returns>
 public IMediaLibrary CreateMediaLibrary()
 {
     return(ObjectFactory.Build <IMediaLibrary>(m_hMediaLib));
 }
示例#28
0
 /// <summary>
 /// Creates new instance of player.
 /// </summary>
 /// <typeparam name="T">Type of the player to create</typeparam>
 /// <returns>Newly created player</returns>
 public T CreatePlayer <T>() where T : IPlayer
 {
     return(ObjectFactory.Build <T>(m_hMediaLib));
 }
示例#29
0
 /// <summary>
 /// Creates new instance of media list player
 /// </summary>
 /// <typeparam name="T">Type of media list player</typeparam>
 /// <param name="mediaList">Media list</param>
 /// <returns>Newly created media list player</returns>
 public T CreateMediaListPlayer <T>(IMediaList mediaList) where T : IMediaListPlayer
 {
     return(ObjectFactory.Build <T>(m_hMediaLib, mediaList));
 }
示例#30
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public IRendererDiscovery CreateRendererDiscoverer(string name)
 {
     return(ObjectFactory.Build <IRendererDiscovery>(m_hMediaLib, name));
 }