• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ParseContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: BindDependency

 private static void BindDependency(Type type, string dependencyName, string dependencyText, ParseContext parseContext)
 {
     var serviceConstructor = type.GetConstructor();
     if (!serviceConstructor.isOk)
     {
         var message = string.Format("type [{0}] has ", type.FormatName());
         throw new SimpleContainerException(message + serviceConstructor.errorMessage);
     }
     var formalParameter = serviceConstructor.value.GetParameters().SingleOrDefault(x => x.Name == dependencyName);
     if (formalParameter == null)
     {
         const string message = "type [{0}] has no dependency [{1}]";
         throw new SimpleContainerException(string.Format(message, type.FormatName(), dependencyName));
     }
     var targetType = formalParameter.ParameterType;
     var underlyingType = Nullable.GetUnderlyingType(targetType);
     if (underlyingType != null)
         targetType = underlyingType;
     IConvertible convertible = dependencyText;
     object parsedValue;
     try
     {
         parsedValue = convertible.ToType(targetType, CultureInfo.InvariantCulture);
     }
     catch (Exception e)
     {
         const string message = "can't parse [{0}.{1}] from [{2}] as [{3}]";
         throw new SimpleContainerException(string.Format(message, type.FormatName(), dependencyName,
             dependencyText, formalParameter.ParameterType.FormatName()), e);
     }
     parseContext.GetServiceBuilder(type).BindDependency(dependencyName, parsedValue);
 }
开发者ID:shparun,项目名称:simple-container,代码行数:32,代码来源:FileConfigurationParser.cs


示例2: Extract

        public TextExtractionResult Extract(Func<Metadata, InputStream> streamFactory)
        {
            try
            {
                var parser = new AutoDetectParser();
                var metadata = new Metadata();
                var parseContext = new ParseContext();

                //use the base class type for the key or parts of Tika won't find a usable parser
                parseContext.set(typeof(Parser), parser);

                var content = new System.IO.StringWriter();
                var contentHandlerResult = new TextExtractorContentHandler(content);

                using (var inputStream = streamFactory(metadata))
                {
                    try
                    {
                        parser.parse(inputStream, contentHandlerResult, metadata, parseContext);
                    }
                    finally
                    {
                        inputStream.close();
                    }
                }

                return AssembleExtractionResult(content.ToString(), metadata);
            }
            catch (Exception ex)
            {
                throw new TextExtractionException("Extraction failed.", ex);
            }
        }
开发者ID:KevM,项目名称:tikaondotnet,代码行数:33,代码来源:TextExtractor.cs


示例3: CreateScope

        protected override IScope CreateScope(string name, IDictionary<string, string> data, ParseContext context)
        {
            var module = context.ModuleFactory.Create(name);
            module.Load(data);

            return new ModuleScope(module);
        }
开发者ID:tmont,项目名称:butterfly,代码行数:7,代码来源:ModuleStrategy.cs


示例4: ParseNode

        public override void ParseNode(HtmlNode htmlNode, XElement resultElement, ParseContext parseContext, XElement baseFormattingElement)
        {
            XElement xElement = null;
            HtmlAttribute htmlAttribute = htmlNode.Attributes["src"];
            if (htmlAttribute != null)
            {
                MediaItem mediaItem = this.GetMediaItem(htmlAttribute.Value);
                if (mediaItem != null)
                {
                    string text;
                    string text2;
                    StyleParser.ParseDimensions(htmlNode, out text, out text2);
                    if (string.IsNullOrEmpty(text))
                    {
                        text = HtmlParseHelper.ParseDimensionValue(mediaItem.InnerItem["Width"], true);
                    }
                    if (string.IsNullOrEmpty(text2))
                    {
                        text2 = HtmlParseHelper.ParseDimensionValue(mediaItem.InnerItem["Height"], true);
                    }

                    xElement = this.CreateInlineElement(text, text2);
                    XElement content = this.CreateImageElement(htmlNode, mediaItem, parseContext, text, text2);
                    xElement.Add(content);
                }
            }
            if (xElement != null)
            {
                resultElement.Add(xElement);
            }
        }
开发者ID:ravikumhar,项目名称:Sitecore.PxM.Toolbox,代码行数:31,代码来源:CustomImageParser.cs


