using System;
|
using Foundation;
|
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.Quantity = new NSNumber(Quantity);
|
//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<MenuItemOption>()
|
// .Select<MenuItemOption, INObject>(arg => new INObject(arg.Value, arg.LocalizedString))
|
// .ToArray<INObject>();
|
|
//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<INObject, MenuItemOption>((option) =>
|
// {
|
// var optionID = option.Identifier;
|
// return (optionID is null) ? null : new MenuItemOption(optionID);
|
// }).Where((option) => !(option is null)).ToArray<MenuItemOption>();
|
//}
|
|
//var order = new Order(quantity.Int32Value, menuItem, new NSMutableSet<MenuItemOption>(rawOptions));
|
|
//return order;
|
return null;
|
}
|
|
|
}
|
}
|