Esempio n. 1
0
        public new UserIntent <TData> getIntent <TData>()
        {
            UserIntent <TData> intent = new UserIntent <TData>();

            intent.trigger = this.trigger;
            intent.name    = this.name;
            intent.action  = (data) => this.action((TData)data);
            intent.data    = (TData)this.data;
            return(intent);
        }
Esempio n. 2
0
 public IntentManager AddIntentData <TData>(UserIntent <TData> _intentData)
 {
     if (_intentData.isValid())
     {
         if (!this._intentRepository.Exists(_intentData.getStorageKey()))
         {
             throw new Exception($"Intent with key [{_intentData.getStorageKey()}] not registered");
         }
         var intentCategory = this.GetIntents(_intentData.trigger).FirstOrDefault(intent => intent.name.ToLower() == _intentData.name.ToLower());
         intentCategory.beforeAddIntent();
         var sessionIntents = this._intentRepository.Get <List <UserIntent> >(_intentData.getStorageKey());
         sessionIntents.Add(_intentData.getIntent());
         intentCategory.afterAddIntent();
     }
     return(this);
 }
Esempio n. 3
0
        public new UserIntent getIntent()
        {
            UserIntent intent = new UserIntent();

            intent.type = this.GetType();
            if (this.action == null)
            {
                this.action = IntentManager.GetIntentManager().GetIntent <TData>(this.trigger, this.name).action;
            }
            intent.action = (data) =>
            {
                this.action.Invoke((TData)data);
            };
            intent.name    = this.name;
            intent.trigger = this.trigger;
            intent.data    = this.data;
            return(intent);
        }