Skip to content

Instantly share code, notes, and snippets.

@xivSolutions
Created August 17, 2013 20:38
Show Gist options
  • Save xivSolutions/6258586 to your computer and use it in GitHub Desktop.
Save xivSolutions/6258586 to your computer and use it in GitHub Desktop.
Coding styles used in original Massive vs. alpha revisions
// 1. Coding Style?
// RUBY STYLE Your newer additions seem to take on a Ruby-like (2 space indent) style:
public static void CloneFromObject(this object o, object record) {
var props = o.GetType().GetProperties();
var dictionary = record.ToDictionary();
foreach (var prop in props) {
var propName = prop.Name;
foreach (var key in dictionary.Keys) {
if(key.Equals(propName,StringComparison.InvariantCultureIgnoreCase)){
prop.SetValue(o,dictionary[key]);
}
}
}
}
// The rest of the code seems to have become a mix between the three styles described below:
// STYLE 1 (All opening brackets in-line):
/// <summary>
/// Turns an IDataReader to a Dynamic list of things
/// </summary>
public static List<dynamic> ToExpandoList(this IDataReader rdr) {
var result = new List<dynamic>();
while (rdr.Read()) {
result.Add(rdr.RecordToExpando());
}
return result;
}
// STYLE 2 (opening Brackets in-line except for method opening_ :
/// <summary>
/// Turns an IDataReader to a Dynamic list of things
/// </summary>
public static List<dynamic> ToExpandoList(this IDataReader rdr)
{
var result = new List<dynamic>();
while (rdr.Read()) {
result.Add(rdr.RecordToExpando());
}
return result;
}
// STYLE 3 (all brackets own line):
/// <summary>
/// Turns an IDataReader to a Dynamic list of things
/// </summary>
public static List<dynamic> ToExpandoList(this IDataReader rdr)
{
var result = new List<dynamic>();
while (rdr.Read())
{
result.Add(rdr.RecordToExpando());
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment