Skip to content

Instantly share code, notes, and snippets.

@killnine
Created October 29, 2013 15:41
Show Gist options
  • Select an option

  • Save killnine/7217112 to your computer and use it in GitHub Desktop.

Select an option

Save killnine/7217112 to your computer and use it in GitHub Desktop.
private static void FindAndConvertParameter<R, T>(IList<R> parameters, string name, out T value) where R : ApplicationParameterDto
{
value = default(T);
ApplicationParameterDto parameter = ((List<R>) parameters).Find(dto => dto.Name.Trim().ToUpper() == name.Trim().ToUpper());
if (parameter != null && !String.IsNullOrWhiteSpace(parameter.Value))
{
try
{
if (typeof(T).IsEnum)
{
value = (T)Enum.Parse(typeof(T), parameter.Value);
}
...
}
catch(Exception ex)
{
//TODO: Handle issues...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment