コード例 #1
0
 public DataRecord GetResource(UnactualResourceContent resource)
 {
     try
     {
         _resourceWriterQueueLock.EnterReadLock();
         return _resourcesToWrite.FirstOrDefault(k => k.Content.Equals(resource));
     }
     finally
     {
         _resourceWriterQueueLock.ExitReadLock();
     }
 }
コード例 #2
0
        /// <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);
            }
        }
コード例 #3
0
ファイル: DataRecord.cs プロジェクト: kayanme/Dataspace
 public DataRecord(Action updateSender, Action<Guid, object> poster, object resource, UnactualResourceContent content)
     : this(poster, resource, content)
 {
     UpdateSender = updateSender;
 }
コード例 #4
0
ファイル: DataRecord.cs プロジェクト: kayanme/Dataspace
 public DataRecord(Action<Guid, object> poster, object resource, UnactualResourceContent content)
     : this(content, resource)
 {
     Poster = poster;
 }
コード例 #5
0
ファイル: DataRecord.cs プロジェクト: kayanme/Dataspace
 public DataRecord(UnactualResourceContent content, object resource)
 {
     Content = content;
     Resource = resource;
 }
コード例 #6
0
        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();
                }
            
        }