so this is ridiculous
-
from the why isn't there a better way department:
var l = GetProperty("videos", (IList)null);
return Tmdb.FromJsonArray(l, (d) => new TmdbVideo(d));all that lambda is for is to call the appropriate constructor.
internal static T[] FromJsonArray(IList array,Func,T> creator)
{
if (null == array)
return null;
var result = new T[array.Count];
for(var i = 0;i;
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.
-
from the why isn't there a better way department:
var l = GetProperty("videos", (IList)null);
return Tmdb.FromJsonArray(l, (d) => new TmdbVideo(d));all that lambda is for is to call the appropriate constructor.
internal static T[] FromJsonArray(IList array,Func,T> creator)
{
if (null == array)
return null;
var result = new T[array.Count];
for(var i = 0;i;
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.
I agree. The next big language will resolve all this.
-
I agree. The next big language will resolve all this.
what gets me is all the "features" they've added to C# 8 that make it unreadable, but i think this feature is still missing (and would require runtime support)
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.
-
from the why isn't there a better way department:
var l = GetProperty("videos", (IList)null);
return Tmdb.FromJsonArray(l, (d) => new TmdbVideo(d));all that lambda is for is to call the appropriate constructor.
internal static T[] FromJsonArray(IList array,Func,T> creator)
{
if (null == array)
return null;
var result = new T[array.Count];
for(var i = 0;i;
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.
[Shameless plug](https://github.com/superlloyd/Galador.Reflection/blob/97c7ae019818c09b5b612b5cfa902657c8e82ffa/Galador.Reflection.Shared/Registry.cs#L273)! :D And this code use System.Emit for fast constructing! ;P
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
[Shameless plug](https://github.com/superlloyd/Galador.Reflection/blob/97c7ae019818c09b5b612b5cfa902657c8e82ffa/Galador.Reflection.Shared/Registry.cs#L273)! :D And this code use System.Emit for fast constructing! ;P
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
hey thats ... not bad. clever. simple. nice.
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.
-
hey thats ... not bad. clever. simple. nice.
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.
Yeah.. I have been wanting to post an article on that for at least 2 years... getting lazy! :( getting into new hobby at the moment and not having the energy to pursue them all! :O But by all mean, enjoy! :)
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
Yeah.. I have been wanting to post an article on that for at least 2 years... getting lazy! :( getting into new hobby at the moment and not having the energy to pursue them all! :O But by all mean, enjoy! :)
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
Super Lloyd wrote:
getting into new hobby at the moment and not having the energy to pursue them all!
Relatable content. People here think I love parsers, but they're just a hobby horse of mine, and I've flogged them to death so now i'm working on the next thing.
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.
-
Super Lloyd wrote:
getting into new hobby at the moment and not having the energy to pursue them all!
Relatable content. People here think I love parsers, but they're just a hobby horse of mine, and I've flogged them to death so now i'm working on the next thing.
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.
honey the codewitch wrote:
on the next BIG thing
Fixed that for ya! ;P Haha, well done otherwise! :)
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
-
honey the codewitch wrote:
on the next BIG thing
Fixed that for ya! ;P Haha, well done otherwise! :)
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!
It's just frustrating, and one of the many reasons binary generics are inferior to source based templates. Maybe when they get done making the language look like trash they can implement templates in C# Although, i ended up needing to do it this way anyway, it turns out, so i won. :-D
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.
-
It's just frustrating, and one of the many reasons binary generics are inferior to source based templates. Maybe when they get done making the language look like trash they can implement templates in C# Although, i ended up needing to do it this way anyway, it turns out, so i won. :-D
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.
Well.. arguably you can easily have compilation time template using T4. Did it a few times for simple stuff, works quite easily! ;) [Code Generation and T4 Text Templates - Visual Studio | Microsoft Docs](https://docs.microsoft.com/en-us/visualstudio/modeling/code-generation-and-t4-text-templates?view=vs-2019)
A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!