public DataRecord GetResource(UnactualResourceContent resource) { try { _resourceWriterQueueLock.EnterReadLock(); return _resourcesToWrite.FirstOrDefault(k => k.Content.Equals(resource)); } finally { _resourceWriterQueueLock.ExitReadLock(); } }
/// <summary> /// Публикует изменение актуальности ресурса. /// </summary> /// <param name="resourceName">Name of the resource.</param> /// <param name="id">The id.</param> public void AnnonunceUnactuality(string resourceName, Guid id) { var res = new UnactualResourceContent { ResourceKey = id, ResourceName = resourceName }; if (_totalSubscriptions.Contains(resourceName) || _subscriptions[resourceName].Contains(id)) { foreach (AnnouncerUplink uplink in _uplinks) { uplink.OnNext(res); } } if (_issuedTokens.ContainsKey(resourceName)) { _issuedTokens[resourceName].InvokeUnactuality(res); } }
public DataRecord(Action updateSender, Action<Guid, object> poster, object resource, UnactualResourceContent content) : this(poster, resource, content) { UpdateSender = updateSender; }
public DataRecord(Action<Guid, object> poster, object resource, UnactualResourceContent content) : this(content, resource) { Poster = poster; }
public DataRecord(UnactualResourceContent content, object resource) { Content = content; Resource = resource; }
public void AddResourceToLocalTransaction(UnactualResourceContent description,object resource) { try { _resourceWriterQueueLock.EnterUpgradeableReadLock(); var existingResource = _resourcesInLocalTransaction.FirstOrDefault(k => k.Content.Equals(description)); try { _resourceWriterQueueLock.EnterWriteLock(); if (existingResource != null) //если найден уже записанный в данной транзакции ресурс existingResource.Resource = resource; else _resourcesInLocalTransaction.Add(new DataRecord(description,resource)); } finally { _resourceWriterQueueLock.ExitWriteLock(); } } finally { _resourceWriterQueueLock.ExitUpgradeableReadLock(); } }