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


C# Token.ToString方法代码示例

本文整理汇总了C#中Token.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Token.ToString方法的具体用法?C# Token.ToString怎么用?C# Token.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Token的用法示例。


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

示例1: TokenToStringTest

 public void TokenToStringTest()
 {
     var t1 = new Token { TokenStart = 10, TokenEnd = 20, Content = "1234" };
     var expected = "10-20: 1234";
     var actual = t1.ToString();
     Assert.AreEqual(expected, actual);
 }
开发者ID:rwindegger,项目名称:TextAnalysisPlayground,代码行数:7,代码来源:TokenTests.cs

示例2: SimpleCreateToken

 public void SimpleCreateToken()
 {
     var token = new Token(new Substring("Hello", 0, 2));
     token.Contents.ToString().Should().Be("He");
     token.StartsWithQuote.Should().BeFalse();
     token.EndsWithQuote.Should().BeFalse();
     token.ToString().Should().Be("He");
     token.InnerLength.Should().Be(2);
     token.InnerStartingOffset.Should().Be(0);
     token.InnerEndingOffset.Should().Be(2);
     token.OuterLength.Should().Be(2);
     token.OuterStartingOffset.Should().Be(0);
     token.OuterEndingOffset.Should().Be(2);
 }
开发者ID:reubeno,项目名称:NClap,代码行数:14,代码来源:TokenTests.cs

示例3: TokenWithQuotes

 public void TokenWithQuotes()
 {
     var token = new Token(new Substring("Hi \"a b\" there", 4, 3), true, true);
     token.Contents.ToString().Should().Be("a b");
     token.StartsWithQuote.Should().BeTrue();
     token.EndsWithQuote.Should().BeTrue();
     token.ToString().Should().Be("a b");
     token.InnerLength.Should().Be(3);
     token.InnerStartingOffset.Should().Be(4);
     token.InnerEndingOffset.Should().Be(7);
     token.OuterLength.Should().Be(5);
     token.OuterStartingOffset.Should().Be(3);
     token.OuterEndingOffset.Should().Be(8);
 }
开发者ID:reubeno,项目名称:NClap,代码行数:14,代码来源:TokenTests.cs

示例4: AddCommand

        public void AddCommand(Token token, Command command)
        {
            this.Context.Application.Lock();
            Commands commands = (Commands)this.Context.Application["Commands"];
            this.Context.Application.UnLock();

            //Do AddCommand
            commands.Add(token, command);

            //Log
            string isDebug = System.Configuration.ConfigurationSettings.AppSettings["IsDebug"];
            if (isDebug != null && Convert.ToBoolean(isDebug))
            {
                string logCommands = System.Configuration.ConfigurationSettings.AppSettings["LogCommands"];
                if (logCommands != null && (logCommands == "*" || logCommands.IndexOf(command.GetType().Name) > -1))
                {
                    iExchange.Common.AppDebug.LogEvent("DealingConsole.Service2.AddCommand", token.ToString() + "\n" + command.ToString(), System.Diagnostics.EventLogEntryType.Warning);
                }
            }
        }
开发者ID:BlueSky007,项目名称:DemoDealingConsole,代码行数:20,代码来源:Service2.asmx.cs

示例5: CreateErrorExpectedToken

 private Exception CreateErrorExpectedToken(Token token)
 {
     string expected = lex.GetTokenString(token);
     if (expected == null)
     {
         expected = token.ToString();
     }
     return CreateErrorExpected(expected);
 }
开发者ID:helgihaf,项目名称:Alpha,代码行数:9,代码来源:ExpressionParser.cs

