Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 public static void RefreshContent(CloudBlob webPageBlob, bool skipIfSourcesIntact = false)
 {
     InformationSourceCollection sources = webPageBlob.GetBlobInformationSources();
     if(sources == null)
         throw new InvalidDataException("Web page to refresh is missing information sources: " + webPageBlob.Name);
     if(skipIfSourcesIntact)
     {
         bool sourcesIntact = sources.HasAnySourceChanged() == false;
         if (sourcesIntact)
             return;
     }
     InformationSource templateSource = sources.CollectionContent.First(src => src.IsWebTemplateSource);
     if(templateSource == null)
         throw new InvalidDataException("Web page to refresh is missing template source: " + webPageBlob.Name);
     CloudBlob templateBlob =
         StorageSupport.CurrActiveContainer.GetBlockBlobReference(templateSource.SourceLocation);
     RenderTemplateWithContentToBlob(templateBlob, webPageBlob);
 }