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


C# IDictionary.AssertIsNotNull方法代码示例

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


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

示例1: StorageAccount

        /// <summary>
        /// Creates a new instance of the StorageAccount class.
        /// </summary>
        /// <param name="name">The name of the account.</param>
        /// <param name="totalBytes">The total number of bytes used in the account.</param>
        /// <param name="totalObjects">The total number of storage objects in the account.</param>
        /// <param name="totalContainers">The total number of storage containers in the account.</param>
        /// <param name="metadata">Metadata associated with this account.</param>
        /// <param name="containers">A list of storage containers in the account.</param>
        internal StorageAccount(string name, long totalBytes, int totalObjects, int totalContainers, IDictionary<string, string> metadata, IEnumerable<StorageContainer> containers)
        {
            name.AssertIsNotNullOrEmpty("name");
            totalBytes.AssertIsNotNull("totalBytes");
            totalObjects.AssertIsNotNull("totalObjects");
            metadata.AssertIsNotNull("metadata");
            containers.AssertIsNotNull("containers");

            this.Name = name;
            this.TotalBytesUsed = totalBytes;
            this.TotalObjectCount = totalObjects;
            this.TotalContainerCount = totalContainers;
            this.Containers = containers.ToList();
            this.Metadata = metadata;
        }
开发者ID:jasonzhuyx,项目名称:openstack-sdk-dotnet,代码行数:24,代码来源:StorageAccount.cs

示例2: Create

        /// <inheritdoc/>
        public async Task<StorageObject> Create(string containerName, string objectName, IDictionary<string, string> metadata, Stream content, int numberOfSegments, string segmentsContainer)
        {
            containerName.AssertIsNotNullOrEmpty("containerName", "Cannot create a large storage object with a null or empty container name.");
            objectName.AssertIsNotNullOrEmpty("objectName", "Cannot create a large storage object with a null or empty name.");
            metadata.AssertIsNotNull("metadata", "Cannot create a large storage object with null metadata.");
            content.AssertIsNotNull("content", "Cannot create a large storage object with null content.");
            segmentsContainer.AssertIsNotNullOrEmpty("segmentsContainer","Cannot  create a large object with a null or empty segments container name.");

            if (numberOfSegments <= 0)
            {
                throw new ArgumentException("Cannot create a large object with zero or less segments.", "numberOfSegments");
            }
            
            var segmentFolder = await this.GetSegmentsFolder(segmentsContainer, objectName);

            var chunkSize = this.GetChunkSize(content.Length, numberOfSegments);
            var lastSegmentAndId = this.GetLastSegmentIdAndName(segmentFolder);
            var lastSegmentId = lastSegmentAndId.Key;
            var lastSegmentFullName = string.Format("{0}/{1}", objectName, lastSegmentAndId.Value);
            var offset = lastSegmentId * chunkSize;
            
            if (lastSegmentId > 0)
            {
                //we should drop the last segment (as it's very possible it was corrupted)
                await StorageClient.DeleteStorageObject(segmentsContainer, lastSegmentFullName);
            }

            //Seek to the correct location based on whatever segments have been uploaded, if any
            content.Seek(offset, SeekOrigin.Begin);

            while (content.Position < content.Length)
            {
                //If the remaining data in the stream is less then the chunk size, reset the chunk size to the remaining data size.
                if ((content.Length - content.Position) < chunkSize)
                {
                    chunkSize = (content.Length - content.Position);
                }

                await CreateSegment(content, chunkSize, objectName, lastSegmentId, metadata, segmentsContainer);
                lastSegmentId++;
            }

            var segments = await StorageClient.GetStorageFolder(segmentsContainer, objectName);

            return await CreateLargeObjectManifest(containerName, objectName, metadata, segments.Objects, segmentsContainer);
        }
开发者ID:jasonzhuyx,项目名称:openstack-sdk-dotnet,代码行数:47,代码来源:LargeStorageObjectCreator.cs

示例3: CreateStaticManifest

        /// <inheritdoc/>
        public async Task<IHttpResponseAbstraction> CreateStaticManifest(string containerName, string manifestName, IDictionary<string, string> metadata, Stream content)
        {
            AssertContainerNameIsValid(containerName);
            manifestName.AssertIsNotNullOrEmpty("manifestName", "Cannot create a storage manifest with a null or empty name.");
            metadata.AssertIsNotNull("metadata", "Cannot create a storage manifest with null metadata.");
            content.AssertIsNotNull("content","Cannot create a static large object manifest with null content.");

            var client = this.GetHttpClient(this.Context);

            var baseUri = CreateRequestUri(this.Context.PublicEndpoint, containerName);
            client.Uri = new Uri(string.Format("{0}/{1}?multipart-manifest=put", baseUri, manifestName));
            client.Method = HttpMethod.Put;
            client.Content = content;

            this.AddObjectMetadata(metadata, client);

            return await client.SendAsync();
        }
