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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
/// <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); }