我正在努力了解代表团所以我只是写了一个小试试项目; 我有D班:
class D
{
private static void Func1(Object o)
{
if (!(o is string)) return;
string s = o as string;
Console.WriteLine("Func1 going to sleep");
Thread.Sleep(1500);
Console.WriteLine("Func1: " + s);
}
}
Run Code Online (Sandbox Code Playgroud)
并在主要使用中:
MethodInfo inf = typeof(D).GetMethod("Func1", BindingFlags.NonPublic | BindingFlags.Static);
Delegate d = Delegate.CreateDelegate(typeof(D), inf);
Run Code Online (Sandbox Code Playgroud)
方法info获取正确的信息,但CreateDelegate方法抛出异常,例如,该类型必须从Delegate派生.
我怎么解决这个问题?
我的代码在Angular7中,使用@ ngrx / store7,有时我会得到未定义状态(仅针对特定状态)

它始终是“历史”状态。
我的应用程式状态:
export interface IAppState {
router?: RouterReducerState,
delivery: IDeliveryState,
events: IEventsState,
families: IFamiliesState,
googleDrive: IGoogleDriveState,
spinner: ISpinnerState,
user: IUserState,
volunteerConstraints: IVolunteerConstraintsState,
volunteers: IVolunteersState,
history: IHistoryState
}
export const initialAppState: IAppState = {
delivery: initialDeliveryState,
events: initialEventsState,
families: initialFamiliesState,
googleDrive: initialGoogleDriveState,
spinner: initialSpinnerState,
user: initialUserState,
volunteerConstraints: initialVolunteerConstraintsState,
volunteers: initialVolunteersState,
history: initialHistoryState
};
export function getInitialState(): IAppState {
return initialAppState;
}
Run Code Online (Sandbox Code Playgroud)
我的历史记录状态:
export interface IHistoryState {
familyHistory: Array<FamilyHistoryModel>;
familyHistoryPending: boolean;
routeHistory: Array<RouteHistoryModel>;
routeHistoryPending: boolean;
deliveryHistory: Array<DeliveryHistoryChartModel>;
volunteerRating: …Run Code Online (Sandbox Code Playgroud)