|
This whole discussion seems to be arguing for C/C++ macros (albeit in a limited context).
|
|
|
|
|
The fact that you're trying to shoehorn items like validation in on the item does tend to indicate that the item should probably be encapsulated. I know that we all tend to let things like this through, but the idea that we've moved from having a simple value to something that has actual logic does suggest that we should be encapsulating that item (if we adopt a pure SOLID approach). Yes, there would be an additional level of indirection in the code, but the actual logic of the change would be encapsulated. I give an example of an Age class above to illustrate my point.
|
|
|
|
|
I do see the point but I think that when your validation is range checking or something equally simple it's overkill to create a class for it. Every class increases the complexity of the system and makes it harder to understand, and creating a whole class for a single if condition is adding (imo) more confusion than having the validation in place.
|
|
|
|
|
In this particular case, I really wish that .NET provided AOP as a first class citizen. A lot of this would go away if we could weave in things seamlessly. That, to me, is the feature that's missing.
|
|
|
|
|
AOP is a more general mechanism to do this kind of thing. I'm on the fence about it though, it is arguably too far down the road towards magic, because you see an attribute and you really have no idea what it's doing if there is potentially AOP code from referenced assemblies in play.
I think I'd rather see specific language features to make it simple to deal with the 90% case, even if at some point AOP becomes available as well at a later time.
|
|
|
|
|
BobJanova wrote: it is arguably too far down the road towards magic It be voodoo dude . If, however, they made it obvious that it was an AOP attribute rather than a general attribute, this would help - say use |AOPAttribute| as opposed to [OrdinaryAttribute].
|
|
|
|
|
Hi.
Thank you for your reply.
I think your idea must be supported by Framework too.
Higty
|
|
|
|
|
Hello,
I don't know, is it secure to send windows password via netNamedPipeBinding to WCF service running on windows service? Hence, I request your thoughts on this and here is the scenario
We are asking the user to enter the windows user name and password from client application and sending them to WCF service(without explicit encryption) since the service need to interact with network mapped drive but currently we are not sure whether .net takes care of encrypting the user name and password and sends it via pipe or not.
About service details,
1. It uses the netNamedPipeBinding because we wanted this to be within machine level scope
2. Security mode set to mode="Transport" inthe config file
3. Transport protectionLevel set to protectionLevel="EncryptAndSign" inthe config file
4. There is no app.config at client side but creating object by passing "NetNamedPipeSecurityMode.Transport" "new NetNamedPipeBinding(NetNamedPipeSecurityMode.Transport)"
5. The machine where the wcf service is hosted may or may not be connected to internet
Is these enough? Or should I use explicit encryption? If explicit encryption required then, how to do?
Thanks, Sudhakar
|
|
|
|
|
Best way to check is to get a diagnostic tool and see what's actually sent across the pipe. If you're interacting with a WCF service over a non-secure channel then it's probably going by plain text.
However if you're on a single machine then it may not matter – if someone bad has access to the machine then you've got more problems than how your app handles data locally.
Probably best not to use your email as your display name, you'll get lots of spam if you publish your email like that.
|
|
|
|
|
I am creating a setup and deployment project in visual studio 2010. I need some custom action to be performed. I added an user interface with a text box that will accept the mail ID from user during installation and check from the database whether the mail id already exists in my user table.
Please help me.
|
|
|
|
|
AshwiniSH wrote: Please help me. With what, you have not asked a question?
|
|
|
|
|
Sorry.
In my setup project, I want to add an user interface with a text box that will accept the mail ID from user during installation and check from the database whether the mail id already exists in my user table.
|
|
|
|
|
And what is the problem with doing that? Will the setup program have access to the database?
|
|
|
|
|
I created a setup project in VS2010 and added a user interface selecting a text box field. The user interface is appearing during installation. I want to validate the input entered in the text box. How can I do this?
Where should I check this?
Please help me in how to validate the fields.
In VS2012, Install shield Limited edition I did not find how to add user interface also.
|
|
|
|
|
AshwiniSH wrote: Where should I check this? Presumably you will capture the input and validate it against some values that you have in your code.
|
|
|
|
|
Yes the input will be provided during installation (Say username), I want to validate this. Where should I write code to check this validation?
|
|
|
|
|
I was able to add a user interface but not able to do any validations to it as I don't know where exactly I can refer the user interface I added.
So, I decided to do it another way. i.e run my application exe after the installation. My application has a windows form which accepts user details and can validate through code behind.
In this case I don't want to show "Installation Complete" screen. I want my application to be launched instead of "Installation Complete" screen. How can I do this?
Can you please help me in this?
|
|
|
|
|
I have a method that I am exploring that takes in generic parameters.
public void Test<t,x>(t source, x destination) {
what I am trying to do is determine if x is either a collection or a class anything else should throw an exception.
The collection on I got by using the following
if(destination is ICollection<x>)
But my Googlefu keeps bring me back to the Type class and all I keep using is the IsAnsiClass but this registers true even if I pass an integer variable.
Is there a way to determine if the destination variable is a class?
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
I may well be misunderstanding you here, but...anything that isn't a class is a struct in C#, so won't this work:
public void Test<t,x>(t source, x destination)
{
if (!(destination is ValueType))
{
Console.WriteLine("Class");
}
else
{
Console.WriteLine("Not Class");
}
}
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
You hit the nail on the head there Griff thank you..
I blame my stupidness on a lack of Coffee
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
I frequently try the same; sadly no one believes me...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Of course, if you want to restrict the input so that you only accept class types, just add where x : class as the generic constraint.
|
|
|
|
|
Thanks Pete, I was aware of the where t: class .
The end game that I was trying to achieve as a learning experiment was to create my own version of Automapper to allow me to convert either EF tables or single rows from tables.
The second part of the learning was to create a single class that would act as a facade to the whole process and direct the conversion depending on weather it was a BindingList, List or class.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
modified 25-Mar-14 16:14pm.
|
|
|
|
|
Sweet. I look forward to seeing an article on this as it sounds absolutely fascinating.
|
|
|
|
|
The problem that I see in what you're doing is that you're checking for the passed in type at run-time. The whole point behind Generics is that you treat the T as a template at compile-time, preventing you from writing invalid code before you even compile it.
Pete's solution takes care of that little problem by limiting what types can be passed in as you're writing the code.
|
|
|
|