开发者ID:jasonzhuyx,项目名称:openstack-sdk-dotnet,代码行数:19,代码来源:StorageServiceRestClient.cs

示例4: CreateDynamicManifest

        /// <inheritdoc/>
        public async Task<IHttpResponseAbstraction> CreateDynamicManifest(string containerName, string manifestName, IDictionary<string, string> metadata, string segmentsPath)
        {
            AssertContainerNameIsValid(containerName);
            manifestName.AssertIsNotNullOrEmpty("manifestName","Cannot create a storage manifest with a null or empty name.");
            segmentsPath.AssertIsNotNullOrEmpty("segmentsPath","Cannot create a dynamic large object manifest with a null or empty segments path.");
            metadata.AssertIsNotNull("metadata","Cannot create a storage manifest with null metadata.");

            var client = this.GetHttpClient(this.Context);

            client.Uri = CreateRequestUri(this.Context.PublicEndpoint, containerName, manifestName);
            client.Method = HttpMethod.Put;
            client.Content = new MemoryStream();

            client.Headers.Add("X-Object-Manifest", segmentsPath);
            this.AddObjectMetadata(metadata, client);

            return await client.SendAsync();
        }
开发者ID:jasonzhuyx,项目名称:openstack-sdk-dotnet,代码行数:19,代码来源:StorageServiceRestClient.cs

示例5: Convert

        /// <inheritdoc/>
        public string Convert(IDictionary<string, string> metadata)
        {
            metadata.AssertIsNotNull("metadata", "Cannot convert compute item metadata with null metadata.");
            
            var payload = new StringBuilder();
            payload.Append("{ \"metadata\" : {");
            var isFirst = true;

            foreach (var item in metadata)
            {
                if (!isFirst)
                {
                    payload.Append(",");
                }

                payload.AppendFormat("\"{0}\":\"{1}\"",item.Key, item.Value);
                isFirst = false;
            }

            payload.Append("}}");
            return payload.ToString();
        }
开发者ID:jasonzhuyx,项目名称:openstack-sdk-dotnet,代码行数:23,代码来源:ComputeItemMetadataPayloadConverter.cs

示例6: StorageContainer

        /// <summary>
        /// Creates a new instance of the StorageContainer class.
        /// </summary>
        /// <param name="name">The name of the storage container.</param>
        /// <param name="totalBytes">The total number of bytes used in the container.</param>
        /// <param name="totalObjects">The total number of objects in the container.</param>
        /// <param name="objects">A list of storage objects that are in the container.</param>
        /// <param name="folders">A list of storage folders that are in the container.</param>
        /// <param name="metadata">Metadata associated with the storage container.</param>
        internal StorageContainer(string name, long totalBytes, int totalObjects, IDictionary<string, string> metadata, IEnumerable<StorageObject> objects, IEnumerable<StorageFolder> folders)
        {
            name.AssertIsNotNullOrEmpty("name");
            totalBytes.AssertIsNotNull("totalBytes");
            totalObjects.AssertIsNotNull("totalObjects");
            metadata.AssertIsNotNull("metadata");
            objects.AssertIsNotNull("objects");
            folders.AssertIsNotNull("folders");

            this.Name = name;
            this.TotalBytesUsed = totalBytes;
            this.TotalObjectCount = totalObjects;
            this.Objects = objects.ToList();
            this.Folders = folders.ToList();
            this.Metadata = metadata;
        }
开发者ID:jasonzhuyx,项目名称:openstack-sdk-dotnet,代码行数:25,代码来源:StorageContainer.cs

