当前位置: 首页>>代码示例>>C#>>正文


C# ErrorSink类代码示例

本文整理汇总了C#中ErrorSink的典型用法代码示例。如果您正苦于以下问题:C# ErrorSink类的具体用法?C# ErrorSink怎么用?C# ErrorSink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ErrorSink类属于命名空间,在下文中一共展示了ErrorSink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Resolve_CalculatesAssemblyLocationInLookupText

        public void Resolve_CalculatesAssemblyLocationInLookupText(string lookupText, int assemblyLocation)
        {
            // Arrange
            var errorSink = new ErrorSink();
            var tagHelperDescriptorResolver = new InspectableTagHelperDescriptorResolver();
            var directiveType = TagHelperDirectiveType.AddTagHelper;
            var resolutionContext = new TagHelperDescriptorResolutionContext(
                new[]
                {
                    new TagHelperDirectiveDescriptor
                    {
                        DirectiveText = lookupText,
                        Location = SourceLocation.Zero,
                        DirectiveType = directiveType
                    }
                },
                errorSink);
            var expectedSourceLocation = new SourceLocation(assemblyLocation, 0, assemblyLocation);

            // Act
            tagHelperDescriptorResolver.Resolve(resolutionContext);

            // Assert
            Assert.Empty(errorSink.Errors);
            Assert.Equal(expectedSourceLocation, tagHelperDescriptorResolver.DocumentLocation);
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:26,代码来源:TagHelperDescriptorResolverTest.cs

示例2: CreateDescriptors_WithPrefixes_ReturnsExpectedAttributeDescriptors

        public void CreateDescriptors_WithPrefixes_ReturnsExpectedAttributeDescriptors(
            Type tagHelperType,
            IEnumerable<TagHelperAttributeDescriptor> expectedAttributeDescriptors,
            string[] expectedErrorMessages)
        {
            // Arrange
            var errorSink = new ErrorSink();
            var factory = new TagHelperDescriptorFactory(designTime: false);

            // Act
            var descriptors = factory.CreateDescriptors(
                AssemblyName,
                GetTypeInfo(tagHelperType),
                errorSink: errorSink);

            // Assert
            var errors = errorSink.Errors.ToArray();
            Assert.Equal(expectedErrorMessages.Length, errors.Length);

            for (var i = 0; i < errors.Length; i++)
            {
                Assert.Equal(0, errors[i].Length);
                Assert.Equal(SourceLocation.Zero, errors[i].Location);
                Assert.Equal(expectedErrorMessages[i], errors[i].Message, StringComparer.Ordinal);
            }

            var descriptor = Assert.Single(descriptors);
            Assert.Equal(
                expectedAttributeDescriptors,
                descriptor.Attributes,
                TagHelperAttributeDescriptorComparer.Default);
        }
开发者ID:leloulight,项目名称:Razor,代码行数:32,代码来源:RuntimeTagHelperDescriptorFactoryTest.cs

示例3: CreateDescriptors

        /// <summary>
        /// Creates a <see cref="TagHelperDescriptor"/> from the given <paramref name="typeInfo"/>.
        /// </summary>
        /// <param name="assemblyName">The assembly name that contains <paramref name="type"/>.</param>
        /// <param name="typeInfo">The <see cref="ITypeInfo"/> to create a <see cref="TagHelperDescriptor"/> from.
        /// </param>
        /// <param name="errorSink">The <see cref="ErrorSink"/> used to collect <see cref="RazorError"/>s encountered
        /// when creating <see cref="TagHelperDescriptor"/>s for the given <paramref name="typeInfo"/>.</param>
        /// <returns>
        /// A collection of <see cref="TagHelperDescriptor"/>s that describe the given <paramref name="typeInfo"/>.
        /// </returns>
        public virtual IEnumerable<TagHelperDescriptor> CreateDescriptors(
            string assemblyName,
            ITypeInfo typeInfo,
            ErrorSink errorSink)
        {
            if (typeInfo == null)
            {
                throw new ArgumentNullException(nameof(typeInfo));
            }

            if (errorSink == null)
            {
                throw new ArgumentNullException(nameof(errorSink));
            }

            if (ShouldSkipDescriptorCreation(typeInfo))
            {
                return Enumerable.Empty<TagHelperDescriptor>();
            }

            var attributeDescriptors = GetAttributeDescriptors(typeInfo, errorSink);
            var targetElementAttributes = GetValidHtmlTargetElementAttributes(typeInfo, errorSink);
            var allowedChildren = GetAllowedChildren(typeInfo, errorSink);

            var tagHelperDescriptors =
                BuildTagHelperDescriptors(
                    typeInfo,
                    assemblyName,
                    attributeDescriptors,
                    targetElementAttributes,
                    allowedChildren);

            return tagHelperDescriptors.Distinct(TagHelperDescriptorComparer.Default);
        }
开发者ID:leloulight,项目名称:Razor,代码行数:45,代码来源:TagHelperDescriptorFactory.cs

示例4: GetAttributeNameValuePairs_ParsesPairsCorrectly

        public void GetAttributeNameValuePairs_ParsesPairsCorrectly(
            string documentContent,
            IEnumerable<KeyValuePair<string, string>> expectedPairs)
        {
            // Arrange
            var errorSink = new ErrorSink();
            var parseResult = ParseDocument(documentContent, errorSink);
            var document = parseResult.Document;
            var rewriters = RazorParser.GetDefaultRewriters(new HtmlMarkupParser());
            var rewritingContext = new RewritingContext(document, errorSink);
            foreach (var rewriter in rewriters)
            {
                rewriter.Rewrite(rewritingContext);
            }
            var block = rewritingContext.SyntaxTree.Children.First();
            var parseTreeRewriter = new TagHelperParseTreeRewriter(provider: null);

            // Assert - Guard
            var tagBlock = Assert.IsType<Block>(block);
            Assert.Equal(BlockType.Tag, tagBlock.Type);
            Assert.Empty(errorSink.Errors);

            // Act
            var pairs = parseTreeRewriter.GetAttributeNameValuePairs(tagBlock);

            // Assert
            Assert.Equal(expectedPairs, pairs);
        }
开发者ID:cjqian,项目名称:Razor,代码行数:28,代码来源:TagHelperParseTreeRewriterTest.cs

示例5: TagHelperDirectiveSpanVisitor

 public TagHelperDirectiveSpanVisitor(
     [NotNull] ITagHelperDescriptorResolver descriptorResolver,
     [NotNull] ErrorSink errorSink)
 {
     _descriptorResolver = descriptorResolver;
     _errorSink = errorSink;
 }
开发者ID:jgglg,项目名称:Razor,代码行数:7,代码来源:TagHelperDirectiveSpanVisitor.cs

示例6: RewritingContext

        /// <summary>
        /// Instantiates a new <see cref="RewritingContext"/>.
        /// </summary>
        public RewritingContext(Block syntaxTree, ErrorSink errorSink)
        {
            _errors = new List<RazorError>();
            SyntaxTree = syntaxTree;

            ErrorSink = errorSink;
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:10,代码来源:RewritingContext.cs

示例7: GetValidTargetElementAttributes

        private static IEnumerable<TargetElementAttribute> GetValidTargetElementAttributes(
            TypeInfo typeInfo,
            ErrorSink errorSink)
        {
            var targetElementAttributes = typeInfo.GetCustomAttributes<TargetElementAttribute>(inherit: false);

            return targetElementAttributes.Where(attribute => ValidTargetElementAttributeNames(attribute, errorSink));
        }
开发者ID:antiufo,项目名称:Razor,代码行数:8,代码来源:TagHelperDescriptorFactory.cs

示例8: CreateParserContext

 public override ParserContext CreateParserContext(
     ITextDocument input,
     ParserBase codeParser,
     ParserBase markupParser,
     ErrorSink errorSink)
 {
     return base.CreateParserContext(input, codeParser, markupParser, errorSink);
 }
开发者ID:rahulchrty,项目名称:Razor,代码行数:8,代码来源:TagHelperRewritingTestBase.cs

示例9: CompilerContext

        public CompilerContext(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink, ParserSink parserSink)
        {
            Contract.RequiresNotNull(sourceUnit, "sourceUnit");

            _sourceUnit = sourceUnit;
            _options = options ?? sourceUnit.Engine.GetDefaultCompilerOptions();
            _errors = errorSink ?? sourceUnit.Engine.GetCompilerErrorSink();
            _parserSink = parserSink ?? ParserSink.Null;
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:9,代码来源:CompilerContext.cs

示例10: CodeBuilderContext

 // Internal for testing.
 internal CodeBuilderContext(RazorEngineHost host,
                             string className,
                             string rootNamespace,
                             string sourceFile,
                             bool shouldGenerateLinePragmas,
                             ErrorSink errorSink)
     : base(host, className, rootNamespace, sourceFile, shouldGenerateLinePragmas)
 {
     ErrorSink = errorSink;
     ExpressionRenderingMode = ExpressionRenderingMode.WriteToOutput;
 }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:12,代码来源:CodeBuilderContext.cs

示例11: CompilerContext

        public CompilerContext(SourceUnit sourceUnit, CompilerOptions options, ErrorSink errorSink, ParserSink parserSink) {
            ContractUtils.RequiresNotNull(sourceUnit, "sourceUnit");
            ContractUtils.RequiresNotNull(errorSink, "errorSink");
            ContractUtils.RequiresNotNull(parserSink, "parserSink");
            ContractUtils.RequiresNotNull(options, "options");

            _sourceUnit = sourceUnit;
            _options = options;
            _errors = errorSink;
            _parserSink = parserSink;
        }
开发者ID:jxnmaomao,项目名称:ironruby,代码行数:11,代码来源:CompilerContext.cs

示例12: CreateParserContext

 public virtual ParserContext CreateParserContext(ITextDocument input,
                                                  ParserBase codeParser,
                                                  ParserBase markupParser,
                                                  ErrorSink errorSink)
 {
     return new ParserContext(input,
                              codeParser,
                              markupParser,
                              SelectActiveParser(codeParser, markupParser),
                              errorSink);
 }
开发者ID:x-strong,项目名称:Razor,代码行数:11,代码来源:ParserTestBase.cs

示例13: Rewrite

        public static TagHelperBlockBuilder Rewrite(
            string tagName,
            bool validStructure,
            Block tag,
            IEnumerable<TagHelperDescriptor> descriptors,
            ErrorSink errorSink)
        {
            // There will always be at least one child for the '<'.
            var start = tag.Children.First().Start;
            var attributes = GetTagAttributes(tagName, validStructure, tag, descriptors, errorSink);
            var tagMode = GetTagMode(tagName, tag, descriptors, errorSink);

            return new TagHelperBlockBuilder(tagName, tagMode, start, attributes, descriptors);
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:14,代码来源:TagHelperBlockRewriter.cs

示例14: VisitCallsOnCompleteWhenAllNodesHaveBeenVisited

        public void VisitCallsOnCompleteWhenAllNodesHaveBeenVisited()
        {
            // Arrange
            Mock<ParserVisitor> targetMock = new Mock<ParserVisitor>();
            var root = new BlockBuilder() { Type = BlockType.Comment }.Build();
            var errorSink = new ErrorSink();
            errorSink.OnError(new RazorError("Foo", new SourceLocation(1, 0, 1), length: 3));
            errorSink.OnError(new RazorError("Bar", new SourceLocation(2, 0, 2), length: 3));
            var results = new ParserResults(root, Enumerable.Empty<TagHelperDescriptor>(), errorSink);

            // Act
            targetMock.Object.Visit(results);

            // Assert
            targetMock.Verify(v => v.OnComplete());
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:16,代码来源:ParserVisitorExtensionsTest.cs

示例15: VisitSendsDocumentToVisitor

        public void VisitSendsDocumentToVisitor()
        {
            // Arrange
            Mock<ParserVisitor> targetMock = new Mock<ParserVisitor>();
            var root = new BlockBuilder() { Type = BlockType.Comment }.Build();
            var errorSink = new ErrorSink();
            var results = new ParserResults(root,
                                            Enumerable.Empty<TagHelperDescriptor>(),
                                            errorSink);

            // Act
            targetMock.Object.Visit(results);

            // Assert
            targetMock.Verify(v => v.VisitBlock(root));
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:16,代码来源:ParserVisitorExtensionsTest.cs


注:本文中的ErrorSink类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。