Inheritance: IDisposable
コード例 #1
0
		protected StorageStream(TransactionalStorage transactionalStorage, string fileName,
		                        StorageStreamAccess storageStreamAccess,
		                        NameValueCollection metadata, IndexStorage indexStorage, StorageOperationsTask operations)
		{
			TransactionalStorage = transactionalStorage;
			StorageStreamAccess = storageStreamAccess;
			Name = fileName;

			switch (storageStreamAccess)
			{
				case StorageStreamAccess.Read:
					TransactionalStorage.Batch(accessor => fileHeader = accessor.ReadFile(fileName));
					if (fileHeader.TotalSize == null)
					{
						throw new FileNotFoundException("File is not uploaded yet");
					}
					Metadata = fileHeader.Metadata;
					Seek(0, SeekOrigin.Begin);
					break;
				case StorageStreamAccess.CreateAndWrite:
					TransactionalStorage.Batch(accessor =>
						                           {
							                           operations.IndicateFileToDelete(fileName);
							                           accessor.PutFile(fileName, null, metadata);
							                           indexStorage.Index(fileName, metadata);
						                           });
					Metadata = metadata;
					break;
				default:
					throw new ArgumentOutOfRangeException("storageStreamAccess", storageStreamAccess, "Unknown value");
			}
		}
コード例 #2
0
		public StorageOperationsTask(TransactionalStorage storage, IndexStorage search, INotificationPublisher notificationPublisher)
		{
			this.storage = storage;
			this.search = search;
			this.notificationPublisher = notificationPublisher;

			InitializeTimer();
		}
コード例 #3
0
		public ConflictArtifactManager(TransactionalStorage storage, IndexStorage index)
		{
			this.storage = storage;
			this.index = index;
		}
コード例 #4
0
		public static StorageStream CreatingNewAndWritting(TransactionalStorage transactionalStorage,
		                                                   IndexStorage indexStorage, StorageOperationsTask operations,
		                                                   string fileName, NameValueCollection metadata)
		{
			if (indexStorage == null)
				throw new ArgumentNullException("indexStorage", "indexStorage == null");

			return new StorageStream(transactionalStorage, fileName, StorageStreamAccess.CreateAndWrite, metadata, indexStorage, operations);
		}