示例#1
0
        public void AddOrUpdateLatestAuthed(string deviceCode, Guid appEntranceId)
        {
            if (string.IsNullOrEmpty(deviceCode))
            {
                throw new ArgumentNullException(nameof(deviceCode));
            }

            if (appEntranceId == Guid.Empty)
            {
                throw new ArgumentOutOfRangeException("must not be empty", nameof(appEntranceId));
            }

            if (Devices.ContainsKey(deviceCode))
            {
                var info = Devices[deviceCode];
                if (info.AppEntranceAuths.ContainsKey(appEntranceId))
                {
                    var auth = info.AppEntranceAuths[appEntranceId];
                    auth.LatestAuthed = DateTimeOffset.UtcNow;
                }
                else
                {
                    info.AppEntranceAuths[appEntranceId] = AppEntranceAuth.Create();
                }
            }
            else
            {
                Devices[deviceCode] = DeviceBindingInfo.Create(appEntranceId);
            }
        }
示例#2
0
 internal static DeviceBindingInfo Create(Guid appEntranceId)
 {
     return(new DeviceBindingInfo
     {
         AppEntranceAuths = new Dictionary <Guid, AppEntranceAuth>
         {
             [appEntranceId] = AppEntranceAuth.Create()
         }
     });
 }