Esempio n. 1
0
 public async Task AddSessionItem <T>(string key, T value)
 {
     try {
         await SessionActor?.SetSessionItem(key, value.ToString(), CancellationToken.None);
     }
     catch (Exception ex) {
         ServiceEventSource.Current.Message($"Method {nameof(SessionService)}->AddSessionItem<T>() failed with error: {ex.ToString()} at: {DateTime.UtcNow}");
     }
 }
Esempio n. 2
0
        public async Task <T> GetSessionItem <T>(string key)
        {
            try {
                var sessionItemValue = await SessionActor?.GetSessionItem(key, CancellationToken.None);

                if (string.IsNullOrEmpty(sessionItemValue))
                {
                    return(default(T));
                }
                return((T)Convert.ChangeType(sessionItemValue, typeof(T)));
            }
            catch (Exception ex) {
                ServiceEventSource.Current.Message($"Method {nameof(SessionService)}->GetSessionItem<T>() failed with error: {ex.ToString()} at: {DateTime.UtcNow}");
            }
            return(default(T));
        }