wxr
2021-11-18 dd3f6db0cb3c242758ab0000a0513e093f02531c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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;
        }
 
 
    }
}