Click here to Skip to main content
14,365,441 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: Tutorials are annoying. Pin
OriginalGriff2-Sep-19 5:11
protectorOriginalGriff2-Sep-19 5:11 
GeneralRe: Tutorials are annoying. Pin
CodeWraith2-Sep-19 5:36
memberCodeWraith2-Sep-19 5:36 
GeneralWSO CCC OTD 2019-09-02 Pin
OriginalGriff1-Sep-19 22:45
protectorOriginalGriff1-Sep-19 22:45 
GeneralRe: WSO CCC OTD 2019-09-02 Pin
Pete O'Hanlon1-Sep-19 22:46
protectorPete O'Hanlon1-Sep-19 22:46 
GeneralRe: WSO CCC OTD 2019-09-02 - we have a winner! Pin
OriginalGriff1-Sep-19 22:54
protectorOriginalGriff1-Sep-19 22:54 
GeneralRe: WSO CCC OTD 2019-09-02 - we have a winner! Pin
Pete O'Hanlon1-Sep-19 22:56
protectorPete O'Hanlon1-Sep-19 22:56 
GeneralRe: WSO CCC OTD 2019-09-02 - we have a winner! Pin
OriginalGriff1-Sep-19 23:02
protectorOriginalGriff1-Sep-19 23:02 
Generalso this is ridiculous Pin
honey the codewitch1-Sep-19 19:19
memberhoney the codewitch1-Sep-19 19:19 
from the why isn't there a better way department:

var l = GetProperty("videos", (IList<object>)null);
return Tmdb.FromJsonArray(l, (d) => new TmdbVideo(d));


all that lambda is for is to call the appropriate constructor.

internal static T[] FromJsonArray<T>(IList<object> array,Func<IDictionary<string,object>,T> creator)
{
	if (null == array)
		return null;
	var result = new T[array.Count];
	for(var i = 0;i<result.Length;i++)
	{
		var d = array[i] as IDictionary<string,object>;
		if (null != d)
			result[i] = creator(d);
	}
	return result;
}


Why?

because I can't have a contract - either an interface, a base class, or a template constraint that specifies a certain constructor signature.

This should have been in with .NET 2.0, 3.5 at the latest. That it wasn't in with 4 just floors me, especially seeing as to what the serializer stuff in the dotnet framework has to go through for its constructor requirement.

Reflection? Really? It might even be faster than using a stupid lambda (but probably not)

*headdesk*
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

GeneralRe: so this is ridiculous Pin
PIEBALDconsult1-Sep-19 20:43
protectorPIEBALDconsult1-Sep-19 20:43 
GeneralRe: so this is ridiculous Pin
honey the codewitch1-Sep-19 20:44
memberhoney the codewitch1-Sep-19 20:44 
GeneralRe: so this is ridiculous Pin
Super Lloyd1-Sep-19 23:50
memberSuper Lloyd1-Sep-19 23:50 
GeneralRe: so this is ridiculous Pin
honey the codewitch2-Sep-19 5:00
memberhoney the codewitch2-Sep-19 5:00 
GeneralRe: so this is ridiculous Pin
Super Lloyd2-Sep-19 5:26
memberSuper Lloyd2-Sep-19 5:26 
GeneralRe: so this is ridiculous Pin
honey the codewitch2-Sep-19 5:50
memberhoney the codewitch2-Sep-19 5:50 
GeneralRe: so this is ridiculous Pin
Super Lloyd2-Sep-19 18:22
memberSuper Lloyd2-Sep-19 18:22 
GeneralRe: so this is ridiculous Pin
honey the codewitch2-Sep-19 18:27
memberhoney the codewitch2-Sep-19 18:27 
GeneralRe: so this is ridiculous Pin
Super Lloyd2-Sep-19 19:58
memberSuper Lloyd2-Sep-19 19:58 
GeneralMini CCCs 121 Pin
Tim Deveaux1-Sep-19 19:04
memberTim Deveaux1-Sep-19 19:04 
GeneralOil paint! That's it! Pin
CodeWraith1-Sep-19 13:51
memberCodeWraith1-Sep-19 13:51 
GeneralRe: Oil paint! That's it! Pin
Tim Deveaux1-Sep-19 19:15
memberTim Deveaux1-Sep-19 19:15 
GeneralRe: Oil paint! That's it! Pin
CodeWraith2-Sep-19 0:10
memberCodeWraith2-Sep-19 0:10 
GeneralRe: Oil paint! That's it! Pin
Chris C-B2-Sep-19 2:57
memberChris C-B2-Sep-19 2:57 
GeneralRe: Oil paint! That's it! Pin
Mark_Wallace1-Sep-19 20:16
memberMark_Wallace1-Sep-19 20:16 
GeneralRe: Oil paint! That's it! Pin
CodeWraith2-Sep-19 0:04
memberCodeWraith2-Sep-19 0:04 
GeneralRe: Oil paint! That's it! Pin
Mark_Wallace2-Sep-19 0:08
memberMark_Wallace2-Sep-19 0:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.