Example #1
0
        public void AddsItselfToObjectContext()
        {
            var     context = new PhraseContext();
            dynamic obj     = context.CreateObject();

            Assert.Equal(context, obj.BaseContext);
        }
Example #2
0
        public void AddingTheSameValueUpdatesThatValue()
        {
            var context = new PhraseContext();

            context.Add("name", "Bob");
            context.Add("name", "Joe");
            Assert.Equal("Joe", context.GetValue <string>("name"));
        }
Example #3
0
        public void CanAddAndRetrievePropertiesToContext()
        {
            var context = new PhraseContext();

            context.Add("name", "Bob");
            context.Add("age", 15);
            Assert.Equal("Bob", context.GetValue <string>("name"));
            Assert.Equal(15, context.GetValue <int>("age"));
        }
 public UnitOfWorkCommandHandlerDecorator(
     ICommandHandler <T> decorated,
     IUnitOfWork unitOfWork,
     PhraseContext phraseContext)
 {
     _decorated     = decorated;
     _unitOfWork    = unitOfWork;
     _phraseContext = phraseContext;
 }
        public NewPhraseWindow(PhraseContext context)
        {
            InitializeComponent();

            _context    = context;
            DataContext = CurrentPhrase;
            Visibility  = Visibility.Hidden;
            Closing    += OnClosing;
            MoveToLowerRightCorner();
        }
        public PhraseEditorWindow(PhraseContext context)
        {
            InitializeComponent();

            _context = context;
            _context.Phrases.Load();
            AppDataGrid.DataContext = _context.Phrases.Local.ToObservableCollection();
            Visibility = Visibility.Hidden;
            Closing   += OnClosing;
        }
Example #7
0
        public void CanInitializeLikeADictionary()
        {
            var context = new PhraseContext()
            {
                { "name", "Bob" },
                { "age", 28 }
            };

            Assert.Equal("Bob", context.GetValue <string>("name"));
            Assert.Equal(28, context.GetValue <int>("age"));
        }
Example #8
0
        public void CanCreateAnObjectWithPropertiesForValues()
        {
            var context = new PhraseContext();

            context.Add("name", "Bob");
            context.Add("age", 28);

            dynamic obj = context.CreateObject();

            Assert.Equal("Bob", obj.name);
            Assert.Equal(28, obj.age);
        }
Example #9
0
        public void PhrasesCanCompileTemplates()
        {
            var template = "Hello {{name}}.";
            var phrase   = new PhraseTemplate(template);
            var context  = new PhraseContext()
            {
                { "name", "Bob" }
            };
            var result = phrase.WritePhrase(context);

            Assert.Equal("Hello Bob.", result);
        }
Example #10
0
        public void PhrasesCanCascadeCallsToOtherTemplatesIfNecessary()
        {
            var template = "Good Day, {{name}}.";
            var phrase   = new PhraseTemplate(template);
            var context  = new PhraseContext()
            {
                { "name", "{{fullname}}" },
                { "fullname", "Bob Woodward" }
            };
            var result = phrase.WritePhrase(context);

            Assert.Equal("Good Day, Bob Woodward.", result);
        }
Example #11
0
        public void ChoosingAWordAddsToContextIfPossible()
        {
            var color   = new Descriptor("color", new string[] { "Red" });
            var gateway = EntityGateway <Descriptor> .LoadWithSingleItem(color);

            var     choose             = ChooseDescriptor.CreateIsolatedForUnitTesting(gateway, "choose-testing");
            var     handleBarsTemplate = Handlebars.Compile("{{choose-testing \"color\"}}");
            var     context            = new PhraseContext();
            dynamic contextObj         = context.CreateObject();
            var     result             = handleBarsTemplate(contextObj);

            Assert.Equal("Red", context.GetValue <string>("color"));
            Assert.Equal("Red", contextObj.color);
        }
Example #12
0
        public PhraseContext phrase()
        {
            PhraseContext _localctx = new PhraseContext(Context, State);

            EnterRule(_localctx, 2, RULE_phrase);
            try {
                State = 51;
                ErrorHandler.Sync(this);
                switch (Interpreter.AdaptivePredict(TokenStream, 3, Context))
                {
                case 1:
                    EnterOuterAlt(_localctx, 1);
                    {
                        State = 48; keyword();
                    }
                    break;

                case 2:
                    EnterOuterAlt(_localctx, 2);
                    {
                        State = 49; attributeFilter();
                    }
                    break;

                case 3:
                    EnterOuterAlt(_localctx, 3);
                    {
                        State = 50; rangeFilter();
                    }
                    break;
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                ErrorHandler.ReportError(this, re);
                ErrorHandler.Recover(this, re);
            }
            finally {
                ExitRule();
            }
            return(_localctx);
        }
Example #13
0
        public override string VisitPhrase(PhraseContext context)
        {
            var posList = context.pos().Select(VisitPos).ToList();

            return($"{string.Join(" ",posList)}.");
        }
Example #14
0
 public PhraseRepo(PhraseContext context) : base(context)
 {
 }
Example #15
0
 public BaseRepo()
 {
     Context = new PhraseContext();
 }
Example #16
0
 public BaseRepo(PhraseContext context)
 {
     Context = context;
 }
Example #17
0
 public OutboxAccessor(PhraseContext phraseContext)
 {
     _phraseContext = phraseContext;
 }
Example #18
0
 public PhraseRepository(PhraseContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
 }
 public DomainEventsAccessor(PhraseContext context)
 {
     _context = context;
 }