File was renamed from HDL-ON_iOS/Other/Siri/Data/SceneDateManager.cs |
| | |
| | | { |
| | | public SceneDateManager() : base(new UserDefaultsStorageDescriptor(NSUserDefaultsHelper.StorageKeys.OrderHistory), new NSMutableArray<SiriScene>()) { } |
| | | |
| | | // Converts an `Order` into `OrderSoupIntent` and donates it as an |
| | | // interaction to the system so that this order can be suggested in the |
| | | // future or turned into a voice shortcut for quickly placing the same |
| | | // order in the future. |
| | | void DonateInteraction(SiriScene order) |
| | | { |
| | | var interaction = new INInteraction(order.Intent, null); |
| | | interaction.Identifier = order.Id.ToString(); |
| | | interaction.DonateInteraction((error) => |
| | | { |
| | | if (!(error is null)) |
| | | { |
| | | Console.WriteLine($"Interaction donation failed: {error}"); |
| | | } |
| | | else |
| | | { |
| | | Console.WriteLine("Successfully donated interaction."); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | #region Public API for clients of `SoupOrderDataManager` |
| | | // Convenience method to access the data with a property name that makes |
| | |
| | | } |
| | | } |
| | | |
| | | public void PlaceOrder(SiriScene order) |
| | | { |
| | | // Access to `ManagedDataBackingInstance` is only valid on |
| | | // `DataAccessQueue`. |
| | | DataAccessQueue.DispatchSync(() => |
| | | { |
| | | if (ManagedDataBackingInstance.Count == 0) |
| | | { |
| | | // Getting an error trying to insert at 0 for an empty |
| | | // NSMutableArray<Order> |
| | | ManagedDataBackingInstance.Add(order); |
| | | } |
| | | else |
| | | { |
| | | ManagedDataBackingInstance.Insert(order, 0); |
| | | } |
| | | }); |
| | | |
| | | // Access to UserDefaults is gated behind a separate access queue. |
| | | WriteData(); |
| | | |
| | | // Donate an interaction to the system. |
| | | DonateInteraction(order); |
| | | } |
| | | #endregion |
| | | |
| | | #region Support methods for unarchiving saved data |