// caller may be null when not called as a worksheet function. public AsyncObservableState(Guid id, AsyncCallInfo callInfo, ExcelReference caller, IExcelObservable observable) { _id = id.ToString(); _callInfo = callInfo; _observable = observable; _callerState = AsyncCallerState.GetCallerState(caller); // caller might be null, _callerState should not be }
// caller may be null when not called as a worksheet function. public AsyncObservableState(Guid id, AsyncCallInfo callInfo, ExcelReference caller, ExcelObservableOptions options, IExcelObservable observable) { _callInfo = callInfo; if (options == ExcelObservableOptions.None) { _topics = new string[] { id.ToString() } } ; else { _topics = new string[] { id.ToString(), ((int)options).ToString() } }; _observable = observable; _callerState = AsyncCallerState.GetCallerState(caller); // caller might be null, _callerState should not be }
// caller might be null public static AsyncCallerState GetCallerState(ExcelReference caller) { if (caller == null) { return(new AsyncCallerState(null)); } AsyncCallerState callerState; if (!_callerStates.TryGetValue(caller, out callerState)) { callerState = new AsyncCallerState(caller); _callerStates[caller] = callerState; } return(callerState); }