当前位置: 首页>>代码示例>>C#>>正文


C# FileSystem.FileHeader类代码示例

本文整理汇总了C#中Raven.Abstractions.FileSystem.FileHeader的典型用法代码示例。如果您正苦于以下问题:C# FileHeader类的具体用法?C# FileHeader怎么用?C# FileHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileHeader类属于Raven.Abstractions.FileSystem命名空间,在下文中一共展示了FileHeader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadFileAsync

        public async Task<FileHeader> LoadFileAsync(string filename)
        {
            if (string.IsNullOrWhiteSpace(filename))
                throw new ArgumentNullException("filename", "The filename cannot be null, empty or whitespace.");

			FileHeader existingEntity;
            if (entitiesByKey.TryGetValue(filename, out existingEntity))
            {
                // Check if the file is not currently been scheduled for deletion or known to be non-existent.
                if (!this.IsDeleted(filename))
                    return existingEntity;
                else
                    return null;
            }

            IncrementRequestCount();            

            // Check if the file exists on the server.
            var metadata = await Commands.GetMetadataForAsync(filename);
            if (metadata == null)
                return null;

            var fileHeader = new FileHeader(filename, metadata);
            AddToCache(filename, fileHeader);

            return fileHeader;
        }
开发者ID:GorelH,项目名称:ravendb,代码行数:27,代码来源:AsyncFilesSession.cs

示例2: UpdateMetadataOperation

        public UpdateMetadataOperation(InMemoryFilesSessionOperations sessionOperations, FileHeader fileHeader, RavenJObject metadata)
        {
            if (fileHeader != null && string.IsNullOrWhiteSpace(fileHeader.FullPath))
                throw new ArgumentNullException("fileHeader", "The file cannot be null or have an empty or whitespace name.");

            this.sessionOperations = sessionOperations;

            this.FileHeader = fileHeader;
            this.Filename = fileHeader.FullPath;
            this.Metadata = metadata;
        }
开发者ID:cocytus,项目名称:ravendb,代码行数:11,代码来源:UpdateMetadataOperation.cs

