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

C# TokenInfo类代码示例

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

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



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

示例1: ParserResult

 public ParserResult(TokenInfo token, bool isSuccessed, LambdaExpression expr, SyntaxException error = null)
 {
     IsSuccessed = isSuccessed;
     Expression = expr;
     Token = token;
     Error = error;
 }
开发者ID:barbarossia,项目名称:ConsoleApplication2,代码行数:7,代码来源:ParserResult.cs


示例2: CreateTextRun

 private static Run CreateTextRun(string code, TokenInfo token)
 {
     var text = code.Substring(token.SourceSpan.Start.Index, token.SourceSpan.Length);
     var result = new Run(text);
     var style = _colorizationStyles.ContainsKey(token.Category) ? _colorizationStyles[token.Category] : _colorizationStyles[TokenCategory.None];
     result.Style = Application.Current.FindResource(style) as Style;
     return result;
 }
开发者ID:jflam,项目名称:repl-lib,代码行数:8,代码来源:Colorizer.cs


示例3: GetChannelInformation

        private ChannelInformations GetChannelInformation(string baseUrl, TokenInfo googleAuthorization, HttpClient httpClient)
        {
            var getChannels = baseUrl + "/channels?part=contentDetails&mine=true";
            var channelResponse = MakeYoutubeGetRequest(googleAuthorization, httpClient, getChannels);
            var channelInformation = new JavaScriptSerializer().Deserialize<ChannelInformations>(channelResponse);

            return channelInformation;
        }
开发者ID:Dudemanword,项目名称:Un-PIece,代码行数:8,代码来源:YoutubeOperations.cs


示例4: MapRuleAction

 private ParserResult MapRuleAction(ParserResult other)
 {
     Type source = Token.SourceType;
     Type target = other.Token.TargetType;
     var invoker = (IInvoker)Utilities.CreateType(typeof(MapGroupInvoker<,>), source, target)
                    .CreateInstance(Expression, other.Expression);
     var expr = invoker.Invoke();
     var token = new TokenInfo(RegisterKeys.MapRule, source, target);
     return new ParserResult(token, true, expr);
 }
开发者ID:barbarossia,项目名称:ConsoleApplication2,代码行数:10,代码来源:ParserResultAction.cs


示例5: IsUnaryOperator

            public static bool IsUnaryOperator(TokenInfo token)
            {
                switch (token.Token)
                {
                    case Token.Plus:
                    case Token.Minus:
                    case Token.Not:
                        return true;
                }

                return false;
            }
开发者ID:robertsundstrom,项目名称:vb-lite-compiler,代码行数:12,代码来源:BasicParser.Helper.cs


示例6: GetPlayListInformation

        private PlayListInformations GetPlayListInformation(ChannelInformations channelInformation, string baseUrl, TokenInfo googleAuthorization, HttpClient httpClient)
        {
            PlayListInformations playlistInformation = new PlayListInformations();
            foreach (var item in channelInformation.items)
            {
                var playlistItemUrl = baseUrl + "/playlistItems?part=snippet&playlistId=" + item.contentDetails.relatedPlaylists.uploads;
                var playlistResponse = MakeYoutubeGetRequest(googleAuthorization, httpClient, playlistItemUrl);
                playlistInformation = new JavaScriptSerializer().Deserialize<PlayListInformations>(playlistResponse);
            }

            return playlistInformation;
        }
开发者ID:Dudemanword,项目名称:Un-PIece,代码行数:12,代码来源:YoutubeOperations.cs


示例7: CreateToken

        /// <summary>
        /// 为客户端创建令牌
        /// </summary>
        /// <returns></returns>
        public string CreateToken()
        {
            string returnStr = "";
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return returnStr;
            }

            //应用程序类型为Web的时候应用程序没有调用此方法的权限
            if (this.App.ApplicationType == (int)ApplicationType.WEB)
            {
                ErrorCode = (int)ErrorType.API_EC_PERMISSION_DENIED;
                return returnStr;
            }

            OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(Config.Passwordkey, Config.Onlinetimeout);
            int olid = oluserinfo.Olid;

            string expires = string.Empty;
            DateTime expireUTCTime;
            TokenInfo token = new TokenInfo();

            if (System.Web.HttpContext.Current.Request.Cookies["dnt"] == null || System.Web.HttpContext.Current.Request.Cookies["dnt"]["expires"] == null)
            {
                token.Token = "";
                if (Format == FormatType.JSON)
                    returnStr = "";
                else
                    returnStr = SerializationHelper.Serialize(token);
                return returnStr;
            }
            expires = System.Web.HttpContext.Current.Request.Cookies["dnt"]["expires"].ToString();
            ShortUserInfo userinfo = Discuz.Forum.Users.GetShortUserInfo(oluserinfo.Userid);
            expireUTCTime = DateTime.Parse(userinfo.Lastvisit).ToUniversalTime().AddSeconds(Convert.ToDouble(expires));
            expires = Utils.ConvertToUnixTimestamp(expireUTCTime).ToString();

            string time = string.Empty;
            if (oluserinfo == null)
                time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            else
                time = DateTime.Parse(oluserinfo.Lastupdatetime).ToString("yyyy-MM-dd HH:mm:ss");

            string authToken = Common.DES.Encode(string.Format("{0},{1},{2}", olid.ToString(), time, expires), this.Secret.Substring(0, 10)).Replace("+", "[");
            token.Token = authToken;
            if (Format == FormatType.JSON)
                returnStr = authToken;
            else
                returnStr = SerializationHelper.Serialize(token);
            return returnStr;

        }
