public RuleActivationState GetActivationState(IRuleContext context, IRule rule){
     if (AlwaysPassive.Contains(rule.Module())){
         return RuleActivationState.Never();
     }
     if (AlwaysActive.Contains(rule.Module())){
         return RuleActivationState.Always();
     }
     var modules = context.modules();
     if (null == modules){
         if (rule.Module() == "default"){
             return RuleActivationState.Always();
         }
         else{
             return RuleActivationState.Never();
         }
     }
     else{
         if (modules.IsActive(rule.Module())){
             return RuleActivationState.ActiveVersion(GetVersion(context));
         }
         else{
             return RuleActivationState.PassiveVersion(GetVersion(context));
         }
     }
 }
 protected override void innerInitContext(IRuleContext context){
     IModuleService s = context.modules();
     if (null == s && context is IWithServices){
         ModuleService service = new ModuleService();
         ((IWithServices) context).Services.RegisterService<IModuleService>(service);
     }
     base.innerInitContext(context);
 }
 public int GetVersion(IRuleContext context){
     var modules = context.modules();
     if (null == modules){
         return -1;
     }
     else{
         return modules.Version;
     }
 }
 protected override bool preTest(IRuleContext context, out bool result){
     result = true;
     if (Modules.Count == 0){
         result = false;
     }
     bool hasdifferent = false;
     foreach (string s in Modules){
         IModuleService ms = context.modules();
         if (IsActivator != ms.IsActive(s)){
             hasdifferent = true;
             break;
         }
     }
     if (!hasdifferent){
         result = false;
     }
     if (!result){
         return false;
     }
     return base.preTest(context, out result);
 }
 protected override void innerExecute(IRuleContext context){
     foreach (string module in Modules){
         IModuleService ms = context.modules();
         ms.ChangeActivation(module, IsActivator);
     }
 }