Reputation: 25
How to access non-public members for NCrontab ?
string time_A = "20,25,30 20 * * 1-5";
var schedule = NCrontab.CrontabSchedule.Parse(time_A);
I can see Non-Public members of 'schedule' from the debug,
but I want to get value of _day and _hours.
From I need to access a non-public member (Highlighted Item) of a Combo Box, seems like it does not work for the following line.
PropertyInfo highlightedItemProperty = schedule.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Instance).Single(pi => pi.Name == "_days");
Please advise.
Updated !!!
I can fix it now.
string time_A = "20,25,30 18-22 * * 1-5";
var schedule = CrontabSchedule.Parse(time_A);
var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
var field = schedule.GetType().GetField("_hours", bindingFlags);
var getfield = field.GetValue(schedule);
Upvotes: 1
Views: 85