var service = new SpreadsheetsService(null); var query = new ListQuery("0AjD5UGMt5CGDdEcwaS10S2IzVzJFNDYtaEo5anN2RHc", "1", "public", "values"); var feed = service.Query(query); var table = new DataTable(); foreach (ListEntry entry in feed.Entries) { var row = table.NewRow(); foreach (ListEntry.Custom element in entry.Elements) { var column = table.Columns[element.LocalName] ?? table.Columns.Add(element.LocalName); row[column] = element.Value; } table.Rows.Add(row); }Google Data API .NET client library
Friday, December 30, 2011
Read a published Google spreadsheet into a DataTable using GData
Saturday, December 17, 2011
Determine if a WinForms control resource file is localized
XPathDocument doc; using (var stream = File.OpenRead(fileName)) { doc = new XPathDocument(stream); } var nav = doc.CreateNavigator(); var itr = nav.Select("root/data[@name = '>>$this.Name']"); var localized = itr.Count > 0;
Remove matching C# region directives using LINQ
var flag = false; var modified = false; var lines = File.ReadLines(fileName) .Where(line => { if ((!flag && line.Contains("#region " + regionName)) || (flag && line.Contains("#endregion"))) { flag = !flag; modified = true; return false; } return true; }) .ToArray(); if (modified) { File.WriteAllLines(fileName, lines); }
Thursday, December 8, 2011
Compile and execute a stateful T4 template using Mono.TextTemplating
var input = "<#@ template language=\"C#\" debug=\"true\" #>" + "<#+ static int num; #>" + "<#= num++ #>"; var generator = new TemplateGenerator(); var compiled = generator.CompileTemplate(input); Debug.Assert(Equals(compiled.Process(), "0")); Debug.Assert(Equals(compiled.Process(), "1")); Debug.Assert(Equals(compiled.Process(), "2"));Mono.TextTemplating
Subscribe to:
Posts (Atom)