|
MafiaMoe wrote: IEWin.NavigationBar.Method();
bool g = IEWin.NavigationBar.Forward.Method();
for this to work, NavigationBar must be:
- a public member or property of IEWindow;
- an instance of some other class that has:
- a public Method() method.
- a public member or property called Forward, which is itself an instance of some other class that has a Method() method.
Conclusion: you build a hierarchy of classes, and provide either data members holding, or properties returning, an instance of some child class (which could or could not be an inner class, your choice). So you could do hundreds of different operations on IEWin although IEWindow itself does not have to offer hundreds of methods, it all becomes one big hierarchy (or tree).
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Add(String GUID, String name, NetProtocol net, String ServerName, Int32 port, String UserName, String Password)
that is a method, but now i need to check all variables if are null or empty. If any one does not match, it would throw expection.
I don't like too many if statemnts, is it possible to put everything in one If line?
|
|
|
|
|
Saksida Bojan wrote: is it possible to put everything in one If line?
Have you forgotten what you learned while reading your first C# book? you can build complex expressions, e.g. using the logical AND and OR operators.
However, the user of your class/method won't like it when your method gives a single exception saying "some parameter is wrong". You really should use one IF per parameter as a minimum.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
What makes you think he ever read a book ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
That was a suggestion in disguise.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Is it something like this?
if (name == null || name.Equals("") || ServerName == null || name.Equals(""))
Yes i have read C# book, but quite while ago. And once i have tried using with many OR operators, i didn't got the desired results
Luc Pattyn wrote:
However, the user of your class/method won't like it when your method gives a single exception saying "some parameter is wrong". You really should use one IF per parameter as a minimum.
This class isn't part of GUI.
|
|
|
|
|
seems OK, why don't you try it?
also have a look at String.IsNullOrEmpty(), that could be a more compact solution.
Saksida Bojan wrote: This class isn't part of GUI.
That's besides the point; the user of your class or method, i.e. the person writing the code that is going to use them (even if it is you), may appreciate getting a specific error message.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Also, if you're writing C# (and not Java) just test string equality with the == operator; there's no need to call Equals directly.
Plus, it's a little more efficient to test for an empty string by checking its Length.
And, as Luc said, IsNullOrEmpty is the preferred way to check this.
Personally, I check each separately so I can give more detailed Exceptions.
|
|
|
|
|
Saksida Bojan wrote:
Yes i have read C# book, but quite while ago. And once i have tried using with many OR operators, i didn't got the desired results
Perhaps you should read it again ?
Saksida Bojan wrote: This class isn't part of GUI.
What is the point of the class reporting if the input is unacceptable, unless it asks the user to correct it ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Saksida Bojan wrote: I don't like too many if statemnts, is it possible to put everything in one If line?
Why don't you ? Let me explain something to you. Writing code that a computer can understand, is easy. One of the worst things about outsourced code, is how illegible it is to humans. Do the poor person who is going to maintain this code in the future a favour, and think about writing legible code, rather than your personal preferences.
Also, how can you provide a detailed error message if all your if statement knows is that one of the parameters is invalid ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
By web app, you mean a windows app that works with the web ? Your app is not ASP.NET, right ?
ninjatruck wrote: I am new to C#,
This is an odd task for someone who is 'new to C#'. How new is new ? What other languages do you know ? Why are you writing this right now ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Well my plan is to use this as part of the code behind class for an ASP.NET website.
I know c++, though I'm not very experienced with that either. I'm writing this now to help a friend who wants this for work. The program will read a .csv, and check URLs based on what it reads. I have everything else working great, but checking the URL isn't working correctly. I've only been working with c# for about a month at this point.
|
|
|
|
|
ninjatruck wrote: Well my plan is to use this as part of the code behind class for an ASP.NET website.
Why would an ASP.NET site be checking if other sites are valid ?
ninjatruck wrote: I know c++, though I'm not very experienced with that either. I'm writing this now to help a friend who wants this for work.
Wait - you don't really know C# or C++, or any other language, but you're writing this to help a friend, who knows so little about programming that they are asking for help from a beginner, yet they are writing code for their job ?
ninjatruck wrote: The program will read a .csv, and check URLs based on what it reads. I have everything else working great, but checking the URL isn't working correctly. I've only been working with c# for about a month at this point.
For someone who has been working with C# for a month to try to write code like this, is insane. You're not learning C# really, you're learning enough syntax to try to use some objects in the .NET framework, without really understand what is going on.
Have you checked what exception is thrown when you go to a URL you expect is valid ? Perhaps the exception type is different.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I hadn't checked what exception was thrown. Thanks for the idea.
Honestly I didn't realize this was such a complicated task when I said I would help.
|
|
|
|
|
ninjatruck wrote: Honestly I didn't realize this was such a complicated task when I said I would help.
Fair enough - you're doing a cool thing to try to help a friend, I am just shocked that based on your limited experience, that he both needs your help, and has a job as a developer.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
It is very hard to make. If you PING to server, you can easly get if the server is accsasible. But as i understand from your original post, you wan't to make sure a link is valid not if server is accsasible. Here the problem rises. Server is easly visible, but it will return a custom 404 page.
If you wan't to make for specific sites, you can grab all those sites their custom 404 pages, parse it and check its content.
|
|
|
|
|
I think it should be always better to ping the server rather than practically loading the page.
The site sometimes throws error if proper login to the url is not there.
So Please take out the part after the url and ping that. For instance
http://www.amazon.com/exec/obidos/ASIN/B000GELXHY
should be placed as
http://www.amazon.com
Hope this is working.
|
|
|
|
|
ninjatruck wrote: see if a given URL is valid
that depends on your definition of valid, e.g.:
- responding to pings;
- responding to HTML GET;
- responding to HTML POST;
- responding to other protocols;
...
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
My mistake, essentially I need to see if the url gives a 404 error.
|
|
|
|
|
Read his answer above. He's been doing C# for a month and that month gives him more experience than a friend who works as a programmer, so he's trying to help him out.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
He sure is teaching me new things...
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
cascading menu example in vc++
|
|
|
|
|
sujeet3082@yahoo.com wrote: cascading menu example in vc++
Is this the title of an article or has it some remote connection to C#, i.e. this forum?
|
|
|
|
|
I'm sorry, but it's clear you're not really ready for the big time.
1 - sujeet3082@yahoo.com - using your email as a user id will get you tons of spam
2 - this is the C# forum
3 - your subject line is ridiculously pointless
4 - your 'question' is plain rude. We are real people, you don't just type what you want and we write it for you.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|