示例5: Main

        static void Main(string[] args)
        {
            string[] IgnoreClassifiers = new string[] { "Whitespace"};
            //var parser = DynamicParser.LoadFromMgx("M.mgx", "Microsoft.M.MParser");
            var parser = DynamicParser.LoadFromMgx("Mg.mgx", "Microsoft.M.Grammar.MGrammar");
            using (var sr = new StreamReader("rockfordauth.mg"))
            using (var parseContext = new ParseContext(parser.Lexer,
                                                       parser.Parser,
                                                       parser.GraphBuilder,
                                                       ErrorReporter.Standard,
                                                       "test.M"))
            {
                var lexerReader = new LexerReader();
                if (lexerReader.Open(parseContext, sr, true))
                {
                    using (StreamWriter sw = new StreamWriter("output.html"))
                    {
                       sw.WriteLine("<html><head><style>body { background-color: #333333; color: white; font-family: Consolas; } .Delimiter { color: #ddd; } .Keyword { color: #6dcff6; font-weight: bold; } .Literal { color: #10cc20; }</style></head><body>");
                        bool eof = false;
                        while (true)
                        {
                            var tokens = lexerReader.Read();
                            foreach (var token in tokens)
                            {
                                object[] tokenInfos = parser.GetTokenInfo(token.Tag);
                                ClassificationAttribute classificationAttribute = null;
                                if (tokenInfos != null && tokenInfos.Length > 0)
                                {
                                    classificationAttribute = tokenInfos[0] as ClassificationAttribute;
                                }

                                if (token.Description.Equals("EOF")) // TODO: Match against the EOF token if its public
                                {
                                    eof = true;
                                    break;
                                }
                                if (classificationAttribute != null &&
                                    !IgnoreClassifiers.Contains(classificationAttribute.Classification))
                                {
                                    sw.Write(string.Format("<span class=\"{0}\">{1}</span>",
                                        classificationAttribute.Classification,
                                        token.GetTextString()));
                                }
                                else
                                {
                                    string output = token.GetTextString().Replace(" ", "&nbsp;").Replace("\r", "<br />");
                                    sw.Write(output);
                                }
                            }
                            if (eof)
                                break;
                        }
                        sw.WriteLine("</body></html>");
                    }
                }
                Console.WriteLine("Output generated.");
                Console.ReadLine();
            }
        }
开发者ID:larsw,项目名称:larsw.msyntaxhighlighter,代码行数:59,代码来源:Program.cs


示例6: DoExecute

        protected override void DoExecute(ParseContext context)
        {
            context.Input.Read(3);
            context.UpdateCurrentChar();

            OpenScope(new HorizontalRulerScope(), context);
            CloseCurrentScope(context);
        }
开发者ID:tmont,项目名称:butterfly,代码行数:8,代码来源:HorizontalRulerStrategy.cs


示例7: BinaryOperator

        public BinaryOperator(Token Source, ParseContext.Operator Operator,
			Node LHS, Node RHS)
            : base(Source)
        {
            this.Operator = Operator;
            this.LHS = LHS;
            this.RHS = RHS;
        }
开发者ID:Blecki,项目名称:EtcScript,代码行数:8,代码来源:BinaryOperation.cs


示例8: DoExecute

        protected override void DoExecute(ParseContext context)
        {
            if (!context.Scopes.ContainsType(ScopeTypeCache.DefinitionList)) {
                OpenScope(new DefinitionListScope(), context);
            }

            OpenScope(new DefinitionTermScope(), context);
        }
开发者ID:tmont,项目名称:butterfly,代码行数:8,代码来源:DefinitionListStrategy.cs


