本文整理汇总了C#中IAction.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IAction.GetType方法的具体用法?C# IAction.GetType怎么用?C# IAction.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAction
的用法示例。
在下文中一共展示了IAction.GetType方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: SetProperties
public static void SetProperties(IAction action)
{
foreach (PropertyInfo pi in action.GetType().GetProperties())
{
object[] propertyAttributes = pi.GetCustomAttributes(typeof(ActionPropertyAttribute), false);
if (propertyAttributes.Length == 1)
{
if (action.Fields.ContainsKey(pi.Name))
{
pi.SetValue(action, Convert.ChangeType(ValueStringEvaluator.Evaluate(action.Fields[pi.Name],
action.ParentBuildFile), pi.PropertyType), null);
action.Fields.Remove(pi.Name);
}
else
{
ActionPropertyAttribute apa = (ActionPropertyAttribute)propertyAttributes[0];
if (apa.IsRequired)
throw new ActionPropertyNotSetException(action, pi, "The value for a required property was not set.");
}
}
}
EvaluateFields(action);
}
示例3: CanHandle
public bool CanHandle(IAction action)
{
// @todo & typeof is IHandler
var interfaces = GetType().GetInterfaces();
var candidates = interfaces.Where(x => x.IsConstructedGenericType
&& x.GetGenericArguments()[0] == action.GetType());
return candidates.Any();
}
示例4: log
bool log(IAction action, bool completed, bool reversed, Exception ex)
{
var info = new ActionInfo
{
ID = ID,
BID = BID,
Order = action.Order,
Data = action.GetData().Serialize(),
Result = action.GetResult().Serialize(),
Action = action.GetType().Name,
Exception = ex.Serialize(),
Completed = (ex== null) && completed,
Reversed = (ex == null) && reversed,
VersionTime = DateTime.Now,
IsLast = true
};
lock (lockObj)
{
actionStore[ID].Actions.Add(info);
}
return true;
}
示例5: CreateActionView
private static IActionView CreateActionView(ToolStripKind kind, IAction action, IconSize iconSize)
{
IActionView view = null;
// optimization: for framework-provided actions, we can just create the controls
// directly rather than use the associated view, which is slower;
// however, an AssociateViewAttribute should always take precedence.
if (action.GetType().GetCustomAttributes(typeof(AssociateViewAttribute), true).Length == 0)
{
if (kind == ToolStripKind.Toolbar)
{
if (action is IDropDownAction)
{
if (action is IClickAction)
view = StandardWinFormsActionView.CreateDropDownButtonActionView();
else
view = StandardWinFormsActionView.CreateDropDownActionView();
}
else if(action is ITextBoxAction)
view = StandardWinFormsActionView.CreateTextBoxActionView();
else if (action is IClickAction)
view = StandardWinFormsActionView.CreateButtonActionView();
}
else
{
if (action is IClickAction)
view = StandardWinFormsActionView.CreateMenuActionView();
}
}
if (view == null)
view = (IActionView)ViewFactory.CreateAssociatedView(action.GetType());
view.Context = new ActionViewContext(action, iconSize);
return view;
}
示例6: Do
/*
* isCanUndo attribute specifies whether the action can be undo.
* sometimes an action doesn't need undo even it's a IUndoable action.
* the action will not be pushed in undo stack after performed immediately.
*/
private void Do(IAction action, bool perform, bool isCanUndo)
{
Logger.Log(LOGKEY, string.Format("{0} action: {1}[{2}]", perform ? "do" : "add", action.GetType().Name, action.GetName()));
if (BeforePerformAction != null)
{
var arg = new ActionEventArgs(action, ActionBehavior.Do);
BeforePerformAction(this, arg);
if (arg.Cancel) return;
}
if (perform) action.Do();
if (action is IUndoableAction && isCanUndo)
{
redoStack.Clear();
undoStack.Add(action as IUndoableAction);
if(undoStack.Count() > capacity)
{
undoStack.RemoveRange(0, undoStack.Count() - capacity);
Logger.Log(LOGKEY, "action stack full. remove " + (capacity - undoStack.Count()) + " action(s).");
}
}
if (AfterPerformAction != null) AfterPerformAction(this, new ActionEventArgs(action, ActionBehavior.Do));
}
示例7: Bind
internal virtual void Bind(ITaskDefinition iTaskDef) {
var iActions = iTaskDef.Actions;
switch (GetType().Name) {
case "ComHandlerAction":
iAction = iActions.Create(TaskActionType.ComHandler);
break;
case "ExecAction":
iAction = iActions.Create(TaskActionType.Execute);
break;
case "EmailAction":
iAction = iActions.Create(TaskActionType.SendEmail);
break;
case "ShowMessageAction":
iAction = iActions.Create(TaskActionType.ShowMessage);
break;
default:
throw new ArgumentException();
}
Marshal.ReleaseComObject(iActions);
foreach (var key in unboundValues.Keys) {
try {
iAction.GetType().InvokeMember(key, BindingFlags.SetProperty, null, iAction, new[] {
unboundValues[key]
});
} catch (TargetInvocationException tie) {
throw tie.InnerException;
} catch {
}
}
unboundValues.Clear();
}
示例8: SetAction
/// <summary>
/// Populate the IResourceAction with the IAction
/// </summary>
/// <param name="action">The action being used to populate the ResourceAction</param>
public void SetAction(IAction action)
{
m_supportsMime = false;
m_supportsContainers = false;
if (string.IsNullOrEmpty(action.Name))
m_name = "Action_" + Guid.NewGuid().ToString();
else
m_name = action.Name;
List<RunAt> executionTargets = new List<RunAt>(action.Runat);
m_runAtCapabilities = executionTargets.ToArray();
m_runAtSetting = executionTargets.ToArray();
List<ChannelType> supportedChannels = new List<ChannelType>(action.SupportedChannels);
m_SupportedFileCollectionCapabilities = SupportedFileSet.CreateFileCollection("");
m_SupportedFileCollectionSetting = SupportedFileSet.CreateFileCollection("");
if (action.SupportedFileCollection.IsNonSupportedCollection)
{
m_SupportedFileCollectionCapabilities.AddSupportFor(".*");
m_SupportedFileCollectionSetting.AddSupportFor(".*");
}
foreach (string s in action.SupportedFileCollection)
{
if (action.SupportedFileCollection.IsNonSupportedCollection)
{
m_SupportedFileCollectionCapabilities.RemoveSupportFor(s);
m_SupportedFileCollectionSetting.RemoveSupportFor(s);
}
else
{
m_SupportedFileCollectionSetting.AddSupportFor(s);
m_SupportedFileCollectionCapabilities.AddSupportFor(s);
if (s == ".email")
m_supportsMime = true;
if (s == ".fld")
m_supportsContainers = true;
}
}
List<PolicyType> policyTypes = new List<PolicyType>();
foreach (ChannelType channel in supportedChannels)
{
PolicyType p = ChannelTypeMappings.Lookup[channel];
policyTypes.Add(p);
}
this.SupportedPolicySetting = policyTypes.ToArray();
m_isExplicit = false;
m_languageSupport = action.LanguageSupport;
m_canCoexist = !action.GetType().FullName.StartsWith("Workshare.Policy.Actions.BlockUserAction");
m_template = false;
m_blocking = false; //block action has been migrated
}
示例9: ActionObject
/// <summary>
/// </summary>
public ActionObject(IAction obj, string name)
{
m_Object = obj;
m_Name = name;
m_Type = obj.GetType().FullName;
}
示例10: SetActionInputPropertyValues
private static void SetActionInputPropertyValues(ActionInfo actionDefinition, IAction action, Dictionary<string, object> propertyCache)
{
foreach (var property in actionDefinition.InputProperties)
{
var propertyInfo = GetSetPropertyInfo(action.GetType(), property.Name, actionDefinition.Id);
object expandedValue;
try
{
expandedValue = ExpandMacros(property.Value, propertyCache);
}
catch (Exception e)
{
var message = string.Format("Can't expand macros for property '{0}' in action '{1}'. {2}", property.Name, actionDefinition.Id, e.Message);
throw new InvalidDataException(message, e);
}
if (!propertyInfo.PropertyType.IsInstanceOfType(expandedValue))
{
expandedValue = Convert.ChangeType(expandedValue, propertyInfo.PropertyType);
}
propertyInfo.SetValue(action, expandedValue);
}
}
示例11: GetActionOutputPropertyValues
private static void GetActionOutputPropertyValues(ActionInfo actionDefinition, IAction action, Dictionary<string, object> propertyCache)
{
foreach (var outPropertyRow in actionDefinition.OutputProperties)
{
var propertyName = outPropertyRow.Name;
var propertyInfo = GetGetPropertyInfo(action.GetType(), propertyName, actionDefinition.Id);
var propertyValue = propertyInfo.GetValue(action);
propertyCache.Add(GetPropertyMacroName(actionDefinition.Id, propertyName), propertyValue);
}
}
示例12: HasHttpMethod
private static bool HasHttpMethod(IAction action, HttpVerbs httpVerb) {
return action.GetType().GetMethods().ToList().Find(
x => x.Name.ToLowerInvariant() == Enum.GetName(typeof(HttpVerbs), httpVerb).ToLowerInvariant()) != null;
}
示例13: GetMethod
private static MethodInfo GetMethod(IAction action, HttpVerbs httpVerb) {
return action.GetType().GetMethods().ToList().Find(
x => x.Name.ToUpperInvariant() == Enum.GetName(typeof(HttpVerbs), httpVerb));
}