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


C# CloudBlob.DownloadText方法代码示例

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


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

示例1: appendToBlob

        private const string MimeTypeName = "text/plain"; // since these are assumed to

        #endregion Fields

        #region Methods

        /// <summary>
        /// ugliness of downloading and reuploading whole blob.
        /// </summary>
        /// <param name="blob"></param>
        /// <param name="toAdd"></param>
        public static void appendToBlob(CloudBlob blob, string toAdd)
        {
            string oldLogData = "";
            if (Exists(blob))
                oldLogData = blob.DownloadText();
            blob.DeleteIfExists();
            blob.UploadText(oldLogData + "\r\n" + toAdd);
        }
开发者ID:valkiria88,项目名称:Astoria,代码行数:19,代码来源:BlobLibrary.cs

示例2: Pygmentize

        Tuple<string, IHtmlString> Pygmentize(CloudBlob blob)
        {
            var filename = Uri.UnescapeDataString(blob.Uri.Segments.Last());

            var extension = Path.GetExtension(filename).ToLower();

            if (extension == ".mdown")
            {
                return new Tuple<string, IHtmlString>(null, new MvcHtmlString(new Markdown().Transform(blob.DownloadText())));
            }

            var formatters = new Dictionary<string, string>()
            {
                { ".cscfg", "xml" },
                { ".csdef", "xml" },
                { ".config", "xml" },
                { ".xml", "xml" },
                { ".cmd", "bat" },
                { ".rb", "ruby" },
                { ".cs", "csharp" },
                { ".html", "html" },
                { ".cshtml", "html" },
                { ".css", "css" },
                { ".erb", "erb" },
                { ".haml", "haml" },
                { ".js", "javascript" },
                { ".php", "php" },
                { ".py", "python" },
                { ".yaml", "yaml" },
                { ".yml", "yaml" },
                { ".txt", "text" }
            };

            var executable = "pygmentize";
            if (RoleEnvironment.IsAvailable)
            {
                executable = Path.Combine(RoleEnvironment.GetLocalResource("Python").RootPath, @"scripts\pygmentize.exe");
            }

            if (!formatters.ContainsKey(extension))
            {
                extension = ".txt";
            }

            var startInfo = new ProcessStartInfo(executable, string.Format("-f html -l {0}", formatters[extension]))
                {
                    UseShellExecute = false,
                    CreateNoWindow = true,
                    RedirectStandardInput = true,
                    RedirectStandardOutput = true,
                };
            var proc = Process.Start(startInfo);
            proc.StandardInput.Write(blob.DownloadText().Trim(new char[]{'\uFEFF'}));
            proc.StandardInput.Close();
            return new Tuple<string, IHtmlString>(filename, new MvcHtmlString(proc.StandardOutput.ReadToEnd()));
        }
开发者ID:smarx,项目名称:Things,代码行数:56,代码来源:HomeController.cs

示例3: RenderTemplateWithContentToBlob

 public static void RenderTemplateWithContentToBlob(CloudBlob template, CloudBlob renderTarget, InformationSource setAsDefaultSource = null)
 {
     InformationSourceCollection sources = renderTarget.GetBlobInformationSources();
     if(sources == null)
     {
         sources = CreateDefaultSources(template);
     }
     if (setAsDefaultSource != null)
     {
         sources.SetDefaultSource(setAsDefaultSource);
     }
     string templateContent = template.DownloadText();
     List<ContentItem> existingRoots = GetExistingRoots(sources);
     string renderResult = RenderTemplateWithContentRoots(templateContent, existingRoots);
     bool rerenderRequired = UpdateMismatchedRootsToSources(sources, existingRoots, renderTarget);
     renderTarget.SetBlobInformationSources(sources);
     renderTarget.UploadBlobText(renderResult, StorageSupport.InformationType_RenderedWebPage);
     if(rerenderRequired)
     {
         RenderTemplateWithContentToBlob(template, renderTarget);
     } else
     {
         sources.SubscribeTargetToSourceChanges(renderTarget);
     }
 }
开发者ID:rodmjay,项目名称:TheBallOnAzure,代码行数:25,代码来源:RenderWebSupport.cs

示例4: ReadBlobFile

        public static string ReadBlobFile(string fileName)
        {
            // byte[] fileBytes = null;
            string fileBytes = string.Empty;

            try
            {
                string storageAccountConnection = string.Empty;

                storageAccountConnection = ConfigurationManager.AppSettings["StorageAccount.ConnectionString"].ToString();

                // If you want to use Windows Azure cloud storage account, use the following
                // code (after uncommenting) instead of the code above.
                cloudStorageAccount = CloudStorageAccount.Parse(storageAccountConnection);

                // Create the blob client, which provides
                // authenticated access to the Blob service.
                blobClient = cloudStorageAccount.CreateCloudBlobClient();

                string deploymentPackageFolderString = string.Empty;

                deploymentPackageFolderString = ConfigurationManager.AppSettings["DeploymentPackageFolder"].ToString();

                // Get the container reference.
                blobContainer = blobClient.GetContainerReference(deploymentPackageFolderString);

                // Create the container if it does not exist.
                blobContainer.CreateIfNotExist();

                // Set permissions on the container.
                containerPermissions = new BlobContainerPermissions();

                // This sample sets the container to have public blobs. Your application
                // needs may be different. See the documentation for BlobContainerPermissions
                // for more information about blob container permissions.
                containerPermissions.PublicAccess = BlobContainerPublicAccessType.Blob;

                blobContainer.SetPermissions(containerPermissions);

                blob = blobContainer.GetBlobReference(fileName);

                BlobRequestOptions blobReqOptions = new BlobRequestOptions();

                blobReqOptions.Timeout = new TimeSpan(0, 5, 0);

                fileBytes = blob.DownloadText(blobReqOptions);
            }
            catch (System.Exception ex)
            {
                Logger.Write(string.Format("Error in ReadBlobFile()  Error: {0}", ex.Message));

                fileBytes = null;
            }

            return fileBytes;
        }
开发者ID:yonglehou,项目名称:Bermuda,代码行数:56,代码来源:AzureStorageUtility.cs

示例5: DownloadText

 private static string DownloadText(CloudBlob blob)
 {
     return blob.DownloadText();
 }
开发者ID:markrendle,项目名称:AzureDocumentStore,代码行数:4,代码来源:CloudBlobExtensions.cs


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