Пример #1
0
        public void Triggered(MacroTriggerWithArguments source)
        {
            string logMessage = string.Format("Macro #{0} ({1}) triggered. Event: {2}.", ID, Name, source.HumanReadable);

            LogDispatcher.I(LOG_TAG, logMessage);
            _run();
        }
Пример #2
0
 public virtual void Register(MacroTriggerWithArguments triggerWithArguments)
 {
     if (!registeredTriggersWithArguments.Contains(triggerWithArguments))
     {
         registeredTriggersWithArguments.Add(triggerWithArguments);
     }
 }
Пример #3
0
 public void AddTrigger(MacroTriggerWithArguments trigger)
 {
     if (!triggers.Contains(trigger))
     {
         triggers.Add(trigger);
     }
     trigger.Macro = this;
 }
Пример #4
0
 public virtual void Activate(MacroTriggerWithArguments triggerWithArguments)
 {
     if (triggerWithArguments.Trigger != this)
     {
         return;
     }
     if (triggerWithArguments.ArgumentObjects.Length != Arguments.Length)
     {
         return;
     }
     _activate(triggerWithArguments);
 }
Пример #5
0
        public virtual void Deactivate(MacroTriggerWithArguments triggerWithArguments)
        {
            if (triggerWithArguments.Trigger != this)
            {
                return;
            }
            TActivationData activationData = triggerWithArguments.ActivationData as TActivationData;

            if (activationData == null)
            {
                return;
            }
            _deactivate(triggerWithArguments, activationData);
        }
Пример #6
0
        public XElement SerializeItem(object item, object parentItem)
        {
            MacroTriggerWithArguments triggerWA = item as MacroTriggerWithArguments;

            if (triggerWA == null)
            {
                return(null);
            }

            XElement xmlElement = new XElement(TAG_NAME);

            xmlElement.SetAttributeValue(ATTRIBUTE_CODE, triggerWA.TriggerCode);

            foreach (string argumentStr in triggerWA.ArgumentKeys)
            {
                XElement argElement = new XElement(TAG_NAME_ARGUMENT);
                argElement.SetAttributeValue(ATTRIBUTE_ARGUMENT_KEY, argumentStr);
                xmlElement.Add(argElement);
            }

            return(xmlElement);
        }
Пример #7
0
 public virtual void Unregister(MacroTriggerWithArguments triggerWithArguments)
 {
     registeredTriggersWithArguments.Remove(triggerWithArguments);
 }
Пример #8
0
 public void RemoveTrigger(MacroTriggerWithArguments trigger)
 {
     triggers.Remove(trigger);
     trigger.Macro = null;
 }
Пример #9
0
 protected abstract void _deactivate(MacroTriggerWithArguments triggerWithArguments, TActivationData activationData);
Пример #10
0
 protected abstract void _activate(MacroTriggerWithArguments triggerWithArguments);