public MainWindow() { var tokens = TokenTest.GetTestTokens(); var compiler = new CCompiler(tokens); compiler.Compile(); var compTokens = compiler.GetCompilerTokens(); var ding = true; }
static void Main(string[] args) { var tokens = TokenTest.GetTestTokens(); var compiler = new CCompiler(tokens); compiler.Compile(); var compilerTokens = compiler.GetCompilerTokens(); var symbolTable = compiler.GetSymbolTable(); var virtualMachine = new VVirtualMachine(compilerTokens, symbolTable); virtualMachine.RunCode(); }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" }); // using (UserRepository _repo = new UserRepository()) //{ UserRepository _repo = new UserRepository(); TokenTest user = await _repo.FindUser(context.UserName, context.Password); if (user == null) { context.SetError("invalid_grant", "The user name or password is incorrect."); return; } // } var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim("sub", context.UserName)); identity.AddClaim(new Claim("role", "user")); context.Validated(identity); }
public string GetApiByEnv(int indexEnv) { CurrentEnv = DicEnviroment[indexEnv]; if (indexEnv == 0) // thật { UserApi = TokenProd.Split('/').First(); PassApi = TokenProd.Split('/').Last(); return(ApiProd); } if (indexEnv == 1) // test { UserApi = TokenTest.Split('/').First(); PassApi = TokenTest.Split('/').Last(); return(ApiTest); } if (indexEnv == 2) // dev { UserApi = TokenDev.Split('/').First(); PassApi = TokenDev.Split('/').Last(); return(ApiDev); } return(ApiProd); }
public void TestNextToken() { const string input = @"let five = 5; let ten = 10; let add = fn(x, y) { x + y; }; let result = add(five, ten); !-/*5; 5 < 10 > 5; if (5 < 10) { return true; } else { return false; } 10 == 10; 10 != 9; "; var testArray = new TokenTest[] { new TokenTest(TokenType.LET, "let"), new TokenTest(TokenType.IDENT, "five"), new TokenTest(TokenType.ASSIGN, "="), new TokenTest(TokenType.INT, "5"), new TokenTest(TokenType.SEMICOLON, ";"), new TokenTest(TokenType.LET, "let"), new TokenTest(TokenType.IDENT, "ten"), new TokenTest(TokenType.ASSIGN, "="), new TokenTest(TokenType.INT, "10"), new TokenTest(TokenType.SEMICOLON, ";"), new TokenTest(TokenType.LET, "let"), new TokenTest(TokenType.IDENT, "add"), new TokenTest(TokenType.ASSIGN, "="), new TokenTest(TokenType.FUNCTION, "fn"), new TokenTest(TokenType.LPAREN, "("), new TokenTest(TokenType.IDENT, "x"), new TokenTest(TokenType.COMMA, ","), new TokenTest(TokenType.IDENT, "y"), new TokenTest(TokenType.RPAREN, ")"), new TokenTest(TokenType.LBRACE, "{"), new TokenTest(TokenType.IDENT, "x"), new TokenTest(TokenType.PLUS, "+"), new TokenTest(TokenType.IDENT, "y"), new TokenTest(TokenType.SEMICOLON, ";"), new TokenTest(TokenType.RBRACE, "}"), new TokenTest(TokenType.SEMICOLON, ";"), new TokenTest(TokenType.LET, "let"), new TokenTest(TokenType.IDENT, "result"), new TokenTest(TokenType.ASSIGN, "="), new TokenTest(TokenType.IDENT, "add"), new TokenTest(TokenType.LPAREN, "("), new TokenTest(TokenType.IDENT, "five"), new TokenTest(TokenType.COMMA, ","), new TokenTest(TokenType.IDENT, "ten"), new TokenTest(TokenType.RPAREN, ")"), new TokenTest(TokenType.SEMICOLON, ";"), new TokenTest(TokenType.BANG, "!"), new TokenTest(TokenType.MINUS, "-"), new TokenTest(TokenType.SLASH, "/"), new TokenTest(TokenType.ASTERISK, "*"), new TokenTest(TokenType.INT, "5"), new TokenTest(TokenType.SEMICOLON, ";"), new TokenTest(TokenType.INT, "5"), new TokenTest(TokenType.LT, "<"), new TokenTest(TokenType.INT, "10"), new TokenTest(TokenType.GT, ">"), new TokenTest(TokenType.INT, "5"), new TokenTest(TokenType.SEMICOLON, ";"), new TokenTest(TokenType.IF, "if"), new TokenTest(TokenType.LPAREN, "("), new TokenTest(TokenType.INT, "5"), new TokenTest(TokenType.LT, "<"), new TokenTest(TokenType.INT, "10"), new TokenTest(TokenType.RPAREN, ")"), new TokenTest(TokenType.LBRACE, "{"), new TokenTest(TokenType.RETURN, "return"), new TokenTest(TokenType.TRUE, "true"), new TokenTest(TokenType.SEMICOLON, ";"), new TokenTest(TokenType.RBRACE, "}"), new TokenTest(TokenType.ELSE, "else"), new TokenTest(TokenType.LBRACE, "{"), new TokenTest(TokenType.RETURN, "return"), new TokenTest(TokenType.FALSE, "false"), new TokenTest(TokenType.SEMICOLON, ";"), new TokenTest(TokenType.RBRACE, "}"), new TokenTest(TokenType.INT, "10"), new TokenTest(TokenType.EQ, "=="), new TokenTest(TokenType.INT, "10"), new TokenTest(TokenType.SEMICOLON, ";"), new TokenTest(TokenType.INT, "10"), new TokenTest(TokenType.NOT_EQ, "!="), new TokenTest(TokenType.INT, "9"), new TokenTest(TokenType.SEMICOLON, ";"), new TokenTest(TokenType.EOF, ""), }; Lexer l = new Lexer(input); for (int i = 0; i < testArray.Length; i++) { Token tok = l.NextToken(); Assert.AreEqual(testArray[i].expectedType, tok.Type); Assert.AreEqual(testArray[i].expectedLiteral, tok.Literal); } }
static void Main(string[] args) { string appkey = CommonUtils.GetDataConfig("appkey"); string appsecret = CommonUtils.GetDataConfig("appsecret"); string nickname = CommonUtils.GetDataConfig("nickname"); ChatApiTest chatApi = new ChatApiTest(appkey, appsecret, nickname); Console.WriteLine("------ChatTest-----"); chatApi.testChatApiFrom("hello!!"); chatApi.testChatApiJson("hello!!"); chatApi.testApiChatGeoFrom("113.979399", "22.544891"); chatApi.testApiChatGeoJson("113.979399", "22.544891"); chatApi.testApiSpeechChatStream("../../chat-api/test.amr"); chatApi.testApiSpeechChatData("../../chat-api/test.amr"); Console.WriteLine("------TokenTest-----"); string appChannel = CommonUtils.GetDataConfig("appChannel"); string privateKey = CommonUtils.GetDataConfig("privateKey"); TokenTest token = new TokenTest(); Console.WriteLine(token.testGetToken(appChannel, privateKey)); string apiRefreshToken = CommonUtils.GetDataConfig("apiRefreshToken"); Console.WriteLine(token.testRefreshToken(apiRefreshToken)); string apiToken = CommonUtils.GetDataConfig("apiToken"); Console.WriteLine(token.testDeleteToken(apiToken)); token.testGetToken(appChannel, privateKey); //重新获取 apiToken = CommonUtils.GetDataConfig("apiToken"); apiRefreshToken = CommonUtils.GetDataConfig("apiRefreshToken"); Console.WriteLine("------AccountTest-----"); AccountTest account = new AccountTest(apiToken); string testPhone = CommonUtils.GetDataConfig("testPhone"); Console.WriteLine(account.testCaptchaSms(testPhone)); string defaultPhone = CommonUtils.GetDataConfig("defaultPhone"); string defaultSms = CommonUtils.GetDataConfig("defaultSms"); Console.WriteLine(account.testUserSignIn(defaultPhone, defaultSms)); string userRefreshToken = CommonUtils.GetDataConfig("userRefreshToken"); Console.WriteLine(account.testRefreshToken(userRefreshToken)); string userToken = CommonUtils.GetDataConfig("userToken"); Console.WriteLine(account.testUserSignOut(userToken)); account.testUserSignIn(defaultPhone, defaultSms); //重新登录 userToken = CommonUtils.GetDataConfig("userToken"); Console.WriteLine(account.testUserInfo(userToken)); string businessId = CommonUtils.GetDataConfig("businessId"); Console.WriteLine(account.testAddSubAccount(userToken, businessId)); Console.WriteLine("------OrderTest-----"); OrderTest order = new OrderTest(apiToken, userToken); string orderId = CommonUtils.GetDataConfig("orderId"); Console.WriteLine(order.testGetOneOrder(orderId)); int state = (int)Utils.StateType.CHUPIAOZHONG; string lastId = CommonUtils.GetDataConfig("order_Id"); int pageSize = 30; int orderType = (int)Utils.OrderType.FLIGHT; Console.WriteLine(order.testGetOrderList(state.ToString(), lastId, pageSize.ToString(), orderType.ToString())); Console.WriteLine(order.testDeleteOneOrder(orderId)); Console.WriteLine("------PaymentTest-----"); PaymentTest payment = new PaymentTest(apiToken, userToken); int paymentType = (int)Utils.PaymentType.ALIPAY; Console.WriteLine(payment.testOrderPay(orderId, paymentType)); Console.WriteLine(payment.testOrderPayQR(orderId, paymentType)); Console.WriteLine("------WalletTest-----"); WalletTest Wallet = new WalletTest(apiToken, userToken); Console.WriteLine(Wallet.testGetBalance()); string amount = "1"; string payType = Utils.PayType.ALI_PAY.ToString(); string mode = Utils.PaymentMode.APP.ToString(); Console.WriteLine(Wallet.testWalletRecharge(amount, payType, mode)); Console.ReadKey(); }