コード例 #1
0
        public RulePointContext(RulePoint rulePoint, RulePointContext parentContext, RuleConfigContext ruleConfigContext)
            : base(rulePoint.Name, parentContext, ruleConfigContext)
        {
            if (rulePoint == null)
            {
                throw new ArgumentNullException("rulePoint");   // NOXLATE
            }

            _displayName = rulePoint.DisplayName;
            UpdateDisplayTexts();

            _signature = rulePoint.Signature;

            if (_signature != null)
            {
                DeleteContentOperation = new OperationContext(
                    Properties.Resources.DeleteRulePointDisplayName,
                    new RelayCommand(obj => DeleteContent()));
                CreateContentOperation = new OperationContext(
                    Properties.Resources.CreateRuleContentDisplayName,
                    new RelayCommand(obj => CreateContent()));
                CreateNamedRuleOperation = new OperationContext(
                    Properties.Resources.CreateNewSubruleDisplayName,
                    new RelayCommand(obj => CreateNewNamedRule(Properties.Resources.DefaultNewSubruleName)));
                CopyOperation = new OperationContext(
                    Properties.Resources.CopyRulePointDisplayName,
                    new RelayCommand(obj => CopyToClipboard(), obj => HasContent));
                PasteNamedRuleOperation = new OperationContext(
                    Properties.Resources.PasteNamedRuleDisplayName,
                    new RelayCommand(obj => PasteAsNamedRule(), obj => CanPasteNamedRule()));
            }
        }
コード例 #2
0
        private SortedDictionary <string, RuleBaseContext> GetWorkingSet()
        {
            SortedDictionary <string, RuleBaseContext> workingSet = new SortedDictionary <string, RuleBaseContext>();
            Queue <RuleBaseContext> workingQueue = new Queue <RuleBaseContext>();

            workingQueue.Enqueue(RootRulePoint);
            while (workingQueue.Count > 0)
            {
                RuleBaseContext theRuleContext = workingQueue.Dequeue();
                string          rulePath       = theRuleContext.Path;
                if (!workingSet.ContainsKey(rulePath))
                {
                    workingSet.Add(rulePath, theRuleContext);
                }
                else
                {
                    Debug.Assert(false, "There are rule points or named rules having duplicated rule path. This is not allowed. There must be something wrong."); //NOXLATE
                }

                RulePointContext rulePointContext = theRuleContext as RulePointContext;
                if (rulePointContext != null)
                {
                    foreach (var ruleContext in rulePointContext.Children)
                    {
                        workingQueue.Enqueue(ruleContext);
                    }
                }
            }
            return(workingSet);
        }
コード例 #3
0
        /// <summary>
        /// Search rules including rule points and named rules, and add searching
        /// result to SearchResult property.
        /// </summary>
        private void SearchRules(Stack <RuleBaseContext> workingBuffer)
        {
            const int MaxWorkload           = 10;
            const int MaxSearchResultNumber = 1000;

            if (workingBuffer != _workingBuffer)
            {
                // System has started an another searching work by a new keyword.
                return;
            }

            int count = 0;

            while (workingBuffer.Count > 0 && count < MaxWorkload)
            {
                RuleBaseContext theContext = workingBuffer.Pop();
                if (String.IsNullOrEmpty(SearchKeyword))
                {
                    _searchResult.Add(theContext);
                }
                else
                {
                    // Call ToUpper() for search in case-insensitive way.
                    if (theContext.DisplayName.ToUpper().Contains(SearchKeyword.ToUpper()))
                    {
                        _searchResult.Add(theContext);
                    }
                }

                theContext.UpdateDisplayTexts();

                // Add children into working queue if it has.
                RulePointContext rulePoint = theContext as RulePointContext;
                if (rulePoint != null)
                {
                    foreach (var child in rulePoint.Children.Reverse()) // first child, first serve
                    {
                        workingBuffer.Push(child);
                    }
                }

                ++count;
            }

            if (_workingBuffer.Count > 0 && _searchResult.Count < MaxSearchResultNumber)
            {
                Dispatcher.CurrentDispatcher.BeginInvoke(
                    new Action <Stack <RuleBaseContext> >(SearchRules),
                    DispatcherPriority.Background,
                    workingBuffer);
            }
        }
