本文整理汇总了C#中IAction类的典型用法代码示例。如果您正苦于以下问题:C# IAction类的具体用法?C# IAction怎么用?C# IAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAction类属于命名空间,在下文中一共展示了IAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAction
public void AddAction(IAction action)
{
lock (_actions)
{
_actions.Enqueue(action);
}
}
示例2: get
ActionInfo get(IAction action)
{
lock (lockObj)
{
return actionStore[ID].Actions.FirstOrDefault( a => a.Order == action.Order && a.IsLast);
}
}
示例3: GetDenyActions
private DenyResult[] GetDenyActions(ISubject subject, IAction[] actions, ISecurityObjectId objectId, ISecurityObjectProvider securityObjProvider)
{
var denyActions = new List<DenyResult>();
if (actions == null) actions = new IAction[0];
if (subject == null)
{
denyActions = actions.Select(a => new DenyResult(a, null, null)).ToList();
}
else if (subject is ISystemAccount && subject.ID == Constants.CoreSystem.ID)
{
// allow all
}
else
{
ISubject denySubject = null;
IAction denyAction = null;
foreach (var action in actions)
{
var allow = azManager.CheckPermission(subject, action, objectId, securityObjProvider, out denySubject, out denyAction);
if (!allow)
{
denyActions.Add(new DenyResult(action, denySubject, denyAction));
break;
}
}
}
return denyActions.ToArray();
}
示例4: FormatErrorMessage
internal static string FormatErrorMessage(ISubject subject, IAction[] actions, ISubject[] denySubjects,
IAction[] denyActions)
{
if (subject == null) throw new ArgumentNullException("subject");
if (actions == null || actions.Length == 0) throw new ArgumentNullException("actions");
if (denySubjects == null || denySubjects.Length == 0) throw new ArgumentNullException("denySubjects");
if (denyActions == null || denyActions.Length == 0) throw new ArgumentNullException("denyActions");
if (actions.Length != denySubjects.Length || actions.Length != denyActions.Length)
throw new ArgumentException();
string reasons = "";
for (int i = 0; i < actions.Length; i++)
{
string reason = "";
if (denySubjects[i] != null && denyActions[i] != null)
reason = String.Format("{0}:{1} access denied {2}.",
actions[i].Name,
(denySubjects[i] is IRole ? "role:" : "") + denySubjects[i].Name,
denyActions[i].Name
);
else
reason = String.Format("{0}: access denied.", actions[i].Name);
if (i != actions.Length - 1)
reason += ", ";
reasons += reason;
}
string sactions = "";
Array.ForEach(actions, action => { sactions += action.ToString() + ", "; });
string message = String.Format(
"\"{0}\" access denied \"{1}\". Cause: {2}.",
(subject is IRole ? "role:" : "") + subject.Name,
sactions,
reasons
);
return message;
}
示例5: SetTooltipText
/// <summary>
/// Sets the tooltip text on the specified item, from the specified action.
/// </summary>
/// <param name="item"></param>
/// <param name="action"></param>
internal static void SetTooltipText(ToolStripItem item, IAction action)
{
var actionTooltip = action.Tooltip;
if (string.IsNullOrEmpty(actionTooltip))
actionTooltip = (action.Label ?? string.Empty).Replace("&", "");
var clickAction = action as IClickAction;
if (clickAction == null || clickAction.KeyStroke == XKeys.None)
{
item.ToolTipText = actionTooltip;
return;
}
var keyCode = clickAction.KeyStroke & XKeys.KeyCode;
var builder = new StringBuilder();
builder.Append(actionTooltip);
if (keyCode != XKeys.None)
{
if (builder.Length > 0)
builder.AppendLine();
builder.AppendFormat("{0}: ", SR.LabelKeyboardShortcut);
builder.Append(XKeysConverter.Format(clickAction.KeyStroke));
}
item.ToolTipText = builder.ToString();
}
示例6: Add
public void Add(IAction action)
{
if(action.GetType() == typeof(SelectionAction) && firstSelectionAction == null)
firstSelectionAction = (SelectionAction)action;
else if (action.GetType() == typeof(BiomeAction) && firstBiomeAction == null)
firstBiomeAction = (BiomeAction)action;
else if (action.GetType() == typeof(PopulateAction) && firstPopulateAction == null)
firstPopulateAction = (PopulateAction)action;
//ensure the first action of each type isn't lost when the redo stack is emptied
if(firstSelectionAction != null && action != firstSelectionAction && redoStack.Contains(firstSelectionAction))
{
redoStack.Remove(firstSelectionAction);
undoStack.AddLast(firstSelectionAction);
}
if (firstBiomeAction != null && action != firstBiomeAction && redoStack.Contains(firstBiomeAction))
{
redoStack.Remove(firstBiomeAction);
undoStack.AddLast(firstBiomeAction);
}
if (firstPopulateAction != null && action != firstPopulateAction && redoStack.Contains(firstPopulateAction))
{
redoStack.Remove(firstPopulateAction);
undoStack.AddLast(firstPopulateAction);
}
action.PreviousAction = GetPreviousAction(undoStack.Last, action.GetType());
undoStack.AddLast(action);
foreach (IAction a in redoStack)
a.Dispose();
redoStack.Clear();
}
示例7: Execute
public override IActionResult Execute(object pSouce, IAction pAction)
{
if (pAction is LoadAction)
{
return ExecuteToChildren(new LoadAction(this));
}
var startReadAction = pAction as StartReadAction;
if (startReadAction != null)
{
return StartRead(startReadAction);
}
var selectItemAction = pAction as SelectItemAction;
if (selectItemAction != null)
{
try
{
SelectItem(selectItemAction);
}
catch (InvalidOperationException ex)
{
//TODO: manage exception: log it and show any information to the user?
SelectedChapter = null;
}
}
var startReadSelectedChapterAction = pAction as StartReadSelectedChapterAction;
if (startReadSelectedChapterAction != null)
{
return StartReadSelectedChapter(startReadSelectedChapterAction);
}
return base.Execute(pSouce, pAction);
}
示例8: Execute
public TimeMachineState Execute(TimeMachineState previousState, IAction action)
{
if(action is ResumeTimeMachineAction)
{
return previousState
.WithIsPaused(false)
.WithStates(previousState.States.Take(previousState.Position + 1).ToImmutableList())
.WithActions(previousState.Actions.Take(previousState.Position).ToImmutableList());
}
if(action is PauseTimeMachineAction)
{
return previousState
.WithIsPaused(true);
}
if(action is SetTimeMachinePositionAction)
{
return previousState
.WithPosition(((SetTimeMachinePositionAction)action).Position)
.WithIsPaused(true);
}
if (previousState.IsPaused)
{
return previousState;
}
var innerState = _reducer(previousState.States.Last(), action);
return previousState
.WithStates(previousState.States.Add(innerState))
.WithActions(previousState.Actions.Add(action))
.WithPosition(previousState.Position + 1);
}
示例9: Add
public void Add(IAction action, string tag = "")
{
if (!m_actions.ContainsKey (tag))
m_actions [tag] = new Queue<IAction> ();
m_actions[tag].Enqueue(action);
}
示例10: Append
public void Append (IAction action)
{
if (action == null)
throw new ArgumentNullException ("action");
actions.Add (action);
}
示例11: WithActionIfConditionsNotFulfilled
public Automation WithActionIfConditionsNotFulfilled(IAction action)
{
if (action == null) throw new ArgumentNullException(nameof(action));
ActionsIfNotFulfilled.Add(action);
return this;
}
示例12: AddAction
public void AddAction(IAction action)
{
string ID = action.ID;
System.Windows.Forms.MenuItem menuItem = new System.Windows.Forms.MenuItem(ID);
menuItem.Click += new System.EventHandler(this.MainWindow_ActionSelect);
menuItem.Tag = action;
System.Windows.Forms.MenuItem menuMain = this.menuItemActions;
if (menuMain == null)
{
LoggerFactory.Default.Log("Could not register IAction in IDE", action.EffectiveID);
return;
};
string category = action.Category;
if ((category == "") || (category == null))
{ menuMain.MenuItems.Add(menuItem); }
else
{
System.Windows.Forms.MenuItem categoryItem = findCategoryMenu(menuMain, category);
if (categoryItem == null)
{
categoryItem = new System.Windows.Forms.MenuItem(category);
menuMain.MenuItems.Add(categoryItem);
}
addSortedActionInCategory(categoryItem, menuItem);
}
}
示例13: ChoosePluginForAction
public IPlugin ChoosePluginForAction(IAction action)
{
var capable = Plugins.Where(plugin => plugin.CanHandle(action));
// pretty dumb selection logic for now, pass in ranking preferences later
return capable.FirstOrDefault();
}
示例14: ExecuteToChildren
public static IEnumerable<IActionResult> ExecuteToChildren(
IManager pManager,
IAction pAction,
bool pCheckSource)
{
ArgumentsValidation.NotNull(pManager, "pManager");
ArgumentsValidation.NotNull(pAction, "pAction");
var result = new List<IActionResult>();
var children = pManager.GetChildren();
if (children != null)
{
var checkedChildren = children.Where(x => !pCheckSource || !ReferenceEquals(x, pAction.GetSource()));
foreach (var child in checkedChildren)
{
var r = child.Execute(pManager, pAction);
if (r == null || r is NotAvailableActionResult)
{
continue;
}
result.Add(r);
}
}
return new ReadOnlyCollection<IActionResult>(result);
}
示例15: OnProcess
protected override void OnProcess(IAction action)
{
base.OnProcess(action);
HtmlElement element = this.GetData(action) as HtmlElement;
if (element == null)
{
LoggerManager.Error("Element Not Found");
throw new ElementNoFoundException("Element Not Found", action);
}
LoggerManager.Debug(action.AutomationActionData);
ClickAction clickAction = action as ClickAction;
if (clickAction == null)
{
return;
}
if (clickAction.Click)
{
LoggerManager.Debug("Trigger Click");
this.Call<HtmlElement>(Click, element);
}
if (clickAction.ClickNew)
{
LoggerManager.Debug("Trigger ClickNew");
this.Call<HtmlElement>(ClickNew, element);
}
if (clickAction.MouseClick)
{
LoggerManager.Debug("Trigger MouseClick");
this.Call<HtmlElement>(MouseClick, element);
}
}