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


C# AmazonS3Client.Dispose方法代码示例

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


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

示例1: RefreshAssetList

        public void RefreshAssetList()
        {
            string SecretKey = null;
            string PublicKey = null;
            AmazonS3Client Client = new AmazonS3Client(PublicKey, SecretKey);

            ListObjectsRequest Request = new ListObjectsRequest
            {
                BucketName = "assets.minecraft.net",
            };

            ListObjectsResponse Result;

            List<Release> releases = new List<Release>();
            do
            {
                Result = Client.ListObjects(Request);
                foreach (S3Object o in Result.S3Objects)
                {
                    string IsSnapshot = "Release";
                    if(!o.Key.Contains("minecraft.jar")) continue;
                    if (Regex.IsMatch(o.Key, "[0-9][0-9]w[0-9][0-9]")) IsSnapshot = "Snapshot";
                    else if (o.Key.Contains("pre")) IsSnapshot = "Pre-release";
                    releases.Add(new Release {  Version = o.Key.Split('/')[0],
                                                Size = (o.Size / 1024).ToString() + "KB",
                                                Uploaded = DateTime.Parse(o.LastModified),
                                                Type = IsSnapshot,
                                                Key = o.Key} );
                }
            }
            while (Result.IsTruncated);
            releases.Sort(new Comparison<Release>((x, y) => DateTime.Compare(y.Uploaded, x.Uploaded)));
            _Releases.Clear();
            foreach (Release r in releases)
            {
                _Releases.Add(r);
            }
            Client.Dispose();
            Result.Dispose();
        }
开发者ID:tman0,项目名称:MCLauncher2,代码行数:40,代码来源:SnapshotDownloader.xaml.cs

示例2: Main

        public static void Main()
        {
            Debug.WriteLine("============================================");
            Debug.WriteLine("Welcome to the AWS .NET SDK! Ready, Set, Go!");
            Debug.WriteLine("============================================");

            //The Amazon S3 client allows you to manage buckets and objects programmatically.
            IAmazonS3 s3Client = new AmazonS3Client();

            try
            {
                ListBucketsResponse response = s3Client.ListBuckets();
                int numBuckets = 0;
                if (response.Buckets != null && response.Buckets.Count > 0)
                {
                    numBuckets = response.Buckets.Count;
                }
                Debug.WriteLine("You have " + numBuckets + " Amazon S3 bucket(s)");
            }
            catch (Amazon.S3.AmazonS3Exception S3Exception)
            {
                //AmazonServiceException represents an error response from an AWS service.
                //AWS service received the request but either found it invalid or encountered an error trying to execute it.
                if (S3Exception.ErrorCode != null && (S3Exception.ErrorCode.Equals("InvalidAccessKeyId") || S3Exception.ErrorCode.Equals("InvalidSecurity")))
                {
                    Debug.WriteLine("Please check the provided AWS Credentials.");
                    Debug.Write("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
                    Debug.WriteLine(S3Exception.Message, S3Exception.InnerException);
                }
                else
                {
                    Debug.WriteLine("Error Message:    " + S3Exception.Message);
                    Debug.WriteLine("HTTP Status Code: " + S3Exception.StatusCode);
                    Debug.WriteLine("AWS Error Code:   " + S3Exception.ErrorCode);
                    Debug.WriteLine("Request ID:       " + S3Exception.RequestId);
                }
            }
            finally
            {
                s3Client.Dispose();
            };
        }
开发者ID:honux77,项目名称:aws-training-demo,代码行数:42,代码来源:ReadySetGo.cs


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