Example #1
0
        /// <summary>
        /// Gets a rule point by a given path.
        /// </summary>
        /// <param name="rulePointPath">The path of the rule point you want to get</param>
        /// <returns>The rule point if it exists; otherwise, null.</returns>
        public RulePoint GetRulePoint(string rulePointPath)
        {
            RulePoint iter = RootRulePoint;

            string[] pathItems = RulePathHelper.GetRulePathComponents(rulePointPath);
            foreach (string item in pathItems)
            {
                iter = iter.GetSubRulePoint(item);
                if (iter == null)
                {
                    return(null);
                }
            }
            return(iter);
        }
Example #2
0
        /// <summary>
        /// Gets a rule point by a given path. Returns the lowest level sub rule point in
        /// the heirarchy which has a valid activity defined.
        /// </summary>
        /// <param name="rulePointPath">The path of the rule point you want to get</param>
        /// <returns>The lowest level rule point in the path that has an activity; otherwise, null.</returns>
        public RulePoint GetRulePointWithActivity(string rulePointPath)
        {
            RulePoint activityPoint = null;
            RulePoint iter          = RootRulePoint;

            string[] pathItems = RulePathHelper.GetRulePathComponents(rulePointPath);
            foreach (string item in pathItems)
            {
                iter = iter.GetSubRulePoint(item);
                if (iter == null)
                {
                    return(activityPoint);
                }
                else if (iter.HasActivity)
                {
                    activityPoint = iter;
                }
            }
            return(activityPoint);
        }
Example #3
0
        /// <summary>
        /// Registers a new rule point with specified position.
        /// </summary>
        /// <param name="parentPath">A string representing the position where the rule point goes.</param>
        /// <param name="name">The name of rule point.</param>
        /// <param name="displayName">The display name of rule point.</param>
        /// <param name="signature">The signature of rule point.</param>
        public void RegisterRulePoint(string parentPath, string name, string displayName, RuleSignature signature)
        {
            RulePoint rulePoint = new RulePoint(this, name, signature, displayName);

            // Create rule points recursively.
            RulePoint iter = RootRulePoint;

            string[] pathItems = RulePathHelper.GetRulePathComponents(parentPath);
            foreach (string item in pathItems)
            {
                if (!iter.HasChild(item))
                {
                    iter.AddRulePoint(new RulePoint(this, item));
                }
                iter = iter.GetSubRulePoint(item);
                if (iter == null)
                {
                    throw new InvalidOperationException(Properties.Resources.CannotRegisterRulePoint);
                }
            }

            iter.AddRulePoint(rulePoint);
        }