|
Why did you feel the need to post this question in no less than 7 different forum?? It's no longer likely your ever going to get an answer to this question seeing as you saw fit to do what everyone hates -> SPAM this site with your question. Pick a single forum most appropriate for your subject, like General Discussions in your case, and post your question ONCE!
|
|
|
|
|
...
Blog link to be reinstated at a later date.
|
|
|
|
|
I have some code that we use to parse the contents of a folder and perform actions based on file dates. We would now like to do the same over our internal network to a location such as http://server.company.com:8080/files. Unfortunately, the DirectoryInfo method does not support this type of path. Is there a similar method that can be used for this type of path?
|
|
|
|
|
I am attempting to write code that sinks an event with only an object reference and the event name - no type information. I write a generic event handler function:
public void ComponentEventHandler(object o, EventArgs e)
{
// handle generic event
}
Then I wrote some code that attaches any event to this event handler function
protected void SinkControlEvent(Control ctrl, string eventName)
{
EventDescriptor event = TypeDescriptor.GetEvents(ctrl)[eventName];
Delegate del = Delegate.CreateDelegate(typeof(System.EventHandler), this, "ComponentEventHandler");
event .AddEventHandler(ctrl, del);
}
This works fine when the event I'm sinking has the standard function signature. However, I get an exception when the event has a derived EventArgs parameter. For example, trying to sink the following event would cause a type mismatch exception:
public event void ValueChanged(object sender, ValueEventArgs e);
The exception is "Invalid event handler for ValueChanged event". Of course 'ValueEventArgs' inherits from EventArgs, so I don't understand why this isn't a valid handler.
Some things to note:
1. You can, in code, assign an untyped event handler to a typed event. Somehow the compiler figures it out.
2. I tried changing my code such that I attach an untyped function to a typed delegate, but that also threw an exception.
Delegate del = Delegate.CreateDelegate(event.EventType, this, "ComponentEventHandler");
Thanks,
Aaron Stibich
|
|
|
|
|
astibich2 wrote: public void ComponentEventHandler(object o, EventArgs e)
Could you not change this to
public void ComponentEventHandler<T>(object sender, T e) where T : EventArgs
|
|
|
|
|
That looks a lot like the EventHandler< T> class
|
|
|
|
|
Well, I thought so, but I can't see what he's trying to do that you can't accomplish normally.
|
|
|
|
|
Hello TCP gurus!
It's me again, standing in a the corner of a room with wet paint all around me.... Any help would be appreciated.
I have a dictionary
public class DataImage : Dictionary<string,>
which has been working wonderfully for me. But now I find that when I have a problem when adding values using the Item property.
DataImage<string,> modImage = new DataImage<string,>();
...
modImage["xxx"] = "yyy";
I need to have some additional actions occur. In particular, DataImage contains some private data that needs to be updated whenever an element is added or removed. I have the required code in the Add() and Remove() methods, but I also need that logic to occur when the dictionary is accessed using its Item property.
I would like to do something akin to
public override string Item[key]
{
get { return base[key]; }
set
{
base[key] = value;
changeOtherStuff(key, value);
}
}
I looked at this page (http://msdn.microsoft.com/en-us/library/9tee9ht2.aspx[^]), but couldn't see how to write the necessary code from it. I also searched online, but to no avail.
Clive Pottinger
Victoria, BC
|
|
|
|
|
cpotting wrote: I also searched online, but to no avail.
They hide that information in the documentation[^]
led mike
|
|
|
|
|
Thank you Mike - exactly the syntax I needed. Now I can hang from ceiling and continue painting the floor...
Clive Pottinger
Victoria, BC
|
|
|
|
|
Few observations:
- when defining Item property (indexer), I believe you should provide type of the key parameter
- indexer is defined using this keyword
- default indexer is not marked virtual so you should use new keyword
So the code should be something like the following
public class DataImage : Dictionary<string,sometype> {
...
public new sometype this[string key} {
get {...
Hope this helps,
Mika
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Thank you too, Mika
Clive Pottinger
Victoria, BC
|
|
|
|
|
sorry. The definition of DataImage should say "string,string", but the display is dropping the second "string". And for some reason, I can't get in to edit to the message.
Clive Pottinger
Victoria, BC
|
|
|
|
|
Hi fellows:
How can I restirct only integers to be entered inside the propertygrid value field. I tried looking into this matter by wasn't quite succesfull. I hope your suggestion can help me.
Thanks
|
|
|
|
|
Search for GridItem. Will Implement one row in a PropertyGrid.
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
I couldn't find much related to GridItem to control user input. Would you be kind enough to provide me with some examples or code or perhaps a useful resource.
Thanks
|
|
|
|
|
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
{
GridItem selectedItem = e.ChangedItem;
if (selectedItem.Label == "Text")
{
if (selectedItem.Value.ToString().Contains('a'))
selectedItem.PropertyDescriptor.SetValue(propertyGrid1.SelectedObject, e.OldValue);
}
}
Hope it can help
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
My office is testing a bunch of folks who have applied for Java jobs. I don't know head and tails of the language other than that its syntax is stolen from here and there (I'm still partyin' with MFC/Win32, yay!). My buddy was the invigilator and got the questions' sheet. This was one of the easiest assignments, and shockingly, only 3 out of the 14 people that attempted this problem finished it correctly on time. Some took more than 45 minutes but got it right, and others didn't solve it at all! I tried it for the hell of it beat the time by 29 minutes, finishing at 16 minutes (C/DevCPP), which I guess is not bad. Post your times here, and see if you can bring it down below 16 minutes.
Q7. (Note: You cannot answer Questions 8, 11 and 14 if you are answering this question. Pick another 2 from the rest).
Write a command-line program as follows:
First the program will take as input a +ve integer from the user, let's call it
the TARGET.
It will then take in a set of +ve integers from the user, and here the user gets
to specify how many integers he/she wants to enter. Let's call this set the
RANGE.
Now the program should compute as follows:
- Find all combinations in the RANGE, the sum of which add up to the
target. Print such combinations at the command prompt. In a combination,
repeats are not allowed. i.e. (x + x + y) = TARGET is forbidden. Every element
in the combination must be unique.
- In case a user enters a RANGE element greater than the target, it should be immediately
discarded and the user must be prompted for the element again.
- Order shifted cases don't count. i.e. (x+y) and (y+x) being printed
separately is unnecessary and MUST be avoided.
- In case no combinations exist, the program should report so.
- Add exception handling code where necessary.
Example Run:
Enter Target: 15
How many set elements?: 5
Enter Element1: 7
Enter Element2: 8
Enter Element3: 12
Enter Element4: 3
Enter Element5: 22
Sorry. That element is larger than your target. Try again.
Enter Element5: 4
Combinations are:
1] 7+8
2] 8+3+4
3] 12+3
Time: 45 mins.
(At the top of the source file, please comment in your ID details along with the reference number at the back of the day-card you were provided by the examiner. Write your Full Name, ID key, TDC number and most importantly the reference number. Good luck.)
modified on Tuesday, November 4, 2008 2:13 PM
|
|
|
|
|
Maybe I made too much work on the UI, handling non-numeric input and such... The input part is exactly half the program.
27 minutes.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
You should stick this over in Math & Algs. The interesting bit here is how your candidates go about solving the subset-sum problem, which is NP-Complete. The input half would be done in first year uni.
|
|
|
|
|
I am relatively new to programming in the C family of languages, and I am currently writing a program that I need some help on. Using C#, I am going to create some byte arrays and some int arrays, but I am unclear on how the data is store. I know that arrays are reference types which are created on the heap, but ints and bytes are data types which are kept on the stack. What I don't know is whether the data contained in a byte or int array is stored on the stack or the heap.
I need to be able to make sure that the data is totally destroyed after use, so if it is on the heap, I'm planning on a multi-pas data overwrite. To make sure that there is no recoverable bit of the data,I believe I need to pin the data in memory so that it is not moved by the garbage collector, and I'm planning on using pointers for access. I am aware that I can do this using the "fixed" keyword within an "unsafe" block. However, I'll be working with multiple arrays at the same time and I don't know if the fixed() method is overloaded to accept multiple pointers or if I have to use the "fixed keyword nested for each array separately. I also wonder if I can create the pointers outside of the "fixed" block and pass them in or if they must or should only be created as part of the arguments of the fixed() method.
Could someone please respond to these concerns and/or maybe recommend a book that covers this and other intermediate/advanced topics? I'm also looking for a good magazine on programming with C++ and/or C#.
Thanks!
|
|
|
|
|
BugsSister wrote: but ints and bytes are data types which are kept on the stack.
Your understanding of this needs some work.
BugsSister wrote: What I don't know is whether the data contained in a byte or int array is stored on the stack or the heap.
heap
BugsSister wrote: I need to be able to make sure that the data is totally destroyed after use
Are you talking about scrubbing sensitive data from memory[^]?
led mike
|
|
|
|
|
Thanks led mike-
I've posted this for my brother, so I'll pass it along and see what he responds.
|
|
|
|
|
Hi,
i try to code a GUI for UPX, and in general it will work, but i have still two questions.
First, this is my code for capturing the StandardOutput from UPX in the Console:
private void cmdLesen_Click(object sender, EventArgs e)
{
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = "upx.exe";
start.RedirectStandardError = true;
start.RedirectStandardOutput = true;
start.UseShellExecute = false;
Process prozess = Process.Start(start);
prozess.WaitForExit();
string consolenText = prozess.StandardOutput.ReadToEnd();
string consolenText2 = prozess.StandardError.ReadToEnd();
rtfBox.Text = consolenText2;
}
1) What i don't know is why the Output with prozess.StandardError.ReadToEnd(); is captured and it is written to consolenText2, and i can show it(the whole console output) in my rtfbox, but when i try it with prozess.StandardError.ReadToEnd(); nothing is in the string consolenText ???!!!
2)I want that the console will *N*O*T* fade away !
When it is always on top i could better test the input i have to do and the output in the console "UPX".
It's is simpy better for the controlling of my code
Many many thanks for your help !
... best regards
Questioneer
|
|
|
|
|
... really nothing ?
best regards
Questioneer
|
|
|
|
|