private async void FixConflictByKeepAsIs(object parameter)
        {
            var listView = parameter as ListView;

            if (listView == null)
            {
                return;
            }

            var selectedList = new List <SyncInfoDetail>();
            var usageHint    = false;

            foreach (SyncInfoDetail detail in listView.SelectedItems)
            {
                if (detail.ConflictType == ConflictType.BothChanged ||
                    detail.ConflictType == ConflictType.BothNew)
                {
                    detail.ConflictSolution = ConflictSolution.KeepAsIs;
                    SyncDbUtils.SaveSyncInfoDetail(detail);
                    selectedList.Add(detail);
                }
                else
                {
                    usageHint = true;
                }
            }

            selectedList.ForEach(x => ConflictList.Remove(x));
            if (!usageHint)
            {
                return;
            }
            var dialog = new ContentDialog
            {
                Title   = _resourceLoader.GetString("SyncKeepAsIsHintTitle"),
                Content = new TextBlock
                {
                    Text         = _resourceLoader.GetString("SyncKeepAsIsHintDesc"),
                    TextWrapping = TextWrapping.WrapWholeWords,
                    Margin       = new Thickness(0, 20, 0, 0)
                },
                PrimaryButtonText = _resourceLoader.GetString("OK")
            };
            await _dialogService.ShowAsync(dialog);
        }
        private void FixConflictByRemote(object parameter)
        {
            var listView = parameter as ListView;

            if (listView == null)
            {
                return;
            }

            var selectedList = new List <SyncInfoDetail>();

            foreach (SyncInfoDetail detail in listView.SelectedItems)
            {
                detail.ConflictSolution = ConflictSolution.PreferRemote;
                SyncDbUtils.SaveSyncInfoDetail(detail);
                selectedList.Add(detail);
            }

            selectedList.ForEach(x => ConflictList.Remove(x));
        }
Ejemplo n.º 3
0
        public LR1Parser(ILogger logger,
                         Grammar grammar,
                         ConflictList conflicts)
        {
            this.grammar = grammar;
            var endSymbol = grammar.Symbols[0];

            //Honalee Algorithm
            //Create kernel item from augmented gramar production
            var kernel     = new LR1Item(grammar[0], 0, endSymbol);
            var startState = new State(0)
            {
                kernel
            };

            States = new States {
                startState
            };
            startState.Closure(this.grammar);

            var queue = new Queue <State>();

            queue.Enqueue(startState);
            var actionBuilder = new ActionBuilder(this.grammar);

            //Method2
            while (queue.Count > 0)
            {
                startState = queue.Dequeue();
                Goto(startState, actionBuilder, queue);
            }

            var resolver = new ConflictResolvers(conflicts,
                                                 grammar.Symbols,
                                                 logger);

            Actions = actionBuilder.Build(logger,
                                          States,
                                          this.grammar.Symbols,
                                          resolver);
        }
Ejemplo n.º 4
0
 public ConflictResolvers(ConflictList conflicts,
                          Symbols symbols,
                          ILogger logger)
 {
     data = new Dictionary <Key, int>();
     foreach (var conflict in conflicts)
     {
         if (symbols.TryFind(conflict.Symbol, out var symbol))
         {
             var key    = new Key(conflict.State, symbol !.Id);
             var action = conflict.Shift ?
                          conflict.NextState :
                          -(int)(2 + conflict.NextState);
             data[key] = action;
         }
         else
         {
             logger.LogWarning(conflict, "Missing symbol {0}", conflict.Symbol);
         }
     }
 }
Ejemplo n.º 5
0
        public void BookTest()
        {
            var grammar = new Grammar(
                "S", "C", "C", null,
                "C", "c", "C", null,
                "C", "d", null);

            var text     = grammar.ToString(false);
            var expected =
                @"R0: S' -> S
R1: S -> C C
R2: C -> c C
R3: C -> d
";

            Assert.AreEqual(expected, text);

            var test      = "test.log";
            var logger    = new ConsoleLogger(test);
            var conflicts = new ConflictList();
            var builder   = new LR1Parser(logger, grammar, conflicts);
            var states    = builder.States.ToString(false);

            expected =
                @"S0
    S': · S, $
    S: · C C, $
    C: · c C, c
    C: · c C, d
    C: · d, c
    C: · d, d

S1
    S': S ·, $

S2
    S: C · C, $
    C: · c C, $
    C: · d, $

S3
    C: · c C, c
    C: · c C, d
    C: c · C, c
    C: c · C, d
    C: · d, c
    C: · d, d

S4
    C: d ·, c
    C: d ·, d

S5
    S: C C ·, $

S6
    C: · c C, $
    C: c · C, $
    C: · d, $

S7
    C: d ·, $

S8
    C: c C ·, c
    C: c C ·, d

S9
    C: c C ·, $
";
            Assert.AreEqual(expected, states);
        }
Ejemplo n.º 6
0
 private bool CanExecuteFixConflict()
 {
     return(ConflictList?.Count() > 0);
 }