|
Hi,
I am trying to invoke a static method on "a_class" which is derived by "another_class" and the static function I am trying to invoke in "another_class".
The problem is that I am trying to do this by using reflections. And by using reflections on "a_class" I can not see any MethodInfo for any static method declared in "another_class".
I am trying to do something as follows:
//I will be getting a generic collection in this object
object oCollection;
//Getting the type
Type factoryType = BuildManager.GetType("My.NameSpace.Class", true);
//Calling a static function on factoryType
oCollection = factoryType.InvokeMember("GetByFilter",
BindingFlags.NonPublic | BindingFlags.Public |
BindingFlags.Static | BindingFlags.InvokeMethod |
BindingFlags.DeclaredOnly | BindingFlags.FlattenHierarchy,
null, null, new object[] { });
Can anybody kindly tell me how can I achive this?
Thanks in advance
Stuck
|
|
|
|
|
I think that getting rid of the DeclaredOnly binding flag should do the trick (assuming that factoryType == typeof(a_class)). DeclaredOnly specifies that the search should not look in base classes for the member.
|
|
|
|
|
Hi Josh,
I really appriciate that you answered my question. I tried by taking off DeclaredOnly BindingFlag but it still didnt work.
Any other suggestion?
By the way, I was able to see the methods declared public in parent class, but I was not able to see the public static method declared in parent class.
Thank you
|
|
|
|
|
You can't.
Static methods only exist in the class where they are declared. They are not inherited.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks alot Guffa for answering!!
seems like I am out of luck
|
|
|
|
|
Does anyone know the attribute decorations that populate the Tasks list at design time?
|
|
|
|
|
What do u want tell me in detail.
|
|
|
|
|
I thought I had.
I have a user control that inherits Panel called GraphicViewer.
I have a collection to populate.
In designer, I want the GraphicViewer Tasks list to be populated with a task that launches the ArrayTypeEditor.
|
|
|
|
|
I have a TreeView where each node has an model object in it's Tag property. When a node is selected, I show that object in a property grid.
There are only two levels to this structure, a Category object has a Name and a collection of Field objects, which is displayed as a Catetory Node with child Field nodes.
-Cat1
--Field1
--Field2
-Cat2
--Field3
--Field4
Problem is, the property grid allows you to modify the Fields collection in the property grid, and I can't identify a property grid event that will let me know that this has happened so that I can update the TreeView.
The Validating event fires when you alter a plain text field in the property grid, but not when a collection is modified.
Has anybody dealt with this before?
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
Probably the safest way to do this is as follows:
Hook into the BeforeSelect event on the Treeview
In your BeforeSelectEventHandler,
move the PropertyGrid.SelectedObject into the prior SelectedNode Tag.
This will ensure that you capture all changes that occured in each object.
|
|
|
|
|
The objects are updated, that's not the problem. The problem is that the object in a Category node has 4 children in it's collection property, but the TreeView doesn't know that it needs to add a 4th child node. I can check the last node for changes when you move to another node, but I'd like to know the instant it happens so there's no confusion looking at the tree view wondering where my new child is. Does that make sense?
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
SO if the user adds or removes items from the collection using the PropertyGrid the PropertyValueChanged event does not fire?
|
|
|
|
|
Nope, sounded reasonable to me too. It fires when you set the property grid's SelectedObject to another object.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
You could use the INotifyPropertyChanged technique (new to .NET 2.0, but easy enough to simulate in 1.x if necessary). In the setter of each property, call an OnPropertyChanged method passing in the name of the property as a string. In that method, fire an event which passes an event arg containing the property name. Then hook that event on the newly selected object and whenever it changes, either selectively repopulate the selected node's descendants, or just wipe the whole branch out and repopulate it with the object's current state.
Josh
|
|
|
|
|
Best I think I could do with this is publish events in the collection, and hook em on node select. That might work. Thanks for the idea.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
|
Holy crap BatMan! Even that doesn't work! PropertyGrid must clone everything in and copy it back out. The only explaination I can think of...
On node select, I hook add and remove events in the internal collection, and set the parent to the property grid. The events NEVER fire! I give up, I'll find a compromise to get around it.
Try code model generation tools at BoneSoft.com.
-- modified at 17:47 Thursday 29th June, 2006
Nah, that can't be... You can refer to the property grid's selected object, and the node's tag and get the same reference... I don't know what's going on, but property grid does seem to supress my events.
|
|
|
|
|
After referring to an article here, I was able to successfully build a TWAIN program and get pictures from a digital camera. I was told that it works with Windows2000 (and even as low as Windows98) but when I run the code I made in .NET, it doesn't work. Any suggestions or ideas?
I love to program!
|
|
|
|
|
Greetings!
I was wondering if I could get some direction to get me started in implementing a "copy/paste" of the properties of a UserControl.
In my application, I have 10 instances of a particular UserControl. This UserControl has, say, 10 properties. I would like to be able to use the right-click menu that I have for this UserControl and be able to copy the "settings" of one instance to any other instance of the UserControl.
From what I've read on MSDN, I understand that I have to make the UserControl class Serializable and that the variables that I do not copied can be excluded using the [NonSerializable] attribute, thus so:
<br />
[Serializable]<br />
<br />
public class ctlMyControl : ctlBaseControl<br />
{<br />
int nNum1;
float fNum2;
<br />
[NonSerializable]<br />
float fNum3;
<br />
} <br />
My question is how does one implement the actualy copy and paste?
What function(s) do I use to perform the copy and what function(s) do I use to paste?
Your help is appreciated!
Thanks!
|
|
|
|
|
Hi,
I am using a snmp manager component. it sends a broadcast request. the responses of the broadcast are reveived via an event called
snmp_OnResponse()event. All the response I received I am trying to store them in a arraylist. which I later want to use to do further processing.
But I have no way of knowing when I would have received all the responses.
I can make an assumption, by using snmp timeout , and waiting for that amount of time before proceeding to do anything. Is there a wait or sleep function which will reliquish control, and let OnResponse event handle all the incoming responses before proceeding with further function calls?
I would appreciate if you can suggest any other approach to solve this.
Thanks,
Arti
|
|
|
|
|
Maybe the System.Timers.ElapsedEventHandler would work for your situation
|
|
|
|
|
Yes, there is a Thread.Sleep(int) method in System.Threading namespace.
Best,
Jun
|
|
|
|
|
Ok I have two controls, Ok Control X and Control Y, I want control X to be able to raise in event that Control Y is listening for when Control Y hears this event it responds by raising an event/events Control X is listening for and in Turn Control X does some work or method call etc. Any help would be greatly appreciated. Thank you
|
|
|
|
|
X->Y->X->Y... Sounds like infinite looping here
Best,
Jun
|
|
|
|
|
Yeah I am kinda confused myself but it shouldnt end up falling into an infinite loop. Ok here is a long explanation that hopefully will make it more clear.
I have a side bar with buttons on it, each button corresponding to a specific form that will be loaded in to a panel on the same form as the SideBar/ToolBar. Ok hope ur still with me...lol..Alright now these forms are independent of the Toolbar but the tools bars controls the user navigation from form to form. If a user clicks on one of the buttons(wanting to change to another form) I want to currently active form(the form that is being viewed) to know that an attempt to unload it and load another form is about to happen, if this form is at a critical point in its process it needs to be able to say NO dont change me yet and stop the process of the visual unloading of the form and prompting the user to finish whatever he needs to finish and they attempt a change later.
SOOO with all of that, that is why I have a Control X(toolbar) that wants to raise an event to control Y(Form in Panel), Control Y(Form in Panel) will listen for this event, if it is at a point of being able to allow a change then it sends a response back to the Control X(Toolbar) allowing the change of forms to happen. I hope this explains it more clearly. I understand what i need to do, i am just trying to find some code examples to begin to lead me down the right path to see if i am right or not.
Thanks for all the help.
|
|
|
|