コード例 #4
0
 public NamedRuleContext(string name, RulePointContext parentContext, RuleConfigContext ruleConfigContext)
     : base(name, parentContext, ruleConfigContext)
 {
     DeleteOperation = new OperationContext(
         Properties.Resources.DeleteNamedRuleDisplayName,
         new RelayCommand(obj => Delete()));
     CopyOperation = new OperationContext(
         Properties.Resources.CopyNamedRuleDisplayName,
         new RelayCommand(obj => CopyToClipboard()));
     CutOperation = new OperationContext(
         Properties.Resources.CutNamedRuleDisplayName,
         new RelayCommand(obj => Cut()));
     UpdateDisplayTexts();
 }
コード例 #5
0
        public RuleBaseContext(string name, RulePointContext parentContext, RuleConfigContext ruleConfigContext)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name"); // NOXLATE
            }
            if (ruleConfigContext == null)
            {
                throw new ArgumentNullException("ruleConfigContext"); // NOXLATE
            }

            _name              = name;
            _parentContext     = parentContext;
            _ruleConfigContext = ruleConfigContext;
        }
コード例 #6
0
        private void RuleConfigContext_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            RuleConfigContext context = sender as RuleConfigContext;

            Debug.Assert(context != null);

            if (e.PropertyName == "EditingRule") // NOXLATE
            {
                RuleBaseContext editingRule = context.EditingRule;
                if (editingRule == null)
                {
                    DetachDesigner();

                    if (context.SelectedRule != null && context.SelectedRule is RulePointContext)
                    {
                        RulePointContext rpc = context.SelectedRule as RulePointContext;
                        mDesignerViewContent.Content = rpc.CreateContentOperation;
                    }
                    else
                    {
                        mDesignerViewContent.Content = "TODO: show help doc here."; // NOXLATE
                    }
                }
                else
                {
                    RuleAppExtension.RuleDesignerManagerInst.UpdateDesignerAttributes();
                    _workflowDesigner      = new WorkflowDesigner();
                    _workflowDesigner.Text = context.EditingRule.Text;
                    _workflowDesigner.Load();
                    RuleEditingContext editingContext         = context.EditingRule.GetEditingContext();
                    ServiceManager     editingContextServices = _workflowDesigner.Context.Services;
                    editingContextServices.Publish <RuleEditingContextService>(new RuleEditingContextService(editingContext));
                    editingContextServices.Publish <ActivityTranslator>(RuleAppExtension.ActivityTranslatorInst);
                    editingContextServices.Publish <ActivityFactory>(RuleAppExtension.ActivityFactoryInst);
                    _workflowDesigner.ModelChanged += new EventHandler(WorkflowDesigner_ModelChanged);
                    if (_ruleDesigner == null)
                    {
                        _ruleDesigner = new InternalDesigner();
                    }
                    _ruleDesigner.SetDesigner(_workflowDesigner);
                    mDesignerViewContent.Content = _ruleDesigner;
                    //mRulesTreeView.Focus();
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// Get RuleBaseContext instance by given path.
        /// </summary>
        /// <param name="path">The path of rule.</param>
        /// <returns>RuleBaseContext instance</returns>
        public RuleBaseContext GetRuleContext(string path)
        {
            if (String.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException("path"); // NOXLATE
            }

            RuleBaseContext iter = RootRulePoint;

            string[] pathItems = RulePathHelper.GetRulePathComponents(path);
            foreach (string component in pathItems)
            {
                RulePointContext rulePoint = iter as RulePointContext;
                if (rulePoint == null)
                {
                    return(null);
                }
                iter = rulePoint.Children.FirstOrDefault((r) => (r.Name == component)) as RuleBaseContext;
            }
            return(iter);
        }
コード例 #8
0
        const string IllegalChars = "'"; // NOXLATE


        public NamedRuleContext(NamedRule namedRule, RulePointContext parentContext, RuleConfigContext ruleConfigContext)
            : this(namedRule.Name, parentContext, ruleConfigContext)
        {
        }
コード例 #9
0
 public RuleConfigContext()
 {
     RootRulePoint = new RulePointContext(RuleAppExtension.RuleManagerInstance.RootRulePoint, null, this);
     ApplyCommand  = new RelayCommand(new Action <object>(Apply), new Predicate <object>(ApplyCanExecute));
 }