示例3: UpdateMetadataOperation

        public UpdateMetadataOperation(InMemoryFilesSessionOperations sessionOperations, FileHeader fileHeader, RavenJObject metadata, Etag etag)
        {
            if (fileHeader == null || string.IsNullOrWhiteSpace(fileHeader.FullPath))
                throw new ArgumentNullException("fileHeader", "The file cannot be null or have an empty or whitespace name!");

            this.sessionOperations = sessionOperations;

            FileHeader = fileHeader;
            FileName = fileHeader.FullPath;
            Metadata = metadata;
            Etag = etag;
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:12,代码来源:UpdateMetadataOperation.cs

示例4: ConflictNotificationSerialization

        public void ConflictNotificationSerialization()
        {
			var metadata = new RavenJObject { { Constants.LastModified, "2014-07-07T12:00:00.0000000" }, { Constants.FileSystem.RavenFsSize, "128" } };
            var fileHeader = new FileHeader("test1.file", metadata);
            var notification = new ConflictNotification() { FileName = "test1.file", SourceServerUrl = "http://destination", RemoteFileHeader = fileHeader, Status = ConflictStatus.Detected};

            var serializedValue = JsonExtensions.ToJObject(notification);

            var jr = new RavenJTokenReader(serializedValue);
            var deserializedValue = JsonExtensions.CreateDefaultJsonSerializer().Deserialize<ConflictNotification>(jr);

            Assert.NotNull(deserializedValue);
        }
开发者ID:GorelH,项目名称:ravendb,代码行数:13,代码来源:SerializationTests.cs

示例5: FileHeaderSerialization

        public void FileHeaderSerialization()
        {
			var metadata = new RavenJObject { { Constants.LastModified, "2014-07-07T12:00:00.0000000" }, { Constants.FileSystem.RavenFsSize, "128" } };
            var fileHeader = new FileHeader("test1.file", metadata);

            var serializedValue = JsonExtensions.ToJObject(fileHeader);

            var jr = new RavenJTokenReader(serializedValue);
            var deserializedValue = JsonExtensions.CreateDefaultJsonSerializer().Deserialize<FileHeader>(jr);

            Assert.NotNull(deserializedValue);
            Assert.Equal(fileHeader.Name, deserializedValue.Name);
            Assert.Equal(fileHeader.LastModified, deserializedValue.LastModified);
        }
开发者ID:GorelH,项目名称:ravendb,代码行数:14,代码来源:SerializationTests.cs

示例6: Filter

        public bool Filter(FileHeader file, Guid destinationId, IEnumerable<FileHeader> candidatesToSynchronization)
		{
			// prevent synchronization back to source
			if (file.Metadata.Value<Guid>(SynchronizationConstants.RavenSynchronizationSource) == destinationId)
				return false;

            if (file.FullPath.EndsWith(RavenFileNameHelper.DownloadingFileSuffix))
				return false;

            if (file.FullPath.EndsWith(RavenFileNameHelper.DeletingFileSuffix))
				return false;

			if (file.IsFileBeingUploadedOrUploadHasBeenBroken())
				return false;

            if (ExistsRenameTombstone(file.FullPath, candidatesToSynchronization))
				return false;

			return true;
		}
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:20,代码来源:SynchronizationStrategy.cs

示例7: RegisterFileDeletion

        public void RegisterFileDeletion(FileHeader file, Etag etag = null)
        {
			deletedEntities.Add(file.Directory);

			var operation = new DeleteFileOperation(this, file.Directory, etag);

            IncrementRequestCount();

            registeredOperations.Enqueue(operation); 
        }
开发者ID:bbqchickenrobot,项目名称:ravendb,代码行数:10,代码来源:InMemoryFilesSessionOperations.cs

示例8: GetSmallest

        private FileHeader GetSmallest(FileHeader[][] applyAsync, int[] indexes, int[] originalIndexes)
        {
            FileHeader smallest = null;
            var smallestIndex = -1;
            for (var i = 0; i < applyAsync.Length; i++)
            {

                var pos = indexes[i] - originalIndexes[i];
                if (pos >= applyAsync[i].Length)
                    continue;

                var current = applyAsync[i][pos];
                if (smallest == null ||
                    string.Compare(current.FullPath, smallest.FullPath, StringComparison.OrdinalIgnoreCase) < 0)
                {
                    smallest = current;
                    smallestIndex = i;
                }
            }

            if (smallestIndex != -1)
                indexes[smallestIndex]++;

            return smallest;
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:25,代码来源:AsyncShardedFilesServerClient.cs

示例9: CompareFileInfos

        private int CompareFileInfos(FileHeader current, FileHeader smallest, string[] sortFields)
        {
            if (sortFields == null || sortFields.Length == 0)
            {
                return string.Compare(current.FullPath, smallest.FullPath, StringComparison.OrdinalIgnoreCase);
            }
            foreach (var sortField in sortFields)
            {
                var field = sortField;
                var multiplay = 1; //for asending decending
                if (sortField.StartsWith("-"))
                {
                    field = sortField.TrimStart(new[] { '-' });
                    multiplay = -1;
                }

                if (field.Equals("__size", StringComparison.OrdinalIgnoreCase))
                {
                    var currentItem = current.TotalSize;
                    var smallestItem = smallest.TotalSize;

                    if (currentItem == null && smallestItem == null)
                        continue;

                    if (currentItem == null)
                        return 1 * multiplay;

                    if (smallestItem == null)
                        return -1 * multiplay;


                    var compare = (long)(currentItem - smallestItem);
                    if (compare != 0)
                        return Math.Sign(compare) * multiplay;
                }
                else
                {
                    var currentItem = current.Metadata.Value<string>(field);
                    var smallestItem = smallest.Metadata.Value<string>(field);
                    
                    var compare = string.Compare(currentItem, smallestItem, StringComparison.OrdinalIgnoreCase);
                    if (compare != 0)
                        return compare * multiplay;
                }
            }

            return 0;
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:48,代码来源:AsyncShardedFilesServerClient.cs

示例10: TryGetFromCache

        internal bool TryGetFromCache(string filename, out FileHeader fileHeader)
        {
            fileHeader = null;

            if (entitiesByKey.ContainsKey(filename))
                fileHeader = entitiesByKey[filename];

            return fileHeader != null;
        }
开发者ID:GorelH,项目名称:ravendb,代码行数:9,代码来源:InMemoryFilesSessionOperations.cs

示例11: EntityChanged

        public bool EntityChanged(FileHeader fileHeader)
        {
            if (fileHeader == null)
                return true;

            return RavenJToken.DeepEquals(fileHeader.Metadata, fileHeader.OriginalMetadata, null) == false;
        }
开发者ID:GorelH,项目名称:ravendb,代码行数:7,代码来源:InMemoryFilesSessionOperations.cs

示例12: RegisterRename

 public void RegisterRename(FileHeader sourceFile, string destinationFile, Etag etag = null)
 {
     RegisterRename(sourceFile.FullPath, destinationFile, etag);
 }
开发者ID:GorelH,项目名称:ravendb,代码行数:4,代码来源:InMemoryFilesSessionOperations.cs

示例13: AddToCache

        public void AddToCache(string filename, FileHeader fileHeader)
        {
            if (!entitiesByKey.ContainsKey(filename))
                entitiesByKey.Add(filename, fileHeader);
            else
                entitiesByKey[filename] = fileHeader;

            if (this.IsDeleted(filename))
                knownMissingIds.Remove(filename);
        }
开发者ID:GorelH,项目名称:ravendb,代码行数:10,代码来源:InMemoryFilesSessionOperations.cs

示例14: ConflictResolved

 public void ConflictResolved(FileHeader header)
 {
     ResolvedCount++;
 }
开发者ID:heinnge,项目名称:ravendb,代码行数:4,代码来源:FileSessionListenersTests.cs

示例15: RegisterFileDeletion

        public void RegisterFileDeletion(FileHeader file, Etag etag = null)
        {
			RegisterFileDeletion(file.FullPath, etag);
        }
开发者ID:GorelH,项目名称:ravendb,代码行数:4,代码来源:InMemoryFilesSessionOperations.cs


注:本文中的Raven.Abstractions.FileSystem.FileHeader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。