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


C# NameValueCollection.Value方法代码示例

本文整理汇总了C#中System.Collections.Specialized.NameValueCollection.Value方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.Value方法的具体用法?C# NameValueCollection.Value怎么用?C# NameValueCollection.Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.Specialized.NameValueCollection的用法示例。


在下文中一共展示了NameValueCollection.Value方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateFileMetadata

		public void UpdateFileMetadata(string filename, NameValueCollection metadata)
		{
			Api.JetSetCurrentIndex(session, Files, "by_name");
			Api.MakeKey(session, Files, filename, Encoding.Unicode, MakeKeyGrbit.NewKey);
			if (Api.TrySeek(session, Files, SeekGrbit.SeekEQ) == false)
				throw new FileNotFoundException(filename);

			using (var update = new Update(session, Files, JET_prep.Replace))
			{
				if (!metadata.AllKeys.Contains("ETag"))
				{
					throw new InvalidOperationException("Metadata of file {0} does not contain 'ETag' key " + filename);
				}

				var innerEsentMetadata = new NameValueCollection(metadata);

				var etag = innerEsentMetadata.Value<Guid>("ETag");
				innerEsentMetadata.Remove("ETag");

				var existingMetadata = RetrieveMetadata();

				if (existingMetadata.AllKeys.Contains("Content-MD5"))
				{
					innerEsentMetadata["Content-MD5"] = existingMetadata["Content-MD5"];
				}

				Api.SetColumn(session, Files, tableColumnsCache.FilesColumns["etag"], etag.TransformToValueForEsentSorting());
				Api.SetColumn(session, Files, tableColumnsCache.FilesColumns["metadata"], ToQueryString(innerEsentMetadata),
				              Encoding.Unicode);

				update.Save();
			}
		}
开发者ID:hibernating-rhinos,项目名称:RavenFS,代码行数:33,代码来源:StorageActionsAccessor.cs

示例2: UpdateFileMetadata

        public void UpdateFileMetadata(string filename, NameValueCollection metadata)
        {
            var key = CreateKey(filename);

            ushort version;
            var file = LoadJson(storage.Files, key, writeBatch.Value, out version);
            if (file == null)
                throw new FileNotFoundException(filename);

            if (!metadata.AllKeys.Contains("ETag"))
                throw new InvalidOperationException(string.Format("Metadata of file {0} does not contain 'ETag' key", filename));

            var innerMetadata = new NameValueCollection(metadata);
            var etag = innerMetadata.Value<Guid>("ETag");
            innerMetadata.Remove("ETag");

            var existingMetadata = RetrieveMetadata(file);
            if (existingMetadata.AllKeys.Contains("Content-MD5"))
                innerMetadata["Content-MD5"] = existingMetadata["Content-MD5"];

	        var oldEtag = file.Value<string>("etag");

            file["etag"] = etag.ToString();
            file["metadata"] = ToQueryString(innerMetadata);

            storage.Files.Add(writeBatch.Value, key, file, version);

			var filesByEtag = storage.Files.GetIndex(Tables.Files.Indices.ByEtag);

			filesByEtag.Delete(writeBatch.Value, CreateKey(oldEtag));
			filesByEtag.Add(writeBatch.Value, CreateKey(etag), key);
        }
开发者ID:randacc,项目名称:ravendb,代码行数:32,代码来源:StorageActionsAccessor.cs

示例3: PutFile

		public void PutFile(string filename, long? totalSize, NameValueCollection metadata, bool tombstone = false)
		{
			using (var update = new Update(session, Files, JET_prep.Insert))
			{
				Api.SetColumn(session, Files, tableColumnsCache.FilesColumns["name"], filename, Encoding.Unicode);
				if (totalSize != null)
					Api.SetColumn(session, Files, tableColumnsCache.FilesColumns["total_size"], BitConverter.GetBytes(totalSize.Value));

				Api.SetColumn(session, Files, tableColumnsCache.FilesColumns["uploaded_size"], BitConverter.GetBytes(0));

				if (!metadata.AllKeys.Contains("ETag"))
					throw new InvalidOperationException(string.Format("Metadata of file {0} does not contain 'ETag' key", filename));

				var innerEsentMetadata = new NameValueCollection(metadata);

				var etag = innerEsentMetadata.Value<Guid>("ETag");
				innerEsentMetadata.Remove("ETag");

				Api.SetColumn(session, Files, tableColumnsCache.FilesColumns["etag"], etag.TransformToValueForEsentSorting());
				Api.SetColumn(session, Files, tableColumnsCache.FilesColumns["metadata"], ToQueryString(innerEsentMetadata),
				              Encoding.Unicode);

				update.Save();
			}

			if (!tombstone)
			{
				if (Api.TryMoveFirst(session, Details) == false)
					throw new InvalidOperationException("Could not find system metadata row");

				Api.EscrowUpdate(session, Details, tableColumnsCache.DetailsColumns["file_count"], 1);
			}
		}
开发者ID:hibernating-rhinos,项目名称:RavenFS,代码行数:33,代码来源:StorageActionsAccessor.cs

示例4: PutFile

        public void PutFile(string filename, long? totalSize, NameValueCollection metadata, bool tombstone = false)
        {
            var filesByEtag = storage.Files.GetIndex(Tables.Files.Indices.ByEtag);

            var key = CreateKey(filename);

            if (!metadata.AllKeys.Contains("ETag"))
                throw new InvalidOperationException(string.Format("Metadata of file {0} does not contain 'ETag' key", filename));
			
			ushort version;
	        var existingFile = LoadJson(storage.Files, key, writeBatch.Value, out version);

            var innerMetadata = new NameValueCollection(metadata);
            var etag = innerMetadata.Value<Guid>("ETag");
            innerMetadata.Remove("ETag");

            var file = new RavenJObject
                       {
                           { "name", filename }, 
                           { "total_size", totalSize }, 
                           { "uploaded_size", 0 }, 
                           { "etag", etag.ToString() }, 
                           { "metadata", ToQueryString(innerMetadata) }
                       };

            storage.Files.Add(writeBatch.Value, key, file, version);

	        if (existingFile != null)
	        {
		        filesByEtag.Delete(writeBatch.Value, CreateKey(existingFile.Value<string>("etag")));
	        }

	        filesByEtag.Add(writeBatch.Value, CreateKey(etag), key);

            if (tombstone)
                return;

            var fileCount = storage.Files.GetIndex(Tables.Files.Indices.Count);
            fileCount.Add(writeBatch.Value, key, key);
        }
开发者ID:randacc,项目名称:ravendb,代码行数:40,代码来源:StorageActionsAccessor.cs


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