开发者ID:khaliyo,项目名称:DiscuzNT,代码行数:56,代码来源:Auth.cs


示例8: IsArithmeticOperator

            public static bool IsArithmeticOperator(TokenInfo token)
            {
                switch (token.Token)
                {
                    case Token.Plus:
                    case Token.Minus:
                    case Token.Slash:
                    case Token.Star:
                    case Token.Percent:
                    case Token.Mod:
                        return true;
                }

                return false;
            }
开发者ID:robertsundstrom,项目名称:vb-lite-compiler,代码行数:15,代码来源:BasicParser.Helper.cs


示例9: IsBinaryOperator

            public static bool IsBinaryOperator(TokenInfo token)
            {
                switch (token.Token)
                {
                    case Token.Plus:
                    case Token.Minus:
                    case Token.Slash:
                    case Token.Star:
                    case Token.Percent:
                    case Token.LeftAngleBracket:
                    case Token.RightAngleBracket:
                    case Token.Is:
                    case Token.IsNot:
                    case Token.Mod:
                    case Token.Equality:
                    case Token.Inequality:
                    case Token.Period:
                        return true;
                }

                return false;
            }
开发者ID:robertsundstrom,项目名称:vb-lite-compiler,代码行数:22,代码来源:BasicParser.Helper.cs


示例10: Run

        public override bool Run(CommandParameter commandParam, ref string result)
        {
            if (commandParam.AppInfo.ApplicationType == (int)ApplicationType.WEB)
            {
                result = Util.CreateErrorMessage(ErrorType.API_EC_PERMISSION_DENIED, commandParam.ParamList);
                return false;
            }
            TokenInfo token = new TokenInfo();

            if (System.Web.HttpContext.Current.Request.Cookies["dnt"] == null || System.Web.HttpContext.Current.Request.Cookies["dnt"]["expires"] == null)
            {
                token.Token = "";
                result = commandParam.Format == FormatType.JSON ? string.Empty : SerializationHelper.Serialize(token);
                return true;
            }

            OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(commandParam.GeneralConfig.Passwordkey, commandParam.GeneralConfig.Onlinetimeout);
            int olid = oluserinfo.Olid;

            string expires = string.Empty;
            DateTime expireUTCTime;

            expires = System.Web.HttpContext.Current.Request.Cookies["dnt"]["expires"].ToString();
            ShortUserInfo userinfo = Discuz.Forum.Users.GetShortUserInfo(oluserinfo.Userid);
            expireUTCTime = DateTime.Parse(userinfo.Lastvisit).ToUniversalTime().AddSeconds(Convert.ToDouble(expires));
            expires = Utils.ConvertToUnixTimestamp(expireUTCTime).ToString();

            string time = string.Empty;
            if (oluserinfo == null)
                time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            else
                time = DateTime.Parse(oluserinfo.Lastupdatetime).ToString("yyyy-MM-dd HH:mm:ss");

            string authToken = Common.DES.Encode(string.Format("{0},{1},{2}", olid.ToString(), time, expires), commandParam.AppInfo.Secret.Substring(0, 10)).Replace("+", "[");
            token.Token = authToken;
            result = commandParam.Format == FormatType.JSON ? authToken : SerializationHelper.Serialize(token);
            return true;
        }
开发者ID:Vinna,项目名称:DeepInSummer,代码行数:38,代码来源:AuthCommand.cs


示例11: GetVideoList

        public Videos GetVideoList(TokenInfo tokenInfo)
        {
            var httpClient = new HttpClient();
            var baseUrl = "https://www.googleapis.com/youtube/v3";

            var channelInformation = GetChannelInformation(baseUrl, tokenInfo, httpClient);
            var playlistInformation = GetPlayListInformation(channelInformation, baseUrl, tokenInfo, httpClient);

            var video = playlistInformation.items.Select(x => new Video
            {
                Description = x.snippet.description,
                Name = x.snippet.title,
                ThumbnailUrl = x.snippet.thumbnails.high.url,
                VideoUrl = @"http://www.youtube.com/embed/" + x.snippet.resourceId.VideoId,
                PublishedDate = x.snippet.publishedAt
            }).ToList();

            var videos = new Videos
            {
                VideoList = video
            };

            return videos;
        }
