Click here to Skip to main content
15,892,805 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 4:11
mveOriginalGriff2-Sep-19 4:11 
GeneralRe: Tutorials are annoying. Pin
CodeWraith2-Sep-19 4:36
CodeWraith2-Sep-19 4:36 
GeneralWSO CCC OTD 2019-09-02 Pin
OriginalGriff1-Sep-19 21:45
mveOriginalGriff1-Sep-19 21:45 
GeneralRe: WSO CCC OTD 2019-09-02 Pin
Pete O'Hanlon1-Sep-19 21:46
mvePete O'Hanlon1-Sep-19 21:46 
GeneralRe: WSO CCC OTD 2019-09-02 - we have a winner! Pin
OriginalGriff1-Sep-19 21:54
mveOriginalGriff1-Sep-19 21:54 
GeneralRe: WSO CCC OTD 2019-09-02 - we have a winner! Pin
Pete O'Hanlon1-Sep-19 21:56
mvePete O'Hanlon1-Sep-19 21:56 
GeneralRe: WSO CCC OTD 2019-09-02 - we have a winner! Pin
OriginalGriff1-Sep-19 22:02
mveOriginalGriff1-Sep-19 22:02 
Generalso this is ridiculous Pin
honey the codewitch1-Sep-19 18:19
mvahoney the codewitch1-Sep-19 18:19 
from the why isn't there a better way department:

C#
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.

C#
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 19:43
mvePIEBALDconsult1-Sep-19 19:43 
GeneralRe: so this is ridiculous Pin
honey the codewitch1-Sep-19 19:44
mvahoney the codewitch1-Sep-19 19:44 
GeneralRe: so this is ridiculous Pin
Super Lloyd1-Sep-19 22:50
Super Lloyd1-Sep-19 22:50 
GeneralRe: so this is ridiculous Pin
honey the codewitch2-Sep-19 4:00
mvahoney the codewitch2-Sep-19 4:00 
GeneralRe: so this is ridiculous Pin
Super Lloyd2-Sep-19 4:26
Super Lloyd2-Sep-19 4:26 
GeneralRe: so this is ridiculous Pin
honey the codewitch2-Sep-19 4:50
mvahoney the codewitch2-Sep-19 4:50 
GeneralRe: so this is ridiculous Pin
Super Lloyd2-Sep-19 17:22
Super Lloyd2-Sep-19 17:22 
GeneralRe: so this is ridiculous Pin
honey the codewitch2-Sep-19 17:27
mvahoney the codewitch2-Sep-19 17:27 
GeneralRe: so this is ridiculous Pin
Super Lloyd2-Sep-19 18:58
Super Lloyd2-Sep-19 18:58 
GeneralMini CCCs 121 Pin
Tim Deveaux1-Sep-19 18:04
Tim Deveaux1-Sep-19 18:04 
GeneralOil paint! That's it! Pin
CodeWraith1-Sep-19 12:51
CodeWraith1-Sep-19 12:51 
GeneralRe: Oil paint! That's it! Pin
Tim Deveaux1-Sep-19 18:15
Tim Deveaux1-Sep-19 18:15 
GeneralRe: Oil paint! That's it! Pin
CodeWraith1-Sep-19 23:10
CodeWraith1-Sep-19 23:10 
GeneralRe: Oil paint! That's it! Pin
Chris C-B2-Sep-19 1:57
Chris C-B2-Sep-19 1:57 
GeneralRe: Oil paint! That's it! Pin
Mark_Wallace1-Sep-19 19:16
Mark_Wallace1-Sep-19 19:16 
GeneralRe: Oil paint! That's it! Pin
CodeWraith1-Sep-19 23:04
CodeWraith1-Sep-19 23:04 
GeneralRe: Oil paint! That's it! Pin
Mark_Wallace1-Sep-19 23:08
Mark_Wallace1-Sep-19 23: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.