public Action remove(Action action) { Action toRemove = action; //actions.Remove(action); actions.RemoveAll(x => x.GetType() == action.GetType()); return toRemove; }
protected override void CopyProperties(Action sourceAction) { if (sourceAction.GetType() == base.GetType()) { base.CopyProperties(sourceAction); ClassId = ((ComHandlerAction)sourceAction).ClassId; Data = ((ComHandlerAction)sourceAction).Data; } }
internal static CfAction FromAction(Action source) { if (source == null) { return null; } CfAction item = null; if (source.GetType() == typeof(Text)) { item = TextMapper.FromText((Text)source); } else if (source.GetType() == typeof(Call)) { item = CallMapper.FromCall((Call)source); } return item; }
public bool has(Action action) { //Console.WriteLine(action.GetType()); //Console.WriteLine("Num actions in has:" + actions.Count); if (actions.Count > 0) { for (int i = 0; i < actions.Count; i++) { Action curAction = actions.ElementAt(i); //Console.WriteLine(curAction.GetType()); if (curAction.GetType().Equals(action.GetType())) { //Console.WriteLine("this worked"); return true; } } return false; } else { return false; } }
public void addAction(Action a) { if (actions.Count > 0) { Action current = actions[0]; int pr = current.getPriority(); if (a.GetType() == typeof(Attack)) //remove all attack actions ( new is better) { actions.RemoveAll((x) => x.getPriority() == pr); // has same priority as currently playing } } actions.Add(a); sortActions(); }
/// <summary> /// Initializes the roles from the action attribute declaration. See <see cref="ActionRolesAttribute"/> /// for more information. /// </summary> /// <returns></returns> /// <exception cref="System.NotImplementedException"></exception> protected virtual List<string> InitializeRoles(Action action) { // retrieve default roles for action using declarative attributes; Type actionType = action.GetType(); { List<object> roleAttributes = new List<object>(actionType.GetCustomAttributes(typeof (ActionRolesAttribute), true)); if (roleAttributes.Count > 0) { foreach (object roleAttribute in roleAttributes) this.roles = ((ActionRolesAttribute)roleAttribute).Roles; } } return this.roles; }
public void Migrate(Action <IMigrationRunner> action) { _log.LogInformation($"Migrating {action.GetType().Name}"); action(_runner); }
private void DispatchAction(Action action) { action.Dispatch(_processor, _checkpointer); _iohandler.WriteAction(new StatusAction(action.GetType())); }
/// <summary> /// Copies the properties from another <see cref="Action" /> the current instance. /// </summary> /// <param name="sourceAction"> /// The source <see cref="Action" /> . /// </param> protected override void CopyProperties(Action sourceAction) { if (sourceAction.GetType() == GetType()) { base.CopyProperties(sourceAction); if (((EmailAction)sourceAction).Attachments != null) { Attachments = (object[])((EmailAction)sourceAction).Attachments.Clone(); } Bcc = ((EmailAction)sourceAction).Bcc; Body = ((EmailAction)sourceAction).Body; Cc = ((EmailAction)sourceAction).Cc; From = ((EmailAction)sourceAction).From; if (((EmailAction)sourceAction).nvc != null) { ((EmailAction)sourceAction).HeaderFields.CopyTo(HeaderFields); } ReplyTo = ((EmailAction)sourceAction).ReplyTo; Server = ((EmailAction)sourceAction).Server; Subject = ((EmailAction)sourceAction).Subject; To = ((EmailAction)sourceAction).To; } }
private static bool CheckType(Action<string> a) { return a.GetType() == typeof(Action<object>); }
/** * <summary>Gets the index of an Action within a list of all Actions that share it's category.</summary> * <param name = "_action">The Action to get the index of</param> * <returns>The index of the Action within a list of all Actions that share it's category</returns> */ public int GetActionSubCategory(Action _action) { string fileName = _action.GetType ().ToString ().Replace ("AC.", ""); ActionCategory _category = _action.category; // Learn category foreach (ActionType type in EnabledActions) { if (type.fileName == fileName) { _category = type.category; } } // Learn subcategory int i=0; foreach (ActionType type in EnabledActions) { if (type.category == _category) { if (type.fileName == fileName) { return i; } i++; } } ACDebug.LogWarning ("Error building Action " + _action); return 0; }
/// <summary> /// Determines whether this instance is type of the specified action. /// A test to see if this action is the same as another action. Remember /// that they don't have to have the same type to be of the same type. /// Consider the "Manage" action which covers ALL actions. /// </summary> /// <returns><c>true</c> if this instance is same as the specified action; otherwise, <c>false</c>.</returns> /// <param name="action">The action</param> public virtual bool IsTypeOf(Action action) { return this.GetType() == action.GetType(); }
private static bool IsCompatible <T>(Action <T> a1, Action <T> a2) => a1.GetType() == a2.GetType();
/// <summary> /// This unregisters a method as a handler for a specific type /// </summary> /// <param name="handler">Handler</param> public void UnregisterHandler <T>(Action <T> handler) { UnregisterHandler(typeof(Action <T>), handler.GetType(), handler); }
/// <summary> /// This unregisters a method as a handler. /// </summary> /// <param name="key">Message key</param> /// <param name="handler">Handler</param> public void UnregisterHandler <T>(string key, Action <T> handler) { UnregisterHandler(key, handler.GetType(), handler); }
private Delegate GetDelegate(EventInfo eventInfo, Action action) { if (typeof(EventHandler).IsAssignableFrom(eventInfo.EventHandlerType)) { MethodInfo method = this.GetType().GetMethod("OnEvent", BindingFlags.NonPublic | BindingFlags.Instance); return(Delegate.CreateDelegate(eventInfo.EventHandlerType, this, method)); } Type handlerType = eventInfo.EventHandlerType; ParameterInfo[] eventParams = handlerType.GetMethod("Invoke").GetParameters(); IEnumerable <ParameterExpression> parameters = eventParams.Select(p => System.Linq.Expressions.Expression.Parameter(p.ParameterType, "x")); MethodCallExpression methodExpression = System.Linq.Expressions.Expression.Call(System.Linq.Expressions.Expression.Constant(action), action.GetType().GetMethod("Invoke")); LambdaExpression lambdaExpression = System.Linq.Expressions.Expression.Lambda(methodExpression, parameters.ToArray()); return(Delegate.CreateDelegate(handlerType, lambdaExpression.Compile(), "Invoke", false)); }
/// <summary> /// Debug print method to format an action into a string /// </summary> /// <param name="action"> the action to format</param> /// <returns>the formatted string</returns> public static string prettyPrint(Action action) { string s = "" + action.GetType().Name; return(s); }
/** * <summary>Gets the index number of an Action within EnabledActions.</summary> * <param name = "_action">The Action to search for</param> * <returns>The index number of the Action within EnabledActions</returns> */ public int GetActionTypeIndex(Action _action) { string className = _action.GetType ().ToString (); className = className.Replace ("AC.", ""); foreach (ActionType actionType in EnabledActions) { if (actionType.fileName == className) { return EnabledActions.IndexOf (actionType); } } return defaultClass; }
public void SetAction( Action action, string mode) { string actionType = action.GetType().Name; string name; switch(mode) { case "enter": name = GetUniqueKey( actionType, _enter ); _enter.Add( name, action ); break; case "step": name = GetUniqueKey( actionType, _step ); _step.Add( name, action ); break; case "exit": name = GetUniqueKey( actionType, _exit ); _exit.Add( name, action ); break; case "finish": name = GetUniqueKey( actionType, _finish ); _finish.Add( name, action); break; } }
/// <summary> /// Copies the properties from another <see cref="Action" /> the current instance. /// </summary> /// <param name="sourceAction"> /// The source <see cref="Action" /> . /// </param> protected override void CopyProperties(Action sourceAction) { if (sourceAction.GetType() == GetType()) { base.CopyProperties(sourceAction); Path = ((ExecAction)sourceAction).Path; Arguments = ((ExecAction)sourceAction).Arguments; WorkingDirectory = ((ExecAction)sourceAction).WorkingDirectory; } }
public void Copy(Action action) { // copy all of the properties foreach (PropertyInfo pi in action.GetType().GetProperties()) { // get the value of the property var val = pi.GetValue(action, null); pi.SetValue(this, val, null); } }
/// <summary> /// Copies the properties from another <see cref="Action" /> the current instance. /// </summary> /// <param name="sourceAction"> /// The source <see cref="Action" /> . /// </param> protected override void CopyProperties(Action sourceAction) { if (sourceAction.GetType() == GetType()) { base.CopyProperties(sourceAction); Title = ((ShowMessageAction)sourceAction).Title; MessageBody = ((ShowMessageAction)sourceAction).MessageBody; } }
private void checkConsumed(int pos, int len, Action a) { int consumed = reader.Offset - pos; if (consumed != len) { throw new SwfFormatException(a.GetType().FullName + ": " + consumed + " was read. " + len + " was required."); } }
public void Copy(Action obj) { if (obj == null) return; // copy all of the properties foreach (PropertyInfo pi in obj.GetType().GetProperties()) { // get the value of the property var val = pi.GetValue(obj, null); pi.SetValue(this, val, null); } }
public override string ToString() { return(action.GetType().ToString() + "\n" + action.ToString()); }