开发者ID:Dudemanword,项目名称:Un-PIece,代码行数:24,代码来源:YoutubeOperations.cs


示例12: GetTokenInfoAt

 public int GetTokenInfoAt(TokenInfo[] infos, int col, ref TokenInfo info) {
   for (int i = 0, len = infos.Length; i < len; i++) {
     int start = infos[i].startIndex; // 1-based to zero based.
     int end = infos[i].endIndex; // 1-based to zero based.
     if (i == 0 && start > col)
       return -1;
     if (col >= start && col <= end) {
       info = infos[i];
       return i;
     }
   }
   return -1;
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:13,代码来源:Source.cs


示例13: BeginParse

    internal void BeginParse( int line, int idx, TokenInfo info, ParseReason reason, IVsTextView view, ParseResultHandler callback) {
     
      string text = null;
      if (reason == ParseReason.MemberSelect || reason == ParseReason.MethodTip)
        text = this.GetTextUpToLine( line );
      else if (reason == ParseReason.CompleteWord || reason == ParseReason.QuickInfo)
        text = this.GetTextUpToLine( line+1 );
      else
        text = this.GetTextUpToLine( 0 ); // get all the text.      

      string fname = this.GetFilePath();

      this.service.BeginParse(new ParseRequest(line, idx, info, text, fname, reason, view), callback); 
    }
开发者ID:hesam,项目名称:SketchSharp,代码行数:14,代码来源:Source.cs


示例14: MatchBraces

 public virtual void MatchBraces(IVsTextView textView, int line, int idx, TokenInfo info) {
   this.BeginParse(line, idx, info, ParseReason.HighlightBraces, textView, new ParseResultHandler(this.HandleMatchBracesResponse));
 }
开发者ID:hesam,项目名称:SketchSharp,代码行数:3,代码来源:Source.cs


示例15: ScanInterpolatedStringLiteralTop

 internal void ScanInterpolatedStringLiteralTop(ArrayBuilder<Interpolation> interpolations, bool isVerbatim, ref TokenInfo info, ref SyntaxDiagnosticInfo error, out bool closeQuoteMissing)
 {
     var subScanner = new InterpolatedStringScanner(this, isVerbatim);
     subScanner.ScanInterpolatedStringLiteralTop(interpolations, ref info, out closeQuoteMissing);
     error = subScanner.error;
     info.Text = TextWindow.GetText(false);
 }
开发者ID:RoryVL,项目名称:roslyn,代码行数:7,代码来源:Lexer_StringLiteral.cs


示例16: ScanVerbatimStringLiteral

        private void ScanVerbatimStringLiteral(ref TokenInfo info, bool allowNewlines = true)
        {
            _builder.Length = 0;

            if (TextWindow.PeekChar() == '@' && TextWindow.PeekChar(1) == '"')
            {
                TextWindow.AdvanceChar(2);
                bool done = false;
                char ch;
                _builder.Length = 0;
                while (!done)
                {
                    switch (ch = TextWindow.PeekChar())
                    {
                        case '"':
                            TextWindow.AdvanceChar();
                            if (TextWindow.PeekChar() == '"')
                            {
                                // Doubled quote -- skip & put the single quote in the string
                                TextWindow.AdvanceChar();
                                _builder.Append(ch);
                            }
                            else
                            {
                                done = true;
                            }

                            break;

                        case SlidingTextWindow.InvalidCharacter:
                            if (!TextWindow.IsReallyAtEnd())
                            {
                                goto default;
                            }

                            // Reached the end of the source without finding the end-quote.  Give
                            // an error back at the starting point.
                            this.AddError(ErrorCode.ERR_UnterminatedStringLit);
                            done = true;
                            break;

                        default:
                            if (!allowNewlines && SyntaxFacts.IsNewLine(ch))
                            {
                                this.AddError(ErrorCode.ERR_UnterminatedStringLit);
                                done = true;
                                break;
                            }

                            TextWindow.AdvanceChar();
                            _builder.Append(ch);
                            break;
                    }
                }

                info.Kind = SyntaxKind.StringLiteralToken;
                info.Text = TextWindow.GetText(false);
                info.StringValue = _builder.ToString();
            }
            else
            {
                info.Kind = SyntaxKind.None;
                info.Text = null;
                info.StringValue = null;
            }
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:66,代码来源:Lexer_StringLiteral.cs


示例17: GetLeadingMultiLineStrings

        private int GetLeadingMultiLineStrings(Tokenizer tokenizer, ITextSnapshot snapshot, int firstLine, int currentLine, out int validPrevLine, ref TokenInfo startToken)
        {
            validPrevLine = currentLine;
            int prevLine = currentLine - 1;
            int length = 0;

            while (prevLine >= 0) {
                LineTokenization prevLineTokenization;
                if (!_tokenCache.TryGetTokenization(prevLine, out prevLineTokenization)) {
                    LineTokenization lineTokenizationTemp;
                    int currentLineTemp = _tokenCache.IndexOfPreviousTokenization(firstLine, 0, out lineTokenizationTemp) + 1;
                    object stateTemp = lineTokenizationTemp.State;

                    while (currentLineTemp <= snapshot.LineCount) {
                        if (!_tokenCache.TryGetTokenization(currentLineTemp, out lineTokenizationTemp)) {
                            lineTokenizationTemp = TokenizeLine(tokenizer, snapshot, stateTemp, currentLineTemp);
                            _tokenCache[currentLineTemp] = lineTokenizationTemp;
                        }

                        stateTemp = lineTokenizationTemp.State;
                    }

                    prevLineTokenization = TokenizeLine(tokenizer, snapshot, stateTemp, prevLine);
                    _tokenCache[prevLine] = prevLineTokenization;
                }

                if (prevLineTokenization.Tokens.Length != 0) {
                    if (prevLineTokenization.Tokens[prevLineTokenization.Tokens.Length - 1].Category != TokenCategory.IncompleteMultiLineStringLiteral) {
                        break;
                    }

                    startToken = prevLineTokenization.Tokens[prevLineTokenization.Tokens.Length - 1];
                    length += startToken.SourceSpan.Length;
                }

                validPrevLine = prevLine;
                prevLine--;

                if (prevLineTokenization.Tokens.Length > 1) {
                    // http://pytools.codeplex.com/workitem/749
                    // if there are multiple tokens on this line then our multi-line string
                    // is terminated.
                    break;
                }
            }
            return length;
        }
开发者ID:borota,项目名称:JTVS,代码行数:47,代码来源:JClassifier.cs


示例18: SnapshotSpanToSpan

 private static Span SnapshotSpanToSpan(ITextSnapshot snapshot, TokenInfo token, int lineNumber)
 {
     var line = snapshot.GetLineFromLineNumber(lineNumber);
     var index = line.Start.Position + token.SourceSpan.Start.Column - 1;
     var tokenSpan = new Span(index, token.SourceSpan.Length);
     return tokenSpan;
 }
开发者ID:borota,项目名称:JTVS,代码行数:7,代码来源:JClassifier.cs


示例19: ClassifyToken

        private ClassificationSpan ClassifyToken(SnapshotSpan span, TokenInfo token, int lineNumber)
        {
            IClassificationType classification = null;

            if (token.Category == TokenCategory.Operator) {
                if (token.Trigger == TokenTriggers.MemberSelect) {
                    classification = _provider.DotClassification;
                }
            } else if (token.Category == TokenCategory.Grouping) {
                if (token.Trigger == (TokenTriggers.MatchBraces | TokenTriggers.ParameterStart)) {
                    classification = _provider.OpenGroupingClassification;
                } else if (token.Trigger == (TokenTriggers.MatchBraces | TokenTriggers.ParameterEnd)) {
                    classification = _provider.CloseGroupingClassification;
                }
            } else if (token.Category == TokenCategory.Delimiter) {
                if (token.Trigger == TokenTriggers.ParameterNext) {
                    classification = _provider.CommaClassification;
                }
            }

            if (classification == null) {
                CategoryMap.TryGetValue(token.Category, out classification);
            }

            if (classification != null) {
                var line = span.Snapshot.GetLineFromLineNumber(lineNumber);
                var index = line.Start.Position + token.SourceSpan.Start.Column - 1;
                var tokenSpan = new Span(index, token.SourceSpan.Length);
                var intersection = span.Intersection(tokenSpan);
                if (intersection != null && intersection.Value.Length > 0) {
                    return new ClassificationSpan(new SnapshotSpan(span.Snapshot, tokenSpan), classification);
                }
            }

            return null;
        }
开发者ID:TerabyteX,项目名称:main,代码行数:36,代码来源:DlrClassifier.cs


示例20: LineTokenization

 public LineTokenization(TokenInfo[] tokens, object state) {
     Tokens = tokens;
     State = state;
 }
开发者ID:RussBaz,项目名称:PTVS,代码行数:4,代码来源:TokenCache.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# TokenKind类代码示例发布时间:2022-05-24
下一篇:
C# TokenImpersonationLevel类代码示例发布时间: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