コード例 #1
0
        public BindingOperation Make(Tree <Cell> nameCell)
        {
            string name = nameCell.Value.Text.Trim();

            if (NoOperationIsImpliedBy(name))
            {
                return(new NoBinding());
            }

            var cellOperation = new CellOperationImpl(processor);

            if (CheckIsImpliedBy(name))
            {
                return(new CheckBinding(cellOperation, targetProvider, nameCell));
            }

            string memberName = processor.ParseTree <Cell, MemberName>(nameCell).ToString();

            RuntimeMember member = RuntimeType.FindInstance(targetProvider, new IdentifierName(memberName), 1);

            if (member == null && newIdentifier.IsStartOf(name))
            {
                string newMemberName = name.Substring(4);
                return(new CreateBinding(processor, adapter, newMemberName));
            }

            return(new InputBinding(processor, targetProvider, nameCell));
        }
コード例 #2
0
 private void ProcessTestDocument(string document, StoryTestWriter writer)
 {
     try {
         var storyTest = new StoryTest(service, writer)
                         .WithInput(document)
                         .OnAbandonSuite(() => { suiteIsAbandoned = true; });
         reporter.WriteLine(storyTest.Leader);
         if (suiteSetupIdentifier.IsStartOf(storyTest.Leader) || IMaybeProcessingSuiteSetup)
         {
             storyTest.Execute();
         }
         else
         {
             storyTest.Execute(new Service.Service(service));
         }
     }
     catch (Exception e) {
         var testStatus = new TestStatus();
         var parse      = new CellBase(parseError, "div");
         parse.SetAttribute(CellAttribute.Body, parseError);
         testStatus.MarkException(parse, e);
         writer.WriteTable(new CellTree(parse));
         writer.WriteTest(new CellTree().AddBranchValue(parse), testStatus.Counts);
     }
 }
コード例 #3
0
ファイル: SocketServer.cs プロジェクト: x97mdr/fitsharp
 private void ProcessTestDocument(string document, Action <string, TestCounts> writer)
 {
     try
     {
         Tree <Cell> result    = service.Compose(new StoryTestString(document));
         var         parse     = result != null ? (Parse)result.Value : null;
         var         storyTest = new StoryTest(parse, (tables, counts) => WriteResults(tables, counts, writer));
         reporter.WriteLine(parse.Leader);
         if (suiteSetupIdentifier.IsStartOf(parse.Leader) || IMaybeProcessingSuiteSetup)
         {
             storyTest.ExecuteOnConfiguration(service.Configuration);
         }
         else
         {
             storyTest.Execute(service.Configuration);
         }
     }
     catch (Exception e)
     {
         var testStatus = new TestStatus();
         var parse      = new CellBase(parseError, "div");
         parse.SetAttribute(CellAttribute.Body, parseError);
         testStatus.MarkException(parse, e);
         WriteResults(new CellTree().AddBranchValue(parse), testStatus.Counts, writer);
     }
 }
コード例 #4
0
        public BindingOperation Make(Tree <Cell> nameCell)
        {
            var name = nameCell.Value.Text.Trim();

            if (NoOperationIsImpliedBy(name))
            {
                return(new NoBinding());
            }

            if (CheckIsImpliedBy(name))
            {
                return(new CheckBinding(processor, targetProvider, nameCell));
            }

            var memberName = processor.ParseTree <Cell, MemberName>(nameCell);
            var member     = MemberQuery.FindInstance(processor.FindMember, targetProvider,
                                                      new MemberSpecification(memberName, 1));

            if (member == null && newIdentifier.IsStartOf(name))
            {
                string newMemberName = name.Substring(4);
                return(new CreateBinding(processor, adapter, newMemberName));
            }

            return(new InputBinding(processor, targetProvider, nameCell));
        }
コード例 #5
0
        public bool CanParse(Type type, TypedValue instance, Tree <Cell> parameters)
        {
            if (type != typeof(DateTime))
            {
                return(false);
            }
            string text = parameters.Value.Content;

            if (!today.IsStartOf(text))
            {
                return(false);
            }
            if (text.Length > today.Length)
            {
                string modifier = text.Substring(today.Length).Trim();
                if (!modifier.StartsWith("+") && !modifier.StartsWith("-"))
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #6
0
ファイル: ParseByteArray.cs プロジェクト: x97mdr/fitsharp
 public bool CanParse(Type type, TypedValue instance, Tree <Cell> parameters)
 {
     return(type == typeof(byte[]) && prefix.IsStartOf(parameters.Value.Text));
 }
コード例 #7
0
ファイル: ExecuteException.cs プロジェクト: x97mdr/fitsharp
 public override bool CanExecute(ExecuteContext context, ExecuteParameters parameters)
 {
     return(context.Command == ExecuteCommand.Check &&
            exceptionIdentifier.IsStartOf(parameters.Cell.Text) && parameters.Cell.Text.EndsWith("]"));
 }
コード例 #8
0
 public bool CanCompare(TypedValue actual, Tree <Cell> expected)
 {
     return(expected.Value.Text != null && failIdentifier.IsStartOf(expected.Value.Text) &&
            expected.Value.Text.EndsWith("]"));
 }