This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //IEnumerable<KeyValuePair<string, string>> serializedParameters | |
| // Do this instead of using FormUrlEncodedContent as it only supports url escaping of strings shorter than 30,000 (or 60,000) | |
| // Would use MultipartFormDataContent but Esri doesn't look like it accepts that | |
| var pars = string.Join("&", serializedParameters.Select(p => p.Key + "=" + Encode(p.Value))); | |
| var content = new ByteArrayContent(Encoding.ASCII.GetBytes(pars)); | |
| content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); | |
| var message = await client.PostAsync(url, content); | |
| return await message.Content.ReadAsStringAsync(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Lazy<int> _lazy; | |
| void Main() | |
| { | |
| _lazy = new Lazy<int>(CreateInt); | |
| for(int x = 0; x < 10; x++) | |
| { | |
| new Thread(Run).Start(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ObjectSettingsReader : ISettingsReader | |
| { | |
| private readonly Dictionary<string, string> _values; | |
| public ObjectSettingsReader(object obj) | |
| { | |
| var q = from p in obj.GetType().GetProperties() | |
| where p.CanRead | |
| let v = "" + p.GetValue(obj) | |
| where v != "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Psudo C# | |
| public class Program(IDb db) | |
| { | |
| _db = db; | |
| void Main() | |
| { | |
| var results = _db.Query(new FooQuery().From(DateTime.Today).ForUser("doe")); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let initField x y s = | |
| match (x,y) with | |
| | (1,1) | (1, 2) | (1,3) -> true | |
| | _ -> false | |
| let valueAt (f:bool[,]) c = | |
| match c with | |
| | (x,y) when x < 0 -> false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using (Timeline.Capture("FormulaEvaluator.Evalauate")) | |
| { | |
| // Code to time | |
| } | |
| public static class Timeline | |
| { | |
| public static IDisposable Capture(string eventName) | |
| { | |
| #pragma warning disable 618 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CombiningSettingsReader : ISettingsReader | |
| { | |
| private readonly ISettingsReader[] _settingsReaders; | |
| public CombiningSettingsReader(params ISettingsReader[] settingsReaders) | |
| { | |
| _settingsReaders = settingsReaders; | |
| } | |
| public string ReadValue(string key) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Main() | |
| { | |
| var propertyInfo = typeof(A).GetProperty("Foo"); | |
| var lambda = Get<A>(propertyInfo); | |
| lambda.Compile()(new A()).Dump(); | |
| } | |
| public Expression<Func<T, int>> Get<T>(PropertyInfo propertyInfo) | |
| { | |
| ParameterExpression entity = Expression.Parameter(typeof (A), "e"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace IBM | |
| { | |
| public class DeepThought | |
| { | |
| private static void Main(string[] args) | |
| { | |
| new DeepThought("What is the answer to life, the universe and everything?"); | |
| } | |
| private DeepThought(Setting<QuestionConfigurationSetting, string> question) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace IBM | |
| { | |
| public class DeepThought | |
| { | |
| private static void Main(string[] args) | |
| { | |
| new DeepThought("What is the answer to life, the universe and everything?"); | |
| } | |
| private DeepThought(Setting<QuestionConfigurationSetting, string> question) |