Last active
August 29, 2015 14:06
-
-
Save pdoran/a382e6c373e3b9a02248 to your computer and use it in GitHub Desktop.
This file contains 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
//An outline example | |
public string GetSomethingFromDBAndFormat(Guid id){ | |
var obj = Session.Get<Something>(id); | |
var formatString = GetNameFormat(obj); | |
formatString += GetNamesFromChildren(obj); | |
return formatString; | |
} | |
private string GetNameFormat(Something obj){ | |
var formatString = ""; | |
if(obj!=null && !string.IsNullOrEmpty(obj.Name)) { | |
formatString += string.Format("Name: {0}",obj.Name); | |
} | |
return formatString; | |
} | |
private string GetNamesFromChildren(Something obj){ | |
var formatString = ""; | |
if(obj!=null && obj.Children!=null) { | |
formatString = string.Join(" Child: ", | |
obj.Children.Select(c=> GetNameFormat(c)) | |
); | |
} | |
return formatString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment