This is a migrated thread and some comments may be shown as answers.

Private Accessor generic method

1 Answer 8 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vikas
Top achievements
Rank 1
Vikas asked on 06 Aug 2015, 12:29 PM

I have a private Generic method and I want to call it using Private Accessor, How can i do that.

private void PopulateCollection<T>(List<IDataItem> fromCollection, ObservableCollection<T> toCollection){}

 

Thanks

Vikas

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 11 Aug 2015, 08:26 AM
Hello Vikas,

You need to identify the method using reflection:
var inst = new PrivateAccessor(new MyType());
var method = typeof(MyType)
    .GetMethod("PopulateCollection", BindingFlags.NonPublic | BindingFlags.Instance)
    .MakeGenericMethod(typeof(ToCollectionElementType));
inst.CallMethod(method, fromCollection, toCollection);

PrivateAccessor should be made easier to use with generic methods, so I added a feature suggestion to our backlog.

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Vikas
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or