示例7: CreateLargeStorageObject

        /// <inheritdoc/>
        public async Task<StorageObject> CreateLargeStorageObject(string containerName, string objectName, IDictionary<string, string> metadata, Stream content, int numberOfSegments)
        {
            containerName.AssertIsNotNullOrEmpty("containerName", "Cannot create a large storage object with a null or empty container name.");
            objectName.AssertIsNotNullOrEmpty("objectName", "Cannot create a large storage object with a null or empty name.");
            metadata.AssertIsNotNull("metadata", "Cannot create a large storage object with null metadata.");
            content.AssertIsNotNull("content", "Cannot create a large storage object with null content.");

            if (numberOfSegments <= 0)
            {
                throw new ArgumentException("Cannot create a large object with zero or less segments.", "numberOfSegments");
            }

            var factory = this.ServiceLocator.Locate<ILargeStorageObjectCreatorFactory>();
            var creator = factory.Create(this);
            return await creator.Create(containerName, objectName, metadata, content, numberOfSegments, this.LargeObjectSegmentContainer);
        }
开发者ID:jasonzhuyx,项目名称:openstack-sdk-dotnet,代码行数:17,代码来源:StorageServiceClient.cs

示例8: CreateStorageManifest

        /// <inheritdoc/>
        public async Task<StorageManifest> CreateStorageManifest(string containerName, string manifestName, IDictionary<string, string> metadata, string segmentsPath)
        {
            containerName.AssertIsNotNullOrEmpty("containerName", "Cannot create a storage manifest with a container name that is null or empty.");
            manifestName.AssertIsNotNullOrEmpty("manifestNamee", "Cannot create a storage manifest with a name that is null or empty.");
            metadata.AssertIsNotNull("metadata", "Cannot create a storage manifest with null metadata.");
            segmentsPath.AssertIsNotNullOrEmpty("segmentsPath", "Cannot create storage manifest with a null or empty segments path.");

            var client = this.GetPocoClient();

            var manifest = new  DynamicLargeObjectManifest(containerName, manifestName, metadata, segmentsPath);

            return await client.CreateStorageManifest(manifest);
        }
开发者ID:jasonzhuyx,项目名称:openstack-sdk-dotnet,代码行数:14,代码来源:StorageServiceClient.cs

示例9: StorageObject

        /// <summary>
        /// Creates a new instance of the StorageObject class.
        /// </summary>
        /// <param name="fullName">The full name of the storage object.</param>
        /// <param name="containerName">The name of the parent storage container for the storage object.</param>
        /// <param name="lastModified">The last modified data for the storage object.</param>
        /// <param name="eTag">The ETag for the storage object.</param>
        /// <param name="length">The length/size of the storage object.</param>
        /// <param name="contentType">The content type of the storage object.</param>
        /// <param name="metadata">The metadata associated with the storage object.</param>
        internal StorageObject(string fullName, string containerName, DateTime lastModified, string eTag, long length, string contentType, IDictionary<string, string> metadata) : base(fullName, contentType)
        {
            containerName.AssertIsNotNullOrEmpty("containerName");
            lastModified.AssertIsNotNull("lastModified");
            eTag.AssertIsNotNull("eTag");
            length.AssertIsNotNull("length");
            metadata.AssertIsNotNull("metadata");

            this.ContainerName = containerName;
            this.LastModified = lastModified;
            this.ETag = eTag;
            this.Length = length;
            this.Metadata = metadata;
        }
开发者ID:jasonzhuyx,项目名称:openstack-sdk-dotnet,代码行数:24,代码来源:StorageObject.cs

示例10: UpdateImageMetadata

        /// <inheritdoc/>
        public async Task UpdateImageMetadata(string imageId, IDictionary<string, string> metadata)
        {
            imageId.AssertIsNotNullOrEmpty("imageId", "Cannot update compute image metadata with a null or empty id.");
            metadata.AssertIsNotNull("metadata", "Cannot update compute image metadata with a null or empty metadata.");

            var client = this.GetPocoClient();
            await client.UpdateImageMetadata(imageId, metadata);
        }
开发者ID:jasonzhuyx,项目名称:openstack-sdk-dotnet,代码行数:9,代码来源:ComputeServiceClient.cs

示例11: UpdateServerMetadata

        /// <inheritdoc/>
        public async Task UpdateServerMetadata(string serverId, IDictionary<string, string> metadata)
        {
            serverId.AssertIsNotNullOrEmpty("flavorId", "Cannot update compute server metadata with a null or empty id.");
            metadata.AssertIsNotNull("metadata", "Cannot update compute server metadata with a null or empty metadata.");

            var client = this.GetPocoClient();
            await client.UpdateServerMetadata(serverId, metadata);
        }
开发者ID:jasonzhuyx,项目名称:openstack-sdk-dotnet,代码行数:9,代码来源:ComputeServiceClient.cs


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