protected override void HandleSaveRequest(StructureParser parser, StructureParser.AutofillTargetId query) { var intent = new Intent(this, typeof(SelectCurrentDbActivity)); intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTop | ActivityFlags.SingleTop); Dictionary <string, string> outputFields = new Dictionary <string, string>(); foreach (var p in parser.ClientFormData.HintMap) { CommonUtil.logd(p.Key + " = " + p.Value.ValueToString()); outputFields.TryAdd(ChooseForAutofillActivity.GetKp2aKeyFromHint(p.Key), p.Value.ValueToString()); } if (query != null) { outputFields.TryAdd(PwDefs.UrlField, query.WebDomain); } JSONObject jsonOutput = new JSONObject(outputFields); var jsonOutputStr = jsonOutput.ToString(); intent.PutExtra(Strings.ExtraEntryOutputData, jsonOutputStr); JSONArray jsonProtectedFields = new JSONArray( (System.Collections.ICollection) new string[] {}); intent.PutExtra(Strings.ExtraProtectedFieldsList, jsonProtectedFields.ToString()); intent.PutExtra(AppTask.AppTaskKey, "CreateEntryThenCloseTask"); intent.PutExtra(CreateEntryThenCloseTask.ShowUserNotificationsKey, "false"); StartActivity(intent); }
private static void Generate(string file) { var header = new Header { version = 1, type = "type1" }; var records = new TradeRecord[64]; for (var i = 0; i < records.Length; i++) { records[i] = new TradeRecord { account = i + 1, id = i, volume = i * 10d, comment = "comment" + i }; } var bytes = StructureParser.Serialize(header, records); File.WriteAllBytes(file, bytes); Console.WriteLine("Test binary file is generated!"); Console.WriteLine("Please copy to server in temparery folder and put file name with '-u' command"); }
public void TestMethod_01() { var header = new Header { version = 1, type = "type1" }; var records = new TradeRecord[64]; for (var i = 0; i < records.Length; i++) { records[i] = new TradeRecord { account = i + 1, id = i, volume = i * 10d, comment = "comment" + i }; } var bytes = StructureParser.Serialize(header, records); Assert.AreNotEqual(bytes.Length, 0, "Bad encoded"); File.WriteAllBytes(BIN_FILE, bytes); }
public void TestMethod_02() { var bytes = File.ReadAllBytes(BIN_FILE); var myDataStruct1 = StructureParser.Deserialize(bytes); var bytes1 = StructureParser.Serialize(myDataStruct1.Item1, myDataStruct1.Item2); Assert.IsTrue(bytes.SequenceEqual(bytes1), "Bad decoded"); }
public object TryParse(string query) { if (query.Length > SuffixString.Length && query.EndsWith(SuffixString)) { var remainderString = query.Substring(0, query.Length - SuffixString.Length); var parsedRemainder = StructureParser.Parse(remainderString); return(new Suffix(SuffixString, remainderString, parsedRemainder)); } return(null); }
public CompileError Parse() { CompileError error; StartMeasureTime(); Source.ProceedModuleNames(IncludeDirectories); var source = Source.GetSource(out error); if (error != null) { return(error); } EndMeasureTime(ElapsedTimeType.SourceReading); List <Token> tokens; try { StartMeasureTime(); tokens = Tokenizer.Tokenize(source, Source.FileName, this); if (Verbose) { Console.WriteLine(string.Join("\n", tokens)); } EndMeasureTime(ElapsedTimeType.Tokenizing); } catch (CompileException ex) { return(ex.ToError()); } StartMeasureTime(); Lexemes = Lexemizer.Lexemize(tokens, out error, Verbose, PrototypesOnly); EndMeasureTime(ElapsedTimeType.Lexemizing); if (error != null) { return(error); } StartMeasureTime(); if ((error = StructureParser.Parse(this, PrototypesOnly)) != null) { return(error); } EndMeasureTime(ElapsedTimeType.StructureParsing); return(null); }
private void button1_Click(object sender, EventArgs e) { StructureParser parser = new StructureParser(this.richTextBox1.Text); StructureTree root = parser.Parse(); MetaModel metamodel = root.Build(); MetaTemplateConverter converter = new MetaTemplateConverter(); TemplateContainer container = converter.Convert(metamodel); string template = "Domains:\n========\n[%foreach(domain in Domains)%]\n Id: [%domain.Id%]\n Name: [%domain.Name%]\n IsIdentity: [%domain.IsIdentity%]\n DataType: [%domain.DataType%]\n Length: [%domain.DataTypeLength%]\n Decimals: [%domain.DataTypeDecimals%]\n[%end%]\n"; template += "Tables:\n=======\n[%foreach(table in Tables)%]\n Id: [%table.Id%]\n Name: [%table.Name%]\n LogicalName: [%table.LogicalName%]\n PhysicalName: [%table.PhysicalName%]\n [\n[%foreach(column in table.Columns)%] TableId: [%column.TableId%]\n Ix: [%column.Ix%]\n Name: [%column.Name%]\n LogicalName: [%column.LogicalName%]\n PhysicalName: [%column.PhysicalName%]\n IsPrimaryKey: [%column.IsPrimaryKey%]\n IsNullable: [%column.IsNullable%]\n IsIdentity: [%column.IsIdentity%]\n DataType: [%column.DataType%]\n Length: [%column.DataTypeLength%]\n Decimals: [%column.DataTypeDecimals%]\n IsForeignKey: [%column.IsForeignKey%]\n [%end%]\n][%end%]\n"; template = TemplateTransformer.Transform(template); template = JavascriptEvaluator.ReplaceString(template, container); this.richTextBox2.Text = template; }
public object TryParse(string query) { var trimmed = query.Trim(); int openParen = trimmed.IndexOf('('); int closeParen = trimmed.LastIndexOf(')'); if (openParen > 0 && closeParen == trimmed.Length - 1) { var argumentListString = trimmed.Substring(openParen + 1, closeParen - openParen - 1); var argumentListParsed = StructureParser.Parse(argumentListString); var prefix = trimmed.Substring(0, openParen).TrimEnd(); return(new Invocation(prefix, argumentListString, argumentListParsed)); } return(null); }
public object TryParse(string query) { var index = query.IndexOf(OperatorText); if (index < 1 || index == query.Length - OperatorText.Length) { return(null); } LeftString = query.Substring(0, index); RightString = query.Substring(index + OperatorText.Length, query.Length - index - OperatorText.Length); var left = StructureParser.Parse(LeftString); var right = StructureParser.Parse(RightString); if (left != null && right != null) { return(new InfixOperator(LeftString, left, OperatorText, RightString, right)); } return(null); }
public void SetUp() { Configuration = CodeGeneratorConfiguration.Create().MediaTypes; Parser = new StructureParser(Configuration); ContentType = new MediaType(); }
public void foo(string s) { var parser = new StructureParser(); var result = parser.Parse(new TextParser(0, s)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); string requestedUrl = Intent.GetStringExtra(ChooseForAutofillActivityBase.ExtraQueryString); if (requestedUrl == null) { Toast.MakeText(this, "Cannot execute query for null.", ToastLength.Long).Show(); RestartApp(); return; } var prefs = PreferenceManager.GetDefaultSharedPreferences(this); bool isDisable = Intent.GetBooleanExtra(ExtraIsDisable, true); var disabledValues = prefs.GetStringSet("AutoFillDisabledQueries", new HashSet <string>() { }).ToHashSet(); if (isDisable) { disabledValues.Add(requestedUrl); } else { disabledValues.Remove(requestedUrl); } prefs.Edit().PutStringSet("AutoFillDisabledQueries", disabledValues).Commit(); bool isManual = Intent.GetBooleanExtra(ChooseForAutofillActivityBase.ExtraIsManualRequest, false); Intent reply = new Intent(); FillResponse.Builder builder = new FillResponse.Builder(); AssistStructure structure = (AssistStructure)Intent.GetParcelableExtra(AutofillManager.ExtraAssistStructure); StructureParser parser = new StructureParser(this, structure); try { parser.ParseForFill(isManual); } catch (Java.Lang.SecurityException e) { Log.Warn(CommonUtil.Tag, "Security exception handling request"); SetResult(Result.Canceled); return; } try { reply.PutExtra(AutofillManager.ExtraAuthenticationResult, (FillResponse)null); } catch (Exception e) { Kp2aLog.LogUnexpectedError(e); throw; } SetResult(Result.Ok, reply); Finish(); }
public bool Post([FromBody] string file) { var filePath = Path.Combine(Environment.CurrentDirectory, "Upload", file); if (!File.Exists(filePath)) { throw new AppException("File '" + file + "' is not found"); } //read buffer var buffer = File.ReadAllBytes(filePath); var model = StructureParser.Deserialize(buffer).AsModel(); //check unique version var ent = _vRepository.Find(a => a.Version == model.Version); var isNew = false; //if null if (ent == null) { isNew = true; ent = new HeaderModel { Type = model.Type, Version = model.Version }; } else { //also update ent.Type = model.Type; ent.Version = model.Version; } //migrate exists trader records foreach (var record in model.TradeRecords) { var trader = ent.TradeRecords.FirstOrDefault(a => a.Id == record.Id); if (trader == null) { trader = new TradeRecordModel { Id = record.Id, Volumne = record.Volumne, Account = record.Account, Comment = record.Comment }; ent.TradeRecords.Add(trader); } else { trader.Volumne = record.Volumne; trader.Account = record.Account; trader.Comment = record.Comment; } } //add if (isNew) { _vRepository.Add(ent); } else { //edit _vRepository.Edit(ent); } return(_vRepository.Save() > 0); }