public void Constructor_CalledWithValidSubmitTypeArgument_Success() { var submitType = "foo"; var sut = new TriggerAttribute(submitType); Assert.IsNotNull(sut); Assert.IsTrue(sut.SubmitType == submitType); }
public static bool Init() { //We will search our assemblies for Quests by reflection so //it is not neccessary anymore to register new quests with the //server, it is done automatically! foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { // Walk through each type in the assembly foreach (Type type in assembly.GetTypes()) { // Pick up a class if (type.IsClass != true) { continue; } if (typeof(IBehaviourAction).IsAssignableFrom(type)) { ActionAttribute attr = GetActionAttribute(type); if (attr != null) { if (log.IsInfoEnabled) { log.Info("Registering BehaviourAction: " + type.FullName); } RegisterBehaviourAction(attr.ActionType, type); } } if (typeof(IBehaviourTrigger).IsAssignableFrom(type)) { TriggerAttribute attr = getTriggerAttribute(type); if (attr != null) { if (log.IsInfoEnabled) { log.Info("Registering BehaviourTrigger: " + type.FullName); } RegisterBehaviourTrigger(attr.TriggerType, type); } } if (typeof(IBehaviourRequirement).IsAssignableFrom(type)) { RequirementAttribute attr = getRequirementAttribute(type); if (attr != null) { if (log.IsInfoEnabled) { log.Info("Registering BehaviourRequirement: " + type.FullName); } RegisterBehaviourRequirement(attr.RequirementType, type); } } } } return(true); }
public ExecuteTriggerLogSection(UIComponent component, TriggerAttribute trigger, TriggerEvents triggerEvent) : base(component) { string triggerAsString = Stringifier.ToStringInSimpleStructuredForm(trigger, typeof(TriggerAttribute)); Message = $"Execute trigger {triggerAsString} on {triggerEvent} against {component.ComponentFullName}"; Level = LogLevel.Trace; }
private void ProcessMethods(Type type, SqlTable table) { MethodInfo[] methods = type.GetMethods( BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo method in methods) { if (method.IsDefined(typeof(TriggerAttribute), false)) { TriggerAttribute attr = (TriggerAttribute) method.GetCustomAttributes(typeof(TriggerAttribute), false)[0]; SqlTrigger trigger = new SqlTrigger(method, attr.Timing); table.AddTrigger(trigger); } } }
/// <summary> /// Creates a new questtrigger and does some simple triggertype parameter compatibility checking /// </summary> /// <param name="defaultNPC"></param> /// <param name="notifyHandler"></param> /// <param name="type">Triggertype</param> /// <param name="k">keyword (K), meaning depends on triggertype</param> /// <param name="i">variable (I), meaning depends on triggertype</param> public AbstractTrigger(GameLiving defaultNPC, DOLEventHandler notifyHandler, eTriggerType type, object k, object i) : this(defaultNPC, notifyHandler, type) { TriggerAttribute attr = BehaviourMgr.getTriggerAttribute(this.GetType()); // handle parameter K object defaultValueK = GetDefaultValue(attr.DefaultValueK); this.k = (TypeK)BehaviourUtils.ConvertObject(k, defaultValueK, typeof(TypeK)); CheckParameter(K, attr.IsNullableK, typeof(TypeK)); // handle parameter I object defaultValueI = GetDefaultValue(attr.DefaultValueI); this.i = (TypeI)BehaviourUtils.ConvertObject(i, defaultValueI, typeof(TypeI)); CheckParameter(I, attr.IsNullableI, typeof(TypeI)); }
public override void DrawGUI() { EventResponder returnedResponder; Expanded = TriggerGUILayout.DrawCustomActionInspectorBar(Expanded, Action, out returnedResponder); if (!returnedResponder) { Delete(); return; } if (returnedResponder != Action) { Action = returnedResponder; } if (Expanded) { EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Space(25); EditorGUILayout.BeginVertical(); GUILayout.BeginVertical(GUI.skin.box); TriggerAttribute triggerAttribute = TriggerGUILayout.GetTriggerAttribute(Action.GetType()); if (triggerAttribute != null) { GUILayout.Label(triggerAttribute.Description, EditorStyles.wordWrappedLabel, GUILayout.ExpandWidth(false)); } EditorGUILayoutExt.BeginLabelStyle(11, FontStyle.Bold, null, null); GUILayout.Label("Input Parameters"); EditorGUILayoutExt.EndLabelStyle(); TriggerGUILayout.DrawSerializedObject(_serializedAction, Action.GetType(), GetScopeVariables()); EditorGUILayout.Separator(); GUILayout.EndVertical(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } }
public override void DrawGUI() { EventFilter returnedFilter; Expanded = TriggerGUILayout.DrawCustomFilterInspectorBar(Expanded, Filter, out returnedFilter); if (!returnedFilter) { foreach (Variable var in _outputVariables.Values) { ScriptableObject.DestroyImmediate(var); } Delete(); return; } Filter = returnedFilter; if (Expanded) { EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Space(25); EditorGUILayout.BeginVertical(); GUILayout.BeginVertical(GUI.skin.box); TriggerAttribute triggerAttribute = TriggerGUILayout.GetTriggerAttribute(Filter.GetType()); if (triggerAttribute != null) { GUILayout.Label(triggerAttribute.Description, EditorStyles.wordWrappedLabel, GUILayout.ExpandWidth(false)); } EditorGUILayoutExt.BeginLabelStyle(11, FontStyle.Bold, null, null); GUILayout.Label("Input Parameters"); EditorGUILayoutExt.EndLabelStyle(); TriggerGUILayout.DrawSerializedObject(_serializedFilter, Filter.GetType(), Parent.GetScopeVariables()); EditorGUILayout.Separator(); EditorGUILayoutExt.BeginLabelStyle(11, FontStyle.Bold, null, null); GUILayout.Label("Output Parameters"); EditorGUILayoutExt.EndLabelStyle(); foreach (var v in Filter.GetOutputParameterDeclarations()) { GUILayout.Label(v.Name, GUILayout.ExpandWidth(false)); } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Box("", GUILayout.Width(300), GUILayout.Height(1)); EditorGUILayout.EndHorizontal(); TriggerGUILayout.DrawAddFilterSelector(Filter.gameObject, Context.Refresh); TriggerGUILayout.DrawAddActionSelector(Filter.gameObject, Context.Refresh); EditorGUILayout.Separator(); GUILayout.EndVertical(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } }
public override void DrawGUI() { EventSender returnedSender; Expanded = TriggerGUILayout.DrawCustomEventInspectorBar(Expanded, _gameObject, out returnedSender); if (Sender != returnedSender) { Sender = returnedSender; } if (Sender == null) { return; } if (Expanded) { EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.Space(25); EditorGUILayout.BeginVertical(); GUILayout.BeginVertical(GUI.skin.box); TriggerAttribute triggerAttribute = TriggerGUILayout.GetTriggerAttribute(Sender.GetType()); if (triggerAttribute != null) { GUILayout.Label(triggerAttribute.Description, EditorStyles.wordWrappedLabel, GUILayout.ExpandWidth(false)); } if (_serializedEvent.GetIterator().CountRemaining() > 1) { EditorGUILayoutExt.BeginLabelStyle(11, FontStyle.Bold, null, null); GUILayout.Label("Input Parameters"); EditorGUILayoutExt.EndLabelStyle(); } TriggerGUILayout.DrawSerializedObject(_serializedEvent, Sender.GetType(), Context.GlobalSymbolTable.Variables); if (Sender.GetOutputParameterDeclarations().Count > 0) { EditorGUILayout.Separator(); EditorGUILayoutExt.BeginLabelStyle(11, FontStyle.Bold, null, null); GUILayout.Label("Output Parameters"); EditorGUILayoutExt.EndLabelStyle(); foreach (var v in Sender.GetOutputParameterDeclarations()) { EditorGUILayout.BeginHorizontal(); GUILayout.Space(15); GUILayout.Label(v.Name + " (" + v.Type.Name + ")", GUILayout.ExpandWidth(false)); if (!string.IsNullOrEmpty(v.Description)) { GUILayout.Label(v.Description); } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Box("", GUILayout.Width(300), GUILayout.Height(1)); EditorGUILayout.EndHorizontal(); TriggerGUILayout.DrawAddFilterSelector(Sender.gameObject, Context.Refresh); TriggerGUILayout.DrawAddActionSelector(Sender.gameObject, Context.Refresh); EditorGUILayout.Separator(); GUILayout.EndVertical(); EditorGUILayout.Separator(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } }
private static void RegisterTriggerMethod(MethodInfo method, ref List <Tuple <MethodInfo, bool> > triggersList, TriggerAttribute attribute) { var parameters = method.GetParameters(); if (parameters.Length == 0 || parameters.Length == 1 && parameters[0].ParameterType == typeof(NativeDll) || parameters.Length == 2 && parameters[0].ParameterType == typeof(NativeDll) && parameters[1].ParameterType == typeof(int)) { if (triggersList == null) { triggersList = new List <Tuple <MethodInfo, bool> >(); } triggersList.Add(new Tuple <MethodInfo, bool>(method, attribute.UseMainThreadQueue)); } else { Debug.LogError($"Trigger method must either take no parameters, one parameter of type {nameof(NativeDll)} or one of type {nameof(NativeDll)} and one int. " + $"See the TriggerAttribute for more details. Violation on method {method.Name} in {method.DeclaringType.FullName}"); } }
public static void SetTrigger(this Operation operation, SchemaRegistry schemaRegistry, TriggerAttribute triggerDescription) { operation.EnsureVendorExtensions(); string batchMode = null; switch (triggerDescription.Pattern) { case TriggerType.PollingBatched: batchMode = Constants.BATCH; break; case TriggerType.PollingSingle: batchMode = Constants.SINGLE; break; case TriggerType.Subscription: batchMode = Constants.SINGLE; operation.SetCallbackType(schemaRegistry, triggerDescription.DataType, triggerDescription.DataFriendlyName); break; default: break; } if (!operation.vendorExtensions.ContainsKey(Constants.X_MS_TRIGGER)) { operation.vendorExtensions.Add(Constants.X_MS_TRIGGER, batchMode.ToString().ToLowerInvariant()); } if (triggerDescription.Pattern == TriggerType.Subscription) { return; } var dataResponse = new Response() { description = triggerDescription.DataFriendlyName, schema = null != triggerDescription.DataType ? schemaRegistry.GetOrRegister(triggerDescription.DataType) : null }; var acceptedResponse = new Response() { description = Constants.ACCEPTED }; operation.responses[Constants.HAPPY_POLL_WITH_DATA_RESPONSE_CODE] = dataResponse; operation.responses[Constants.HAPPY_POLL_NO_DATA_RESPONSE_CODE] = acceptedResponse; }