コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BuiltInRuleRowViewModel"/> class.
        /// </summary>
        /// <param name="rule">
        /// The <see cref="BuiltInRule"/> that is represented by the current row view-model.
        /// </param>
        /// <param name="metaData">
        /// The <see cref="IBuiltInRuleMetaData"/> that provides the meta-data for the <see cref="BuiltInRule"/>
        /// that is represented by the current row view-model.
        /// </param>
        public BuiltInRuleRowViewModel(IBuiltInRule rule, IBuiltInRuleMetaData metaData)
        {
            if (rule == null)
            {
                throw new ArgumentNullException(nameof(rule), "The rule shall not be null");
            }

            if (metaData == null)
            {
                throw new ArgumentNullException(nameof(metaData), "The metaData shall not be null");
            }

            this.Rule     = rule;
            this.metaData = metaData;
        }
コード例 #2
0
        /// <summary>
        /// Registers a <see cref="builtInRule"/> with the service
        /// </summary>
        /// <param name="builtInRule">
        /// The <see cref="BuiltInRule"/> to register
        /// </param>
        /// <param name="metaData">
        /// The <see cref="IBuiltInRuleMetaData"/> that describes the <see cref="BuiltInRule"/>
        /// </param>
        public void Register(IBuiltInRule builtInRule, IBuiltInRuleMetaData metaData)
        {
            var ruleName     = metaData.Name;
            var registration = new Lazy <IBuiltInRule, IBuiltInRuleMetaData>(() => builtInRule, metaData);

            if (this.builtInRules.ContainsKey(ruleName))
            {
                var ruleAuthor      = metaData.Author;
                var ruleDescription = metaData.Description;

                logger.Warn("A BuiltInRule with name:{0}, by author:{1} with description:{2}, has already been registered.", ruleName, ruleAuthor, ruleDescription);
            }
            else
            {
                this.builtInRules.Add(ruleName, registration);
            }
        }
 /// <summary>
 /// Set IBuiltInRuleMetaData properties
 /// </summary>
 /// <param name="metaData">
 /// The <see cref="IBuiltInRuleMetaData"/> from which the properties are set
 /// </param>
 private void SetMetaDataProperties(IBuiltInRuleMetaData metaData)
 {
     this.Author      = metaData.Author;
     this.Name        = metaData.Name;
     this.Description = metaData.Description;
 }