示例9: Token

 public Token(TokenType type, string contents, int index, string text, ParseContext offset)
 {
     _type = type;
     _contents = contents;
     _index = index;
     _text = text;
     _offset = offset;
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:8,代码来源:Token.cs


示例10: IsSatisfiedBy

        public bool IsSatisfiedBy(ParseContext context)
        {
            if (chars.Length == 1) {
                return chars[0] == context.CurrentChar;
            }

            return (char)context.CurrentChar + context.Input.Peek(chars.Length - 1) == chars;
        }
开发者ID:tmont,项目名称:butterfly,代码行数:8,代码来源:ExactCharMatchSatisfier.cs


示例11: CloseParagraphIfNecessary

        protected void CloseParagraphIfNecessary(ParseContext context)
        {
            var scope = context.Scopes.PeekOrDefault();
            if (scope == null || scope.GetType() != ScopeTypeCache.Paragraph) {
                return;
            }

            CloseCurrentScope(context);
        }
开发者ID:tmont,项目名称:butterfly,代码行数:9,代码来源:ScopeDrivenStrategy.cs


示例12: Select

		public override void Select(StatementSink store) {
			ParseContext context = new ParseContext();
			context.source = new MyReader(sourcestream);
			context.store = GetDupCheckSink(store);
			context.namespaces = namespaces;
			context.namedNode = new UriMap();
			context.anonymous = new Hashtable();
			context.meta = Meta;
			
			while (ReadStatement(context)) { }
		}
开发者ID:AminBonyadUni,项目名称:facedetect-f-spot,代码行数:11,代码来源:N3Parser.cs


示例13: GetLanguage

        protected string GetLanguage(ParseContext context)
        {
            var languageBuilder = new StringBuilder();
            context.AdvanceInput();
            while (context.CurrentChar != '\n' && context.CurrentChar != ButterflyStringReader.NoValue) {
                languageBuilder.Append((char)context.CurrentChar);
                context.AdvanceInput();
            }

            return languageBuilder.ToString();
        }
开发者ID:tmont,项目名称:butterfly,代码行数:11,代码来源:OpenPreformattedStrategy.cs


示例14: Parse

 public static Action<ContainerConfigurationBuilder> Parse(Type[] types, string fileName)
 {
     var parseItems = SplitWithTrim(File.ReadAllText(fileName).Replace("\r\n", "\n"), "\n").Select(Parse).ToArray();
     var typesMap = types.ToLookup(x => x.Name);
     return delegate(ContainerConfigurationBuilder builder)
     {
         var context = new ParseContext(builder.RegistryBuilder, typesMap);
         foreach (var item in parseItems)
             item(context);
     };
 }
开发者ID:shparun,项目名称:simple-container,代码行数:11,代码来源:FileConfigurationParser.cs


示例15: Get

 public ITagGroup Get(string group, ParseContext context=null)
 {
     if (_tags.ContainsKey(group))
     {
         return _tags[group];
     }
     if (context != null) {
         throw TagException.UnkownTagGroup(group).Decorate(context);
     }
     return null;;
 }
开发者ID:rslijp,项目名称:sharptiles,代码行数:11,代码来源:TagLib.cs


示例16: DoExecute

        protected override sealed void DoExecute(ParseContext context)
        {
            var c = GetChar(context);

            ParagraphStrategy.ExecuteIfSatisfied(context);

            if (context.CurrentNode != null && context.CurrentNode.Scope.GetType() == ScopeTypeCache.Unescaped) {
                context.Analyzer.WriteUnescapedChar(c);
            } else {
                context.Analyzer.WriteAndEscape(c);
            }
        }
开发者ID:tmont,项目名称:butterfly,代码行数:12,代码来源:WriteCharacterStrategy.cs


示例17: DoExecute

        protected override void DoExecute(ParseContext context)
        {
            var depth = 1;
            while (context.Input.Peek() == '!') {
                depth++;
                context.Input.Read();
            }

            context.Input.SeekToNonWhitespace(); //ignore spaces/tabs
            context.UpdateCurrentChar();
            OpenScope(new HeaderScope(depth), context);
        }
开发者ID:tmont,项目名称:butterfly,代码行数:12,代码来源:HeaderStrategy.cs


示例18: OpenScope

        protected void OpenScope(IScope scope, ParseContext context)
        {
            if (BeforeScopeOpens != null) {
                BeforeScopeOpens.Invoke(scope, context);
            }

            context.Scopes.Push(scope);
            scope.Open(context.Analyzer);

            if (AfterScopeOpens != null) {
                AfterScopeOpens.Invoke(scope, context);
            }
        }
开发者ID:tmont,项目名称:butterfly,代码行数:13,代码来源:ScopeDrivenStrategy.cs


示例19: DoExecute

        protected override sealed void DoExecute(ParseContext context)
        {
            var peek = context.Input.Peek();
            var functionNameBuilder = new StringBuilder();
            while (peek != ButterflyStringReader.NoValue && peek != '|' && peek != ']') {
                functionNameBuilder.Append((char)context.Input.Read());
                peek = context.Input.Peek();
            }

            var closer = context.Input.Read(); //| or ]
            var name = functionNameBuilder.ToString();

            var data = new Dictionary<string, string>();

            if (closer != ']') {
                //read module options
                peek = context.Input.Peek();

                var optionStringBuilder = new StringBuilder();
                while (peek != ButterflyStringReader.NoValue) {
                    if (peek == ']') {
                        context.Input.Read();
                        if (context.Input.Peek() != ']') {
                            //module closer
                            break;
                        }

                        //fallthrough: output a literal "]"
                    } else if (peek == '|') {
                        context.Input.Read();
                        if (context.Input.Peek() != '|') {
                            ParseOptions(optionStringBuilder.ToString(), data);
                            optionStringBuilder.Clear();
                        }

                        //fallthrough: output a literal "|"
                    }

                    optionStringBuilder.Append((char)context.Input.Read());
                    peek = context.Input.Peek();
                }

                //handle the last option
                if (optionStringBuilder.Length > 0) {
                    ParseOptions(optionStringBuilder.ToString(), data);
                }
            }

            context.UpdateCurrentChar();
            OpenAndCloseScope(CreateScope(name, data, context), context);
        }
开发者ID:tmont,项目名称:butterfly,代码行数:51,代码来源:FunctionalStrategy.cs


示例20: GetListItem

        protected override ListItemScope GetListItem(ParseContext context)
        {
            var lastNode = context.ScopeTree.GetMostRecentNode(context.Scopes.Count);
            if (lastNode == null || !(lastNode.Scope is ListItemScope)) {
            #if DEBUG
                //this shouldn't ever happen if the list parsing is performed correctly
                throw new InvalidOperationException("Encountered list with no list items");
            #else
                return new ListItemScope(1);
            #endif
            }

            return (ListItemScope)lastNode.Scope;
        }
开发者ID:tmont,项目名称:butterfly,代码行数:14,代码来源:ListClosingStrategy.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ParseItem类代码示例发布时间:2022-05-24
下一篇:
C# Parse类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap