/// <summary>
        /// Initializes a new instance of the <see cref="PlayerProfileCI"/> class
        /// </summary>
        /// <param name="exportable">The <see cref="ExportablePlayerProfileCI"/> used to create instance</param>
        /// <param name="dataRouterManager">The <see cref="IDataRouterManager"/> used to fetch <see cref="PlayerProfileDTO"/></param>
        internal PlayerProfileCI(ExportablePlayerProfileCI exportable, IDataRouterManager dataRouterManager)
            : base(exportable)
        {
            _dataRouterManager = dataRouterManager ?? throw new ArgumentNullException(nameof(dataRouterManager));

            Import(exportable);
        }
 private void AddPlayerProfile(ExportablePlayerProfileCI item)
 {
     if (_cache.Contains(item.Id))
     {
         try
         {
             var ci = (PlayerProfileCI)_cache.Get(item.Id);
             _semaphoreCacheMerge.Wait();
             ci?.Import(item);
         }
         catch (Exception ex)
         {
             ExecutionLog.LogError($"Error importing player profile for id={item.Id}.", ex);
         }
         finally
         {
             if (!_isDisposed)
             {
                 _semaphoreCacheMerge.Release();
             }
         }
     }
     else
     {
         _cache.Add(item.Id, new PlayerProfileCI(item, _dataRouterManager), GetCorrectCacheItemPolicy(URN.Parse(item.Id)));
     }
 }
示例#3
0
        internal void Import(ExportablePlayerProfileCI exportable)
        {
            if (exportable == null)
            {
                throw new ArgumentNullException(nameof(exportable));
            }

            Names = exportable.Name.IsNullOrEmpty() ? new Dictionary <CultureInfo, string>() : new Dictionary <CultureInfo, string>(exportable.Name);
            if (!Names.IsNullOrEmpty())
            {
                _fetchedCultures = new List <CultureInfo>(exportable.Name.Keys);
                _primaryCulture  = exportable.Name.Keys.First();
            }
            _nationalities = exportable.Nationalities.IsNullOrEmpty() ? new Dictionary <CultureInfo, string>() : new Dictionary <CultureInfo, string>(exportable.Nationalities);
            _type          = exportable.Type;
            _dateOfBirth   = exportable.DateOfBirth;
            _height        = exportable.Height;
            _weight        = exportable.Weight;
            _abbreviation  = exportable.Abbreviation;
            _gender        = exportable.Gender;
            _competitorId  = string.IsNullOrEmpty(exportable.CompetitorId) ? null : URN.Parse(exportable.CompetitorId);
            CountryCode    = exportable.CountryCode;
            FullName       = exportable.FullName;
            Nickname       = exportable.Nickname;
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayerProfileCI"/> class
        /// </summary>
        /// <param name="exportable">The <see cref="ExportablePlayerProfileCI"/> used to create instance</param>
        /// <param name="dataRouterManager">The <see cref="IDataRouterManager"/> used to fetch <see cref="PlayerProfileDTO"/></param>
        internal PlayerProfileCI(ExportablePlayerProfileCI exportable, IDataRouterManager dataRouterManager)
            : base(exportable)
        {
            if (exportable == null)
            {
                throw new ArgumentNullException(nameof(exportable));
            }

            if (dataRouterManager == null)
            {
                throw new ArgumentNullException(nameof(dataRouterManager));
            }

            _fetchedCultures = new List <CultureInfo>(exportable.Name.Keys);
            _primaryCulture  = exportable.Name.Keys.First();

            _dataRouterManager = dataRouterManager;

            Names          = new Dictionary <CultureInfo, string>(exportable.Name);
            _nationalities = new Dictionary <CultureInfo, string>(exportable.Nationalities);
            _type          = exportable.Type;
            _dateOfBirth   = exportable.DateOfBirth;
            _height        = exportable.Height;
            _weight        = exportable.Weight;
            _abbreviation  = exportable.Abbreviation;
            _gender        = exportable.Gender;
            _competitorId  = exportable.CompetitorId;
        }
示例#5
0
 private void AddPlayerProfile(ExportablePlayerProfileCI item)
 {
     if (_cache.Contains(item.Id))
     {
         var itemId = URN.Parse(item.Id);
         try
         {
             var ci = (PlayerProfileCI)_cache.Get(item.Id);
             WaitTillIdIsAvailable(_mergeUrns, itemId);
             ci?.Import(item);
         }
         catch (Exception ex)
         {
             ExecutionLog.LogError(ex, $"Error importing player profile for id={item.Id}.");
         }
         finally
         {
             if (!_isDisposed)
             {
                 ReleaseId(_mergeUrns, itemId);
             }
         }
     }
     else
     {
         _cache.Add(item.Id, new PlayerProfileCI(item, _dataRouterManager), GetCorrectCacheItemPolicy(URN.Parse(item.Id)));
     }
 }