コード例 #1
0
ファイル: Helper.cs プロジェクト: noant/Pyrite
 public static Result<string> SafeExecute(ICustomAction action)
 {
     var result = new Result<string>();
     try
     {
         result.Value = action.Do(action.State);
     }
     catch (Exception e)
     {
         result.AddException(e);
     }
     return result;
 }
コード例 #2
0
ファイル: ModulesControl.cs プロジェクト: noant/Pyrite
 public Result<IEnumerable<Scenario>> RemoveChecker(Type checkerType)
 {
     var result = new Result<IEnumerable<Scenario>>();
     var scenariosWasEdited = new List<Scenario>();
     try
     {
         lock (Pyrite.ScenariosPool.Scenarios)
         {
             var assemblyName = checkerType.Assembly.FullName;
             _customCheckers.RemoveAll(x => x.Assembly.FullName == assemblyName);
             foreach (var action in Pyrite.ScenariosPool.Scenarios)
                 if (action.Action is IHasCheckerAction)
                     if (((IHasCheckerAction)action.Action).RemoveChecker(checkerType))
                         scenariosWasEdited.Add(action);
         }
     }
     catch (Exception e)
     {
         result.AddException(e);
     }
     result.Value = scenariosWasEdited;
     return result;
 }
コード例 #3
0
ファイル: ModulesControl.cs プロジェクト: noant/Pyrite
 public Result<IEnumerable<Scenario>> RemoveAction(Type actionType)
 {
     var result = new Result<IEnumerable<Scenario>>();
     var scenariosWasEdited = new List<Scenario>();
     try
     {
         lock (Pyrite.ScenariosPool.Scenarios)
         {
             var assemblyName = actionType.Assembly.FullName;
             _customActions.RemoveAll(x => x.Assembly.FullName == assemblyName);
             foreach (var action in Pyrite.ScenariosPool.Scenarios.ToArray())
             {
                 if (action.Action is IHasCheckerAction)
                 {
                     if (((IHasCheckerAction)action.Action).RemoveAction(actionType))
                         scenariosWasEdited.Add(action);
                 }
                 else if (action.Action.GetType().Equals(actionType))
                 {
                     Pyrite.ScenariosPool.RemoveScenario(action);
                 }
             }
         }
     }
     catch (Exception e)
     {
         result.AddException(e);
     }
     result.Value = scenariosWasEdited;
     return result;
 }
コード例 #4
0
ファイル: ModulesControl.cs プロジェクト: noant/Pyrite
 public Result<string> GetViewName(Type type)
 {
     var result = new Result<string>();
     try
     {
         result.Value = type.GetProperty("Name").GetValue(type.GetConstructor(new Type[0]).Invoke(new object[0])).ToString();
     }
     catch (Exception e)
     {
         result.AddException(e);
     }
     return result;
 }