|
|
I asked a C# instructor several years ago this question. He said it was because the designers were worried the dumb people wouldn't understand multiple inheritance. (He added that most the dumb things in C# were done for this reason.)
This response is flippant, but I suspect more true than not. Multiple inheritance is very powerful and rarely used in good code, but when needed, it's really needed.
The solution was interfaces. Personally, I'd rather have had multiple inheritance, but what can you do? (I also think they should have had a scoped destructor mechanism built in. I'm sure everyone has their list of complaints.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
I've read the license agreement for my webservice and specifically note the clause "one call per second per IP address", my question is about "masking" IP addresses. Is it possible to route my webservice calls through a proxy server in combination with multiple worker threads thereby possibly making more than 1 request per second? I've seen this technology before concerning web surfing. There are free proxy servers willing to route your packet traffic, I'm just not sure how to implement something like that. Basically give each thread its own proxy server that can route 1 call per second with the end result being 10 threads means 10 calls per second approxiamately.
|
|
|
|
|
That would be like cheating ... not?
- Jake
|
|
|
|
|
Why yes it would be, but thats the beauty of it. Any hints?
|
|
|
|
|
Hint to do something bordering on illegal? Something that can get you sued? I don't think so...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
So what? You're violating your license agreement with that provider. If they find out what you're doing, you'll be making a maximum of 0 requests per second.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am going to answer the technical side of your question:
I have done this before. My system consisted of following components:
1.Spider which collects proxy addresses from the web using google search and regex.
2.Proxy server test app. This apps goes thru the list of proxies and makes calls to webservice on my server using those proxies. This is done to make sure proxy acually works. Here is a good article on this topic http://www.codeproject.com/vb/net/web_service_by_proxy.asp
3.A webservice which serves up valid proxy addresses.
-- modified at 16:02 Thursday 17th August, 2006
|
|
|
|
|
If i have this:
public class Thing
{
public string sName;
public string sLength;
}
Thing Cheese = new Thing();
Cheese.sName = "Cheese, duh";
Cheese.sLength = "16 feet!!!"
How can i add it to a treeview so that i can do something like this:
this.treeView1.SelectedNode
and get the sName, and sLength?
Or is there something completely different that i have to do?
|
|
|
|
|
Design consideration asside you can inherit TreeNode
public class Thing : TreeNode
led mike
|
|
|
|
|
Well i did that, and i can succesfully add my object as a node, yay!
But no text is displayed, how do i name the node?
|
|
|
|
|
Woops, don't matter. It figures, i post, then i found ot how to do it...
|
|
|
|
|
Thats what the Tag property is for.
|
|
|
|
|
Hi all,
I will logout my application when the user idle for certain time. after logout i will display Auto logout Message as "User logged out since there was no action for 1 hr",
here i have a interesting problem, if the user opened certain form(Eg. GetStatus)in the application and then gone for 1 hr. then i am displaying the Auto Logout message over the Form(GetStatus).
Same thing happened for messagebox too. if some message box displayed during application run for eg."Click Yes to proceed" Yes/No. then the user gone for some time. the auto logout happened it displays the auto logout message over the alredy dispayed messagebox. How can i close the already displayed messagebox before showing the Autolout messagebox. here it would be a problem if the user clicks Yes on already displayed message box so i have to definitely close the Messagebox before showing autologout message.
Thanks
Srini
|
|
|
|
|
Hi,
You can try to SendKeys to the message box first before displaying the logout message box. Set the default button of the first message box which is used to close that message box. Then in the code, where you try to display the logout box, just send the 'Enter' or 'Return' key to close it !
Go through ths link
http://msdn2.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx[^]
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
Anant Y. Kulkarni
|
|
|
|
|
As a fairly new C# programmer, I am in need of some help with reflection, or another way of something similar in C#:
I have created a control with several overloaded DisplayObject methods. I have also created an interface within the control's class similar to the following:
interface TheInterface
{
string a
{
get;
set;
}
string b
{
get;
set;
}
The DisplayObject methods have an implementation of this interface like:
DisplayObject(TheInterface myInt)
and
DisplayObject(TheInterface[] myInts)
I have these two methods working just fine. But, I want to add to them......
Outside of the control I define two classes like:
class Outside1 : TheInterface
class Outside2 : TheInterface
And I define another class such as
class WayOutside
{
class Outside1 myOutside1;
class Outside2 myOutside2;
}
Then, the user of my control would call:
DisplayObject(WayOutside);
To handle that case, what I would like to do inside of my control is have another DisplayObject method that would take a generic variable (maybe an object type?) and then have my control go through the class and call the other DisplayObject method that takes either of the "TheInterface" methods above so that the code might look like:
void DisplayObject(object generic)
{
.... HELP HERE? Reflection? Another way? .....
foreach(TheInterface item in generic)
this.DisplayObject(item);
}
Basically, the WayOutside class can have any number of classes in it, but they will all implement TheInterface.
Anyone have any ideas as to how I can do something like this?
Thanks!
David
-- modified at 13:06 Thursday 17th August, 2006
|
|
|
|
|
Yes, reflection sounds like a good way to go. If you're dealing with properties, then you'd do something like:
foreach (PropertyInfo pi in generic.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
{
this.DisplayObject(pi.GetValue(generic, null) as TheInterface);
}
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
When I read "fairly new C# programmer" and "reflection" in the same sentence, I want to say this:
In my opinion, reflection is one of the most over-used aspects of programming that I know. It seems like almost everyone runs for the Golden Hammer of Reflection as soon as they have something that they don't know how to implement.
If I had an object that contained other objects that I wanted, I would make a method in the object that handed me the objects. You kan make an interface to force the class to implement the method:
interface IGotMilk {
TheInterface[] GetTheInterfaceObjects();
}
void DisplayObject(IGotMilk generic) {
foreach (TheInterface item in generic.GetTheInterfaceObjects()) {
this.DisplayObject(item);
}
}
---
b { font-weight: normal; }
|
|
|
|
|
Thank you both for your help and suggestions. I originally considered implementing this with the array of TheInterface objects within the implementer, but nixed the idea, because I want the implementer to have to do as little work as possible to use my class.
Having said that, I did get the array implementation to work correctly as well as the reflection example to work correctly also.
Thank you again for your help....
David
|
|
|
|
|
I'm feeling lazy: Has anyone cobbled together a replacement for DirectoryInfo.GetFiles that accepts multiple file filters?
-- modified at 13:42 Thursday 17th August, 2006
OK, here's something quick and dirty...
private void AddFilesRecursively(List<FileInfo> files, DirectoryInfo directory,
string filters, bool recurse)
{
FileInfo[] dirFiles = directory.GetFiles("*.*", SearchOption.TopDirectoryOnly);
if (filters == "*.*")
files.AddRange(dirFiles);
else
{
foreach (FileInfo file in dirFiles)
{
if (Regex.IsMatch(file.Extension, filters, RegexOptions.IgnoreCase))
files.Add(file);
}
}
if (recurse)
{
DirectoryInfo[] dirInfos = directory.GetDirectories();
foreach (DirectoryInfo dir in dirInfos)
{
AddFilesRecursively(files, dir, filters, recurse, level+1);
}
}
}
private List<FileInfo> GetFiles(string path, string filters, bool recurse)
{
List<FileInfo> files = new List<FileInfo>();
DirectoryInfo dirInfo = new DirectoryInfo(path);
AddFilesRecursively(files, dirInfo, filters, recurse, 0);
return files;
}
-- modified at 13:48 Thursday 17th August, 2006
|
|
|
|
|
Unfortunately not. There was a post about it a little while ago and nobody seemed to offer up anything. Maybe I should write one that takes a Regex...
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Hi Chris
Would something like this work?
public IEnumerable<string> GetFilesInDirectory(string directory, SearchOption searchOptions, params string[] filters)
{
foreach (string filter in filters)
{
foreach (string matchingFile in Directory.GetFiles(directory, filter, searchOptions))
{
yield return matchingFile;
}
}
}
Use it like this:
IEnumerable<string> txtAndXmlFiles = GetFilesInDirectory(@"c:\foo\", SearchOption.AllDirectories, "*.txt", "*.xml");
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Something like that was my first thought. Unfortunately it means the directory tree is being recursed for each filter, and if you have, say, 50,000 files then it bogs down.
Why, Microsoft? Why...
|
|
|
|
|
Ok - what if we did a GetFiles call, returning all files in the directory, then doing the filter ourselves? Would that be too much overhead too? If so, you're faced with implementing a custom GetFiles, in which case, MSDN has already done this for you[^].
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: And in this corner, the Party of Allah
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Thanks for the link. That's a great way to use yield return.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|