using System; using Foundation; using HDLSceneSiri; //using HdlSiri; using Intents; using UIKit; namespace Other.Siri { public class SiriScene : NSObject , INSCoding { public SiriScene() { } public string Id; public string Name; public void EncodeTo(NSCoder encoder) { Console.WriteLine("nscoder"); } public HDLRunSceneIntent Intent { get { var orderSoupIntent = new HDLRunSceneIntent();// { SceneId = Id, SceneName = Name }; orderSoupIntent.SceneId = Id;//orderSoupIntent.Quantity = new NSNumber(Quantity); orderSoupIntent.SceneName = Name;//orderSoupIntent.Soup = new INObject(MenuItem.ItemNameKey, MenuItem.LocalizedString); //var image = UIImage.FromBundle(MenuItem.IconImageName); //if (!(image is null)) //{ // var data = image.AsPNG(); // orderSoupIntent.SetImage(INImage.FromData(data), "soup"); //} //orderSoupIntent.Options = MenuItemOptions // .ToArray() // .Select(arg => new INObject(arg.Value, arg.LocalizedString)) // .ToArray(); //var comment = "Suggested phrase for ordering a specific soup"; //var phrase = NSBundleHelper.SoupKitBundle.GetLocalizedString("ORDER_SOUP_SUGGESTED_PHRASE", comment); //orderSoupIntent.SuggestedInvocationPhrase = String.Format(phrase, MenuItem.LocalizedString); return orderSoupIntent; } } public static SiriScene FromOrderSoupIntent(HDLRunSceneIntent intent) { //var menuManager = new SoupMenuManager(); //var soupID = intent.Soup?.Identifier; //if (soupID is null) //{ // return null; //} //var menuItem = menuManager.FindItem(soupID); //if (menuItem is null) //{ // return null; //} //var quantity = intent.Quantity; //if (menuItem is null) //{ // return null; //} //MenuItemOption[] rawOptions; //if (intent.Options is null) //{ // rawOptions = new MenuItemOption[0]; //} //else //{ // // For the equivalent code in Apple's Swift sample, compactMap // // is used. This eliminates nil values from the final result. // // Here, LINQ's Where method is used to filter out the null // // values. // rawOptions = intent.Options.Select((option) => // { // var optionID = option.Identifier; // return (optionID is null) ? null : new MenuItemOption(optionID); // }).Where((option) => !(option is null)).ToArray(); //} //var order = new Order(quantity.Int32Value, menuItem, new NSMutableSet(rawOptions)); //return order; return null; } } }