コード例 #1
0
        public async Task RepositoryLoadSavedDataUsingExpando()
        {
            // ARRANGE
            var     dataRepository = new DataRepository(DataReposityryPath);
            dynamic dataBeingSaved = new FluentExpandoObject(false, true);
            var     now            = DateTime.Now;

            dataBeingSaved.SomeString   = "this data should be saved!";
            dataBeingSaved.SomeInt      = 123456;
            dataBeingSaved.SomeFloat    = 1.23456;
            dataBeingSaved.SomeDateTime = now;

            // ACT
            await dataRepository.Save <IDictionary <string, object> >("RepositoryLoadSavedData_id", dataBeingSaved);

            var dataReturned = await dataRepository.Get <IDictionary <string, object> >("RepositoryLoadSavedData_id");

            var returnedFluentExpandoObject = new FluentExpandoObject();

            returnedFluentExpandoObject.CopyFrom(dataReturned);

            dynamic dynamicDataReturned = returnedFluentExpandoObject;

            // ASSERT
            Assert.Equal(dataBeingSaved.SomeString, dynamicDataReturned !.SomeString);
            Assert.Equal(dataBeingSaved.SomeInt, dynamicDataReturned !.SomeInt);
            Assert.Equal(dataBeingSaved.SomeFloat, dynamicDataReturned !.SomeFloat);
            Assert.Equal(dataBeingSaved.SomeDateTime, dynamicDataReturned !.SomeDateTime);
        }
コード例 #2
0
        public void Reload(dynamic?data = null)
        {
            var serviceData = new FluentExpandoObject();

            if (data is ExpandoObject)
            {
                serviceData.CopyFrom(data);
            }
            else if (data is object)
            {
                var expObject = ((object)data).ToExpandoObject();
                serviceData.CopyFrom(expObject);
            }

            DaemonRxApp.CallService("zone", "reload", serviceData);
        }
コード例 #3
0
        public void MarkRead(dynamic?data = null)
        {
            var serviceData = new FluentExpandoObject();

            if (data is ExpandoObject)
            {
                serviceData.CopyFrom(data);
            }
            else if (data is object)
            {
                var expObject = ((object)data).ToExpandoObject();
                serviceData.CopyFrom(expObject);
            }

            DaemonRxApp.CallService("persistent_notification", "mark_read", serviceData);
        }
コード例 #4
0
        public void SelectPrevious(dynamic?data = null)
        {
            var serviceData = new FluentExpandoObject();

            if (data is ExpandoObject)
            {
                serviceData.CopyFrom(data);
            }
            else if (data is object)
            {
                var expObject = ((object)data).ToExpandoObject();
                serviceData.CopyFrom(expObject);
            }

            serviceData["entity_id"] = EntityId;
            DaemonRxApp.CallService("input_select", "select_previous", serviceData);
        }
コード例 #5
0
        public void ShuffleSet(dynamic?data = null)
        {
            var serviceData = new FluentExpandoObject();

            if (data is ExpandoObject)
            {
                serviceData.CopyFrom(data);
            }
            else if (data is object)
            {
                var expObject = ((object)data).ToExpandoObject();
                serviceData.CopyFrom(expObject);
            }

            serviceData["entity_id"] = EntityId;
            DaemonRxApp.CallService("media_player", "shuffle_set", serviceData);
        }
コード例 #6
0
        public void SelectSoundMode(dynamic?data = null)
        {
            var serviceData = new FluentExpandoObject();

            if (data is ExpandoObject)
            {
                serviceData.CopyFrom(data);
            }
            else if (data is object)
            {
                var expObject = ((object)data).ToExpandoObject();
                serviceData.CopyFrom(expObject);
            }

            serviceData["entity_id"] = EntityId;
            DaemonRxApp.CallService("media_player", "select_sound_mode", serviceData);
        }
コード例 #7
0
        public void MediaPreviousTrack(dynamic?data = null)
        {
            var serviceData = new FluentExpandoObject();

            if (data is ExpandoObject)
            {
                serviceData.CopyFrom(data);
            }
            else if (data is object)
            {
                var expObject = ((object)data).ToExpandoObject();
                serviceData.CopyFrom(expObject);
            }

            serviceData["entity_id"] = EntityId;
            DaemonRxApp.CallService("media_player", "media_previous_track", serviceData);
        }
コード例 #8
0
        public void Record(dynamic?data = null)
        {
            var serviceData = new FluentExpandoObject();

            if (data is ExpandoObject)
            {
                serviceData.CopyFrom(data);
            }
            else if (data is object)
            {
                var expObject = ((object)data).ToExpandoObject();
                serviceData.CopyFrom(expObject);
            }

            serviceData["entity_id"] = EntityId;
            DaemonRxApp.CallService("camera", "record", serviceData);
        }
コード例 #9
0
        public void DisableMotionDetection(dynamic?data = null)
        {
            var serviceData = new FluentExpandoObject();

            if (data is ExpandoObject)
            {
                serviceData.CopyFrom(data);
            }
            else if (data is object)
            {
                var expObject = ((object)data).ToExpandoObject();
                serviceData.CopyFrom(expObject);
            }

            serviceData["entity_id"] = EntityId;
            DaemonRxApp.CallService("camera", "disable_motion_detection", serviceData);
        }
コード例 #10
0
        /// <summary>
        /// Performs a specified service call to a specified domain with specified data
        /// </summary>
        /// <param name="domain">The domain to which the service call belongs</param>
        /// <param name="service">The service in the domain to call</param>
        /// <param name="data">Additional data to send to the service</param>
        /// <param name="sendEntityId">If true it will include the entity_id attribute with this entity's EntityId with the service call</param>
        protected void CallService(string domain, string service, dynamic?data = null, bool sendEntityId = false)
        {
            var serviceData = new FluentExpandoObject();

            if (data is ExpandoObject)
            {
                serviceData.CopyFrom(data);
            }
            else if (data is not null)
            {
                var expObject = ((object)data).ToExpandoObject();
                if (expObject is not null)
                {
                    serviceData.CopyFrom(expObject);
                }
            }

            if (sendEntityId)
            {
                serviceData["entity_id"] = EntityId;
            }

            DaemonRxApp.CallService(domain, service, serviceData);
        }