pchalamet / cassandra-sharp

high performance .NET driver for Apache Cassandra
114 stars 41 forks source link

ServiceActivator crashes on selecting constructor #66

Closed justmara closed 11 years ago

justmara commented 11 years ago

lol? multiple public constructors make this code crash.

ConstructorInfo ci = type.GetConstructors().Single();

this fails too if prms does not contain value of type, found in constructor. even if constructor parameter contains default value and is optional ;)

pretty stupid piece of code. it works only in single special condition (single constructor and every parameter has a match in prms array), but does not tries to find matching pattern - simply fails on first try.

pchalamet commented 11 years ago

That's a mini injection of dependencies - and this works for what it is designed for: to be no more than 10 lines long. I do not want to take a dependency on a real IoC for deployment concerns.

It has limitation, sure, but this is not a stupid piece of work. Just try to write your own IoC and you will understand for sure why activation is complex.

Why do you not try to work with rules instead of against? Pretty obvious:

-----Original Message----- From: "justmara" notifications@github.com Sent: ‎29/‎08/‎2013 12:32 To: "pchalamet/cassandra-sharp" cassandra-sharp@noreply.github.com Subject: [cassandra-sharp] ServiceActivator crashes on selecting constructor(#66)

lol? multiple public constructors make this code crash. ConstructorInfo ci = type.GetConstructors().Single(); this fails too if prms does not contain value of type, found in constructor. even if constructor parameter contains default value and is optional ;) pretty stupid piece of code. it works only in single special condition (single constructor and every parameter has a match in prms array), but does not tries to find matching pattern - simply fails on first try. — Reply to this email directly or view it on GitHub.