Example #1
0
        public bool Validate(string propertyName, IRuleSet ruleSet)
        {
            if(string.IsNullOrEmpty(propertyName))
            {
                return true;
            }

            if(ruleSet == null)
            {
                Errors[propertyName] = new List<IActionableErrorInfo>();
            }
            else
            {
                var errorsTos = ruleSet.ValidateRules();
                Errors[propertyName] = errorsTos;
            }

            // ReSharper disable ExplicitCallerInfoArgument
            OnPropertyChanged("Errors");
            // ReSharper restore ExplicitCallerInfoArgument

            List<IActionableErrorInfo> errorList;
            if(Errors.TryGetValue(propertyName, out errorList))
            {
                return errorList.Count == 0;
            }
            return false;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PipelineArgument"/> class.
 /// </summary>
 public PipelineArgument(IReadOnlyDictionary<string, string> propertyBag, IDocument document, IRuleSet rules, IPipelineMember successor)
 {
     PropertyBag = propertyBag;
     Document = document;
     Rules = rules;
     Successor = successor;
 }
 public ConsistencyCheckerDefaultConfigurationProvider(IRuleSet ruleSet)
 {
     if (ruleSet == null)
     {
         throw new ArgumentNullException(nameof(ruleSet));
     }
     m_RuleSet = ruleSet;
 }
Example #4
0
        public void Load_FilterRuleByTag_MatchingRule()
        {
            //Arrange
            RuleRepository target = CreateTarget();

            //Act
            target.Load(x => x
                        .NestedTypes()
                        .From(ThisAssembly)
                        .Where(r => r.IsTagged("LoadTest")));
            IRuleSet ruleSet = target.GetRuleSets().First();

            //Assert
            Assert.Single(ruleSet.Rules);
            Assert.Equal("Rule with metadata", ruleSet.Rules.First().Name);
        }
Example #5
0
        public void Load_AssemblyWithRulesToNamedRuleSet_RuleSetNameMatches()
        {
            //Arrange
            RuleRepository target = CreateTarget();

            //Act
            target.Load(x => x
                        .NestedTypes()
                        .From(ThisAssembly)
                        .Where(r => r.RuleType == typeof(ValidRule))
                        .To("Test"));
            IRuleSet ruleSet = target.GetRuleSets().First();

            //Assert
            Assert.AreEqual("Test", ruleSet.Name);
        }
Example #6
0
        public void Load_FilterRuleByName_MatchingRule()
        {
            //Arrange
            RuleRepository target = CreateTarget();

            //Act
            target.Load(x => x
                        .NestedTypes()
                        .From(ThisAssembly)
                        .Where(r => r.Name.Contains("Valid")));
            IRuleSet ruleSet = target.GetRuleSets().First();

            //Assert
            Assert.Single(ruleSet.Rules);
            Assert.Equal(typeof(ValidRule).FullName, ruleSet.Rules.First().Name);
        }
Example #7
0
        public static GrammarParseResult Evaluate(string text, IRuleSet ruleSet)
        {
            if (String.IsNullOrEmpty(text?.Trim()))
            {
                return(GrammarParseResult.Unsuccessful(text));
            }
            AntlrInputStream  inputStream       = new AntlrInputStream(text);
            GrammarLexer      grammarLexer      = new GrammarLexer(inputStream);
            CommonTokenStream commonTokenStream = new CommonTokenStream(grammarLexer);
            GrammarParser     grammarParser     = new GrammarParser(commonTokenStream);

            GrammarParser.StatementsContext context = grammarParser.statements();
            StatementsVisitor  visitor = new StatementsVisitor(ruleSet);
            GrammarParseResult result  = visitor.Visit(context);

            return(result);
        }
Example #8
0
        public MusicFileCop(IFileSystemLoader fileSystemLoader, IConfigurationLoader configurationLoader,
                            IMetadataLoader metadataLoader, IConsistencyChecker consistencyChecker,
                            IDefaultConfigurationNode defaultConfiguration, IConfigurationWriter configWriter, ITextOutputWriter outputWriter, IRuleSet ruleSet)
        {
            if (fileSystemLoader == null)
            {
                throw new ArgumentNullException(nameof(fileSystemLoader));
            }
            if (configurationLoader == null)
            {
                throw new ArgumentNullException(nameof(configurationLoader));
            }
            if (metadataLoader == null)
            {
                throw new ArgumentNullException(nameof(metadataLoader));
            }
            if (consistencyChecker == null)
            {
                throw new ArgumentNullException(nameof(consistencyChecker));
            }
            if (defaultConfiguration == null)
            {
                throw new ArgumentNullException(nameof(defaultConfiguration));
            }
            if (configWriter == null)
            {
                throw new ArgumentNullException(nameof(configWriter));
            }
            if (outputWriter == null)
            {
                throw new ArgumentNullException(nameof(outputWriter));
            }
            if (ruleSet == null)
            {
                throw new ArgumentNullException(nameof(ruleSet));
            }

            this.m_FileSystemLoader     = fileSystemLoader;
            this.m_ConfigLoader         = configurationLoader;
            this.m_MetadataLoader       = metadataLoader;
            this.m_ConsistencyChecker   = consistencyChecker;
            this.m_DefaultConfiguration = defaultConfiguration;
            m_ConfigWriter = configWriter;
            m_OutputWriter = outputWriter;
            m_RuleSet      = ruleSet;
        }
Example #9
0
        public async Task <SaveResponse <IRuleSet> > SaveAsync(IRuleSet ruleSet)
        {
            var saveResponse = new SaveResponse <IRuleSet>();

            try
            {
                saveResponse = await _ruleSetRepository.SaveAsync(ruleSet);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                saveResponse.AddError(ex);
                _logManager.LogError(ex, "Error saving ruleSet");
            }

            return(saveResponse);
        }
        protected bool RuleSetContainsRule(IRuleSet ruleset, Type type)
        {
            foreach (IRule rule in ruleset.Rules())
            {
                if (rule.GetType() == type)
                {
                    return(true);
                }

                if (rule is IRuleSet)
                {
                    if (RuleSetContainsRule(ruleset, type))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
            /// <summary>
            /// Aggregates the specified rule set by prioritizing the individual requests of rules.
            /// </summary>
            /// <param name="ruleSet">The rule set.</param>
            /// <param name="logInfo">The log info. The aggregator should provide information about the results of the different rules and how they
            /// influenced the overall result. This info is written to the log by the rule engine.</param>
            /// <returns>
            /// The aggregated result of all rules taking part in the evaluation.
            /// </returns>
            public MaintenanceRequired Aggregate(IRuleSet <IRule <MaintenenaceRequest?> > ruleSet, out string logInfo)
            {
                MaintenanceRequired?required = null;

                StringBuilder sb = new StringBuilder();

                foreach (IRule <MaintenenaceRequest?> rule in ruleSet)
                {
                    MaintenenaceRequest?request = rule.Evaluate();

                    sb.AppendFormat("Rule {0} returned {1}, ", rule, request);

                    if (request.HasValue)
                    {
                        switch (request)
                        {
                        case MaintenenaceRequest.Daily:

                            required = MaintenanceRequired.Daily;
                            break;

                        case MaintenenaceRequest.Weekly:
                            sb.AppendFormat("Weekly maintenance required, no more rules are evaluated.");
                            logInfo = sb.ToString();
                            return(MaintenanceRequired.Weekly);
                        }
                    }
                }

                if (required == MaintenanceRequired.Daily)
                {
                    sb.AppendFormat("Daily maintenance required.");
                    logInfo = sb.ToString();
                    return(MaintenanceRequired.Daily);
                }

                sb.AppendFormat("No maintenance required.");
                logInfo = sb.ToString();
                return(MaintenanceRequired.None);
            }
Example #12
0
        /// <summary>
        /// Builds summary string from constituent parts
        /// </summary>
        /// <param name="ruleSet"><c>IRuleSet</c> will determine what rules are to be applied to the flight</param>
        private string BuildSummaryString(IRuleSet ruleSet)
        {
            StringBuilder result = new StringBuilder();

            if (Passengers.Count > Aircraft.NumberOfSeats)
            {
                OtherAircraft(ref result);

                return(result.ToString());
            }

            result.Append("Flight summary for ");
            result.Append(FlightRoute.Title);

            AddVerticalWhiteSpace(ref result);

            AddPassengersDetails(ref result);

            AddVerticalWhiteSpace(ref result);

            AddCostInfo(ref result);

            AddVerticalWhiteSpace(ref result);

            AddLoyaltyInfo(ref result);

            AddVerticalWhiteSpace(ref result);

            if (ruleSet.CanProceed())
            {
                result.Append("THIS FLIGHT MAY PROCEED");
            }
            else
            {
                result.Append("FLIGHT MAY NOT PROCEED");
            }
            return(result.ToString());
        }
Example #13
0
        public GetResponse <IRuleSet> CreateAssembly(IRuleSet ruleSet, bool forTesting = false)
        {
            var response = new GetResponse <IRuleSet>();

            try
            {
                // 1. Translate the code
                ruleSet.Code = _ruleSetTranslator.Translate(ruleSet, forTesting);

                // 2. Create the assembly
                ruleSet.GeneratedAssembly = _ruleAssemblyService.CreateAssembly(ruleSet);

                response.Content = ruleSet;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                response.AddError(ex);
                _logManager.LogError(ex, "RuleApplicationService.CreateAssembly");
            }

            return(response);
        }
Example #14
0
        public byte[] CreateAssembly(IRuleSet ruleSet)
        {
            var syntaxTree = CSharpSyntaxTree.ParseText(ruleSet.Code);

            var assemblyName = ruleSet.Name;
            var references   = GetReferences();

            var compilation = CSharpCompilation.Create(
                assemblyName,
                syntaxTrees: new [] { syntaxTree },
                references: references,
                options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));



            using (var ms = new MemoryStream())
            {
                var result = compilation.Emit(ms);

                if (result.Success)
                {
                    ms.Seek(0, SeekOrigin.Begin);
                    return(ms.ToArray());
                }

                var failures = result.Diagnostics.Where(diagnostic =>
                                                        diagnostic.IsWarningAsError ||
                                                        diagnostic.Severity == DiagnosticSeverity.Error);

                foreach (var diagnostic in failures)
                {
                    _logManager.LogError(new Exception(diagnostic.GetMessage()), "RuleSetAssemblyService.CreateAssembly");
                }

                return(null);
            }
        }
        /// <summary>
        /// Aggregates the specified rule set.
        /// The result is valid if all rules are valid and it contains all violations of all rules.
        /// </summary>
        /// <param name="ruleSet">The rule set.</param>
        /// <param name="logInfo">The log info. The aggregator should provide information about the results of the different rules and how they
        /// influenced the overall result. This info is written to the log by the rule engine.</param>
        /// <returns>
        /// The aggregated result of all rules taking part in the evaluation.
        /// </returns>
        public IValidationResult Aggregate(IRuleSet <IValidationRule> ruleSet, out string logInfo)
        {
            StringBuilder sb = new StringBuilder();

            IValidationResult aggregatedResults = this.validationFactory.CreateValidationResult(true);

            foreach (IValidationRule rule in ruleSet)
            {
                IValidationResult result = rule.Evaluate();

                aggregatedResults.Valid &= result.Valid;

                if (!result.Valid && result.Violations != null && result.Violations.Count > 0)
                {
                    log.WarnFormat("Rule '{0}' was valid but returned violations '{1}'.", rule, FormatHelper.ConvertToString(result.Violations, ", "));
                }

                if (result.Violations != null)
                {
                    foreach (IValidationViolation validationViolation in result.Violations)
                    {
                        aggregatedResults.Violations.Add(validationViolation);
                    }
                }

                sb.AppendFormat("Rule '{0}' returned '{1}' with violations '{2}'. ", rule, result.Valid, FormatHelper.ConvertToString(result.Violations, ", "));

                if (!result.Valid && this.breakOnFirstViolation)
                {
                    sb.Append("Rule validation was stopped after first violation. ");
                    break;
                }
            }

            logInfo = sb.ToString();
            return(aggregatedResults);
        }
Example #16
0
        /// <summary>
        /// ルールチェックを実行する。
        /// </summary>
        public static ValidationResult[] Validate(IRuleSet ruleSet, string baseFolder, bool forceOpenScene = false)
        {
            var rules = ruleSet.GetRules();
            ValidationTarget target;
            var results = new List <ValidationResult>();

            try
            {
                target = ruleSet.TargetFinder.Find(baseFolder, forceOpenScene);
                RegisterUndo(target);
            }
            catch (FatalValidationErrorException e)
            {
                Debug.LogError(e.Message);
                var result = new ValidationResult("検証対象の検索");
                result.AddIssue(new Issue(null, IssueLevel.Fatal, e.Message));
                results.Add(result);
                return(results.ToArray());
            }
            foreach (var rule in rules)
            {
                try
                {
                    ValidationResult result = rule.Validate(target);
                    results.Add(result);
                }
                catch (FatalValidationErrorException e)
                {
                    Debug.LogError("ルールチェックを中断しました:" + e.Message);
                    results.Add(rule.GetResult());
                    break;
                }
            }
            Undo.RevertAllInCurrentGroup();
            return(results.ToArray());
        }
Example #17
0
        public string Translate(IRuleSet ruleSet, bool forTesting = false)
        {
            var rules     = forTesting ? ruleSet.Rules : ruleSet.Rules.Where(r => r.IsPublished);
            var className = GetClassName(ruleSet);

            // Create class based on rule set name
            var code = $@"{GetUsingStatements()}
                    namespace {Constants.RuleNamespace}
                    {{
                        public class {className}
                        {{
                            private readonly Dictionary<string, Func<IToken, Exception>> _actions;

                            public {className}(Dictionary<string, Func<IToken, Exception>> actions)
                            {{
                                _actions = actions;
                            }}

                            {GetMethods(rules)}
                        }}
                    }}";

            return(code);
        }
Example #18
0
        public bool Validate(string propertyName, IRuleSet ruleSet)
        {
            if (ruleSet == null)
            {
                Errors[propertyName] = new List <IActionableErrorInfo>();
            }
            else
            {
                var errorsTos            = ruleSet.ValidateRules();
                var actionableErrorInfos = errorsTos.ConvertAll <IActionableErrorInfo>(input => new ActionableErrorInfo(input, () =>
                {
                    //
                }));
                Errors[propertyName] = actionableErrorInfos;
            }
            OnPropertyChanged("Errors");
            List <IActionableErrorInfo> errorList;

            if (Errors.TryGetValue(propertyName, out errorList))
            {
                return(errorList.Count == 0);
            }
            return(false);
        }
Example #19
0
        public ConsistencyChecker(IMetadataMapper fileMetadataMapper, IKernel kernel, IConfigurationMapper configurationMapper, IRuleSet ruleSet)
        {
            if (fileMetadataMapper == null)
            {
                throw new ArgumentNullException(nameof(fileMetadataMapper));
            }
            if (kernel == null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }
            if (configurationMapper == null)
            {
                throw new ArgumentNullException(nameof(configurationMapper));
            }
            if (ruleSet == null)
            {
                throw new ArgumentNullException(nameof(ruleSet));
            }

            m_MetadataMapper      = fileMetadataMapper;
            m_Kernel              = kernel;
            m_ConfigurationMapper = configurationMapper;
            m_RuleSet             = ruleSet;
        }
Example #20
0
 public BruteForceCracker(IRuleSet ruleSet)
 {
     _ruleSet = ruleSet;
 }
Example #21
0
		/// <summary>
		/// Initializes a new instance of the <see cref="EpicsGateWay"/> class.
		/// </summary>
		/// <param name="ipFrom">
		/// The ip from.
		/// </param>
		/// <param name="uDPListen">
		/// The u dp listen.
		/// </param>
		/// <param name="beaconPortFrom">
		/// The beacon port from.
		/// </param>
		/// <param name="tCPListen">
		/// The t cp listen.
		/// </param>
		/// <param name="uDPSend">
		/// The u dp send.
		/// </param>
		/// <param name="ipTo">
		/// The ip to.
		/// </param>
		/// <param name="beaconPortTo">
		/// The beacon port to.
		/// </param>
		/// <param name="targetIPList">
		/// The target ip list.
		/// </param>
		/// <param name="Rules">
		/// The rules.
		/// </param>
		public EpicsGateWay(
			string ipFrom, 
			int uDPListen, 
			int beaconPortFrom, 
			int tCPListen, 
			int uDPSend, 
			string ipTo, 
			int beaconPortTo, 
			string targetIPList, 
			IRuleSet Rules)
		{
			this.Init(ipFrom, uDPListen, beaconPortFrom, tCPListen, uDPSend, ipTo, beaconPortTo, targetIPList, Rules);
		}
Example #22
0
		/// <summary>
		/// The init.
		/// </summary>
		/// <param name="ipFrom">
		/// The ip from.
		/// </param>
		/// <param name="uDPListen">
		/// The u dp listen.
		/// </param>
		/// <param name="beaconPortFrom">
		/// The beacon port from.
		/// </param>
		/// <param name="tCPListen">
		/// The t cp listen.
		/// </param>
		/// <param name="uDPSend">
		/// The u dp send.
		/// </param>
		/// <param name="ipTo">
		/// The ip to.
		/// </param>
		/// <param name="beaconPortTo">
		/// The beacon port to.
		/// </param>
		/// <param name="targetIpList">
		/// The target ip list.
		/// </param>
		/// <param name="rules">
		/// The rules.
		/// </param>
		private void Init(
			string ipFrom, 
			int uDPListen, 
			int beaconPortFrom, 
			int tCPListen, 
			int uDPSend, 
			string ipTo, 
			int beaconPortTo, 
			string targetIpList, 
			IRuleSet rules)
		{
			this.Rules = rules;

			this.receiverCodec = new EpicsGateWayReceiverCodec(this);
			this.connectorCodec = new EpicsGateWayConnectorCodec(this);
			this.Statistic = new EpicsGateWayStatistics();

			// start listening for connection requests on 
			this.tcpListener = new TcpListener(new IPEndPoint(IPAddress.Parse(ipFrom), tCPListen));
			this.tcpListener.Start();

			this.Config.BeaconPortFrom = beaconPortFrom;
			this.Config.BeaconPortTo = beaconPortTo;
			this.Config.TCPListenPort = tCPListen;
			this.Config.UDPSendPort = uDPSend;
			this.Config.UDPListenPort = uDPListen;

			Trace.Write("I" + string.Format("Starting gateway {0}:{1} to ({2}):{3}.", ipFrom, uDPListen, targetIpList, uDPSend));

			this.Config.ServerList.Clear();
			if (targetIpList.Contains(","))
			{
				var ips = targetIpList.Split(',');
				foreach (var ip in ips)
				{
					this.Config.ServerList.Add(ip + ":" + uDPSend);
				}
			}
			else
			{
				this.Config.ServerList.Add(targetIpList + ":" + uDPSend);
			}

			// starting a Thread to grab new TCP-Connections and wrap them into a EpicsTCPServerConnection
			this.connectionGrabber = new Thread(this.GrabConnection);
			this.connectionGrabber.IsBackground = true;
			this.connectionGrabber.Start();

			this.ChannelSearcher = new Thread(this.HandleChannelSearch);
			this.ChannelSearcher.IsBackground = true;
			this.ChannelSearcher.Start();

			this.UdpConnFrom = new EpicsUDPGWConnection(
				this, this.receiverCodec, new IPEndPoint(IPAddress.Parse(ipFrom), this.Config.UDPListenPort));
			this.UdpConnTo = new EpicsUDPGWConnection(
				this, this.connectorCodec, new IPEndPoint(IPAddress.Parse(ipTo), this.Config.BeaconPortTo));

			this.BeaconHandler = new Beaconizer(this.UdpConnFrom, this.Config.BeaconPortFrom);
			ThreadPool.QueueUserWorkItem(
				delegate
					{
						Thread.Sleep(5 * 60 * 1000);
						this.Inited = true;
						this.CareBeacons();
					});
		}
Example #23
0
 public GameStatePreparator(IRuleSet ruleSet)
 {
     this.ruleSet = ruleSet;
 }
Example #24
0
        /// <summary>
        /// The init.
        /// </summary>
        /// <param name="ipFrom">
        /// The ip from.
        /// </param>
        /// <param name="uDPListen">
        /// The u dp listen.
        /// </param>
        /// <param name="beaconPortFrom">
        /// The beacon port from.
        /// </param>
        /// <param name="tCPListen">
        /// The t cp listen.
        /// </param>
        /// <param name="uDPSend">
        /// The u dp send.
        /// </param>
        /// <param name="ipTo">
        /// The ip to.
        /// </param>
        /// <param name="beaconPortTo">
        /// The beacon port to.
        /// </param>
        /// <param name="targetIpList">
        /// The target ip list.
        /// </param>
        /// <param name="rules">
        /// The rules.
        /// </param>
        private void Init(
            string ipFrom,
            int uDPListen,
            int beaconPortFrom,
            int tCPListen,
            int uDPSend,
            string ipTo,
            int beaconPortTo,
            string targetIpList,
            IRuleSet rules)
        {
            this.Rules = rules;

            this.receiverCodec  = new EpicsGateWayReceiverCodec(this);
            this.connectorCodec = new EpicsGateWayConnectorCodec(this);
            this.Statistic      = new EpicsGateWayStatistics();

            // start listening for connection requests on
            this.tcpListener = new TcpListener(new IPEndPoint(IPAddress.Parse(ipFrom), tCPListen));
            this.tcpListener.Start();

            this.Config.BeaconPortFrom = beaconPortFrom;
            this.Config.BeaconPortTo   = beaconPortTo;
            this.Config.TCPListenPort  = tCPListen;
            this.Config.UDPSendPort    = uDPSend;
            this.Config.UDPListenPort  = uDPListen;

            Trace.Write("I" + string.Format("Starting gateway {0}:{1} to ({2}):{3}.", ipFrom, uDPListen, targetIpList, uDPSend));

            this.Config.ServerList.Clear();
            if (targetIpList.Contains(","))
            {
                var ips = targetIpList.Split(',');
                foreach (var ip in ips)
                {
                    this.Config.ServerList.Add(ip + ":" + uDPSend);
                }
            }
            else
            {
                this.Config.ServerList.Add(targetIpList + ":" + uDPSend);
            }

            // starting a Thread to grab new TCP-Connections and wrap them into a EpicsTCPServerConnection
            this.connectionGrabber = new Thread(this.GrabConnection);
            this.connectionGrabber.IsBackground = true;
            this.connectionGrabber.Start();

            this.ChannelSearcher = new Thread(this.HandleChannelSearch);
            this.ChannelSearcher.IsBackground = true;
            this.ChannelSearcher.Start();

            this.UdpConnFrom = new EpicsUDPGWConnection(
                this, this.receiverCodec, new IPEndPoint(IPAddress.Parse(ipFrom), this.Config.UDPListenPort));
            this.UdpConnTo = new EpicsUDPGWConnection(
                this, this.connectorCodec, new IPEndPoint(IPAddress.Parse(ipTo), this.Config.BeaconPortTo));

            this.BeaconHandler = new Beaconizer(this.UdpConnFrom, this.Config.BeaconPortFrom);
            ThreadPool.QueueUserWorkItem(
                delegate
            {
                Thread.Sleep(5 * 60 * 1000);
                this.Inited = true;
                this.CareBeacons();
            });
        }
Example #25
0
 public void AddRuleSet(IRuleSet set)
 {
     rulesets.Add(set);
     rscache.Clear();
 }
Example #26
0
        public void GetRulesForNotSupportedRuleSetDescriptor()
        {
            IRuleSet <IValidationRule> ruleSet = this.testee.GetRules(new NotSupportedRuleSetDescriptor());

            Assert.IsNull(ruleSet);
        }
        public void SetUp()
        {
            _ruleSetFactory = Substitute.For <IRuleSetFactory>();

            _ruleSet = Substitute.For <IRuleSet>();
        }
Example #28
0
 public CustomerController(IRuleSet RuleSet,
                           ILogger <CustomerController> logger)
 {
     _ruleSet = RuleSet;
     _logger  = logger;
 }
Example #29
0
 public Sender(IEmailConfiguration configuration, IRuleSet ruleSet, ISmtpClient smtpClient)
 {
     this.configuration = configuration;
     this.ruleSet       = ruleSet;
     this.smtpClient    = smtpClient;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectAllRulesInRuleSetSelector"/> class.
 /// </summary>
 /// <param name="ruleSet"><see cref="IRuleSet">Rule Set</see> to select.</param>
 public SelectAllRulesInRuleSetSelector(IRuleSet ruleSet)
 {
     Check.IsNotNull(ruleSet, "RuleSet is required.");
     _ruleSet = ruleSet;
 }
Example #31
0
 /// <summary>
 /// Adds a rule to the rule set.
 /// </summary>
 /// <param name="ruleSet">Rule set instance.</param>
 /// <param name="ruleDefinition">Rule definition to add.</param>
 public static void Add(this IRuleSet ruleSet, IRuleDefinition ruleDefinition)
 {
     ruleSet.Add(Enumerable.Repeat(ruleDefinition, 1));
 }
        public GetHelloMessageHandler(IRuleSet <GetHelloMessageInput> rules)
        {
            Checker.NotNullArgument(rules, nameof(rules));

            Rules = rules;
        }
Example #33
0
        public void StartGame()
        {
            myRuleSet = new StandardRuleSet();

            myMasterThread = System.Threading.Thread.CurrentThread;
            myNumPlayers = myPlayers.Count;

            myScores = new int[myNumPlayers];

            myIsGameStarted = true;
            string[] names = this.PlayerNames;
            myPlayers.ForEach(p => p.NewGame(names));
            DoLoop();
        }
 public bool Validate(string propertyName, IRuleSet ruleSet)
 {
     if (ruleSet == null)
     {
         Errors[propertyName] = new List<IActionableErrorInfo>();
     }
     else
     {
         List<IActionableErrorInfo> errorsTos = ruleSet.ValidateRules();
         List<IActionableErrorInfo> actionableErrorInfos =
             errorsTos.ConvertAll<IActionableErrorInfo>(input => new ActionableErrorInfo(input, () =>
             {
                 //
             }));
         Errors[propertyName] = actionableErrorInfos;
     }
     OnPropertyChanged("Errors");
     List<IActionableErrorInfo> errorList;
     if (Errors.TryGetValue(propertyName, out errorList))
     {
         return errorList.Count == 0;
     }
     return false;
 }
Example #35
0
 private string GetClassName(IRuleSet ruleSet)
 {
     return(ruleSet.Name.RemoveWhitespace());
 }
Example #36
0
 public bool Validate(string propertyName, IRuleSet ruleSet)
 {
     return(false);
 }
Example #37
0
 public bool Validate(string propertyName, IRuleSet ruleSet)
 {
     return false;
 }
Example #38
0
 public Evaluator(IRuleSet knowledge, IMoveGenerator moveGenerator)
 {
     _knowledge     = knowledge;
     _moveGenerator = moveGenerator;
 }