1

Closed

CuttingEdge.Conditions not extending its methods in my C# wpf project

description

Hello there,
I have a WPF project in which I want to use CuttingEdge.Conditions for validating things.
I used Nuget to download and get the dll reference in my project. Then after when i tried to access it, i could only go to the "Requires" method inside it and not to the extending methods like "IsNotNull()" etc.

For ex:
CuttingEdge.Conditions.Condition.Requires(argument, "argumentName");

but I want to use it like:
CuttingEdge.Conditions.Condition.Requires(argument, "argumentName").IsNotNull();

Please help. :)

file attachments

Closed Dec 19, 2013 at 5:49 PM by dot_NET_Junkie
This is by design. You need to include the namespace to be able to use the extension methods.

comments

dot_NET_Junkie wrote Dec 18, 2013 at 9:40 AM

Make sure you've included the CuttingEdge.Conditions namespace at the top of your code file:
using CuttingEdge.Conditions;
The validation methods like IsNotNull are extension methods, and extension methods only work when the proper namespace is included (just as LINQ queries don't work without System.Linq).

amanjain wrote Dec 18, 2013 at 10:06 AM

i have used it.
In fact, i tried it in console application and its working fine, but not working in WPF.

amanjain wrote Dec 19, 2013 at 5:34 AM

I am using 1.2 version.

dot_NET_Junkie wrote Dec 19, 2013 at 6:41 AM

Can you upload a sample project that shows this problem?

wrote Dec 19, 2013 at 7:29 AM

amanjain wrote Dec 19, 2013 at 7:29 AM

Here is a sample. One project is in WPF and the other is a Console Application.

dot_NET_Junkie wrote Dec 19, 2013 at 2:19 PM

Your MainWindow.xaml.cs lacks the "CuttingEdge.Conditions" namespace at the top of the file. If you add "using CuttingEdge.Conditions;" at the top of your code file, it works.

amanjain wrote Dec 19, 2013 at 5:08 PM

I was using it (like CuttingEdge.Conditions.Condition.Requires...) in my sample, which is the same if I use a namespace declaration on the top and then Conditions.Condition.Requires. Although in another project, I am using it in the manner what you have mentioned but didn't help.

Can you upload any sample wpf application using it or it would be better if you can update the same what I have uploaded.

Thanks.

amanjain wrote Dec 19, 2013 at 5:22 PM

Hey, I tried it on vs2012 and it worked!
All I had to do was including namespace and not directly using CuttingEdge.Conditions.Condition.Requires(x,"x").IsNotNull();

Will try it on vs2010 again, in this way.

wrote Dec 19, 2013 at 5:49 PM