示例6: KickReadyToken

        /// <summary>
        /// Kick a 'READY' token. It means-> initiate all tasks following current place - only if the tasks can be initiated.
        /// </summary>
        /// <param name="tok"></param>
        protected void KickReadyToken(Token tok)
        {
            if (!_activated) throw new Exception("Process instance not activated");
            log.Info("Kicking token {0}", tok.ToString());
            if (_tokens[tok.TokenId] != tok) throw new Exception("invalid token");
            if (tok.Status != TokenStatus.READY) throw new Exception("invalid status");

            Place pl = Definition.GetPlace(tok.PlaceId);
            if (pl is EndPlace)
            {
                Debug.Assert(pl == Definition.Finish);
                OnEndPlaceReached(tok);
                return;
            }
            IList<Token> toks = GetConsumableTokensInPlace(tok.PlaceId);
            //Strategy 1: if there are enabled transition (that is, tokens in WAITING_TASK state),
            //do nothing and put the token in WAITING state. So actually we will be waiting for the transition
            //to fire before enabling other transitions
            foreach (Token tok1 in toks)
            {
                if (tok1.Status == TokenStatus.LOCKED_ENABLED)
                {
                    log.Info("There are active transitions in this place. Putting token in WAITING state");
                    tok.Status = TokenStatus.WAITING;
                    return;
                }
            }
            //Strategy 2: it's up to system to decide which tokens are selected when the transition fires.
            //so any combination of tokens that enables the transition is good.
            //However, each enabled transition results in a task being created, and we don't want to create
            //a task for each combination of tokens for the transition. Therefore we will select only these
            //tokens that were not used for enabling the same transition
            //With this algorithm, we create separate groups of tokens that enable particular transition,
            //and we enable the transition as many times as there are unallocated tokens left.

            //procedura enablowania tranzycji
            //jesli mamy 1 token, to nie moze byc enabled transition
            //jesli mamy > 1 token, to niektore moga byc enabled
            //jesli mamy 1 wyjscie, to nie ma problemu
            //jesli mamy > 1 wyjscie, to trzeba to jakos podzielic
            //najwazniejsze ze tranzycja nie rozroznia tokenow!!! (nie ma input condition) - sztuka to sztuka
            //jak dojdzie nowy token, to na pewno nie odpala tranzycje inne niz te co juz sa
            //tak, o ile mamy symetrie
            //Na razie zrobmy tak, ze o ile transition jest enabled to nie mozna juz enablowac innych dopoki poprzednia
            //nie odpali
            //wersja pe³na
            //wchodzi token. Dla kazdego wychodzacego tasku:
            //  nEn = ile task ma enabled tranzycji.
            //  sprawdz, czy task mozna enablowac, ale przy zalozeniu ze nie bierzemy tokenow z tranzycji dla tego tasku
            //  ktore juz sa enablowane
            IList<TaskShell> newAts = new List<TaskShell>();

            foreach (Task tsk in pl.NodesOut)
            {
                //1. calculating set of tokens that were used for enabling tsk
                //   so we don't use them for enabling next instance of it
                IDictionary<string, string> tokDict = new Dictionary<string, string>();
                IList<TaskShell> taskTransitions = GetActiveInstancesOfTask(tsk.Id);
                foreach (TaskShell at in taskTransitions)
                {
                    foreach (string tid in at.Tokens)
                    {
                        if (!tokDict.ContainsKey(tid)) tokDict[tid] = tid;
                    }
                }

                IList<Token> enablingTokens = null;
                //ok, now let's check if transition can be enabled without using tokens from the tokDict
                bool b = CanEnableTransition(tsk, tokDict, out enablingTokens);

                log.Info("Checking if transition {0} can be initiated: {1}", tsk.Id, b);

                if (b)
                {
                    TaskShell at = CreateActiveTransitionForTask(tsk);
                    foreach (Token t in enablingTokens)
                    {
                        at.Tokens.Add(t.TokenId);
                    }

                    if (tsk.IsImmediate)
                    {
                        log.Info("Task {0} is immediate. Will start it now.", tsk.Id);
                        newAts.Clear();
                        newAts.Add(at);
                        break; //leave the loop
                    }
                    else
                    {
                        newAts.Add(at);
                    }
                }
            }

            if (newAts.Count == 0)
            {
//.........这里部分代码省略.........
开发者ID:alasdairhurst,项目名称:nginn,代码行数:101,代码来源:ProcessInstance_TaskShell.cs

示例7: _tokenizeException

 private Exception _tokenizeException(string message, char[] json, int index, Token token) {
    var k = index + 1;
    _skipWhitespace(json, ref k);
    var str = new string(json, 0, Math.Min(k, json.Length));
    var lines = str.Split(_reNewline);
    int ln = lines.Length;
    var cl = ln > 0 ? lines[ln - 1].Length : 0;
    var where = "line " + ln + ", position " + cl;
    message = message.ReplaceFirst("{where}", where);
    if (token != Token.None) {
       var tk = token.ToString().ToLower();
       switch (token) {
          case Token.CurlyOpen: tk = "'{'"; break;
          case Token.CurlyClose: tk = "'}'"; break;
          case Token.SquaredOpen: tk = "'['"; break;
          case Token.SquaredClose: tk = "']'"; break;
          case Token.Colon: tk = "':'"; break;
          case Token.Comma: tk = "','"; break;
       }
       tk += " token";
       message = message.ReplaceFirst("{token}", tk);
    }
    throw new ApplicationException("JSON parsing error. " + message);
 }
开发者ID:borkaborka,项目名称:gmit,代码行数:24,代码来源:BplJsonParser.cs

示例8: op_GetHashCode

        public void op_GetHashCode()
        {
            var obj = new Token("Example");

            var expected = obj.ToString().GetHashCode();
            var actual = obj.GetHashCode();

            Assert.Equal(expected, actual);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:9,代码来源:Token.Facts.cs

示例9: UseToken

            private void UseToken(Token t)
            {
                // Store the value depending on token's type
                switch (t.type) {
                case TokenType.Number:

                    value = new Value (float.Parse (t.value as String));

                    break;
                case TokenType.String:

                    value = new Value (t.value as String);
                    break;

                case TokenType.False:

                    value = new Value (false);

                    break;
                case TokenType.True:

                    value = new Value (true);

                    break;
                case TokenType.Variable:
                    value = new Value ();
                    value.type = Value.Type.Variable;
                    value.variableName = t.value as String;
                    break;
                case TokenType.Null:
                    value = Value.NULL;
                    break;
                default:
                    throw ParseException.Make (t, "Invalid token type " + t.ToString ());
                }
            }
开发者ID:thesecretlab,项目名称:YarnSpinner,代码行数:36,代码来源:Parser.cs

示例10: HandleObjectEnd

        private void HandleObjectEnd(Token token)
        {
            stack.Pop();
            if (stack.Count == 0)
            {
                CurrentElement = FudgeStreamElement.MessageEnd;
            }
            else
            {
                CurrentElement = FudgeStreamElement.SubmessageFieldEnd;

                var top = stack.Peek();
                if (top.IsInArray)
                {
                    SkipCommaPostValue(token.ToString());
                }
            }
        }
开发者ID:t0rx,项目名称:Fudge-CSharp,代码行数:18,代码来源:FudgeJSONStreamReader.cs

示例11: AssertNext

 /// <summary>
 /// 次に出現するトークンが特定の種類であることを確認し、読みます。<para />
 /// 読めなかった場合はリワインドします。
 /// </summary>
 /// <param name="reader">トークン リーダー</param>
 /// <param name="type">トークンの種類</param>
 private static Token AssertNext(ref TokenReader reader, Token.TokenType type)
 {
     if (!reader.IsRemainToken)
         reader.PushError("クエリが解析の途中で終了しました。" +
             "ここには " + type.ToString() + " が存在しなければなりません。");
     var ntoken = reader.Get();
     if (ntoken.Type != type)
     {
         reader.PushError("不明な文字です: " + reader.LookAhead() + " (インデックス:" + reader.LookAhead().DebugIndex + ")" +
             "ここには " + type.ToString() + " が存在しなければなりません。");
         return new Token() { Type = type, Value = null, DebugIndex = -1 };
     }
     return ntoken;
 }
开发者ID:sor593,项目名称:Mystique,代码行数:20,代码来源:QueryCompiler.cs

示例12: E_UnexpectedToken

 // Perhaps the most general syntax error
 // We don't know what we wanted, but we didn't like what we got
 //protected void ThrowError_UnexpectedToken(Token tokenActual)
 ParserErrorException E_UnexpectedToken(Token tokenActual)
 {
     return new ParserErrorException(        
         Code.cUnexpectedToken, 
         tokenActual.Location,
         "Unexpected token '"+tokenActual.ToString() + "'"
     );    
 }
开发者ID:chenzuo,项目名称:blue,代码行数:11,代码来源:Parser.cs

示例13: CompareExpression

 /// <summary>
 /// constructor of an expression
 /// </summary>
 /// <param name="operation"></param>
 /// <param name="leftoperand"></param>
 /// <param name="rightoperand"></param>
 public CompareExpression(Token op, IExpression leftoperand, IExpression rightoperand, Engine engine = null)
     : base(op, leftoperand, rightoperand, engine)
 {
     if (this.Operator.Type != otOperatorType.Logical && this.Operator.Type != otOperatorType.Compare)
         throw new RulezException(RulezException.Types.OperatorTypeNotExpected, arguments: new object[] { op.ToString(), "compare" });
     this.NodeType = otXPTNodeType.CompareExpression;
 }
开发者ID:boschn,项目名称:otRulez,代码行数:13,代码来源:rulezXPTree.cs

示例14: HandleValue

        private void HandleValue(Token token)
        {
            if (token.IsSimpleValue)
            {
                HandleSimpleValue(token);
                SkipCommaPostValue(token.ToString());
            }
            else if (token == Token.BeginObject)
            {
                stack.Push(State.InObject);
                CurrentElement = FudgeStreamElement.SubmessageFieldStart;
            }
            else if (token == Token.BeginArray)
            {
                stack.Push(new State(FieldName));

                // Recurse to deal with real value
                HandleValue(GetNextToken());
            }
            else
                throw new FudgeParseException("Unexpected token \"" + token + "\" in JSON stream when looking for a value");
        }
开发者ID:jmptrader,项目名称:Fudge-CSharp,代码行数:22,代码来源:FudgeJSONStreamReader.cs

示例15: OperationExpression

        /// <summary>
        /// constructor of an expression
        /// </summary>
        /// <param name="operation"></param>
        /// <param name="leftoperand"></param>
        /// <param name="rightoperand"></param>
        public OperationExpression( Token token, INode leftoperand, INode rightoperand, Engine engine = null)
            : base()
        {
            // default engine
            if (engine == null) engine = OnTrack.Rules.Engine;

            if (OnTrack.Rules.Engine.GetOperator(token) == null )
                throw new RulezException(RulezException.Types.OperatorNotDefined,arguments:new object[]{ token.ToString() });

            _token = token;

            if (this.Operator.Arguments != 2)
                throw new RulezException(RulezException.Types.OperandsNotEqualOperatorDefinition, arguments: new object[] { token.ToString(), this.Operator.Arguments, 2 });

            if (leftoperand != null) this.Nodes.Add(leftoperand);
            else throw new RulezException(RulezException.Types.OperandNull, arguments: new object[] { token.ToString(), "left" });

            if (rightoperand != null) this.Nodes.Add(rightoperand);
            else throw new RulezException(RulezException.Types.OperandNull, arguments: new object[] { token.ToString(), "right" });

            _engine = engine;
            this.NodeType = otXPTNodeType.OperationExpression;
        }
开发者ID:boschn,项目名称:otRulez,代码行数:29,代码来源:rulezXPTree.cs


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