public async Task CanSetRepositoryProperties() { // Arrange ContainerRepositoryClient client = CreateClient(); RepositoryProperties repositoryProperties = await client.GetPropertiesAsync(); ContentProperties originalContentProperties = repositoryProperties.WriteableProperties; // Act await client.SetPropertiesAsync( new ContentProperties() { CanList = false, CanRead = false, CanWrite = false, CanDelete = false, }); // Assert RepositoryProperties properties = await client.GetPropertiesAsync(); Assert.IsFalse(properties.WriteableProperties.CanList); Assert.IsFalse(properties.WriteableProperties.CanRead); Assert.IsFalse(properties.WriteableProperties.CanWrite); Assert.IsFalse(properties.WriteableProperties.CanDelete); // Cleanup await client.SetPropertiesAsync(originalContentProperties); }
public async Task CanSetTagProperties() { // Arrange ContainerRepositoryClient client = CreateClient(); string tag = "latest"; TagProperties tagProperties = await client.GetTagPropertiesAsync(tag); ContentProperties originalContentProperties = tagProperties.WriteableProperties; // Act await client.SetTagPropertiesAsync( tag, new ContentProperties() { CanList = false, CanRead = false, CanWrite = false, CanDelete = false }); // Assert TagProperties properties = await client.GetTagPropertiesAsync(tag); Assert.IsFalse(properties.WriteableProperties.CanList); Assert.IsFalse(properties.WriteableProperties.CanRead); Assert.IsFalse(properties.WriteableProperties.CanWrite); Assert.IsFalse(properties.WriteableProperties.CanDelete); // Cleanup await client.SetTagPropertiesAsync(tag, originalContentProperties); }
/// <summary> /// /// </summary> /// <param name="resp"></param> private void ProcessHeaders(System.Net.HttpWebResponse resp) { if (resp.Headers.Count != 0) { m_headers = new ContentProperties(resp.Headers); } }
private static void CopyFileResource(IRecordCollectorFile file, ContentProperties contentProperties) { var fileInfo = new FileInfo(file.FullName); if (fileInfo.DirectoryName == null) { return; } var directoryFromRoot = fileInfo.DirectoryName .Replace( contentProperties.ContentRootPath, string.Empty, StringComparison.OrdinalIgnoreCase); var fileFromRoot = file.FullName .Replace( contentProperties.ContentRootPath, string.Empty, StringComparison.OrdinalIgnoreCase); var destinationDirectory = Path.Combine(contentProperties.StaticSiteRootPath, directoryFromRoot); var destinationFile = Path.Combine(contentProperties.StaticSiteRootPath, fileFromRoot); Directory.CreateDirectory(destinationDirectory); File.Copy(file.FullName, destinationFile, true); }
internal TagAttributesBase(string name, string digest, string createdTime, string lastUpdateTime, bool?signed, ContentProperties changeableAttributes) { Name = name; Digest = digest; CreatedTime = createdTime; LastUpdateTime = lastUpdateTime; Signed = signed; ChangeableAttributes = changeableAttributes; }
private ContentProperties GetContentProperties() { var model = new ContentProperties { ContentRootPath = this.contentRoot, StaticSiteRootPath = this.config.GetAppSettingsStaticSiteRootPath(), SectionsToExcludeFromLists = this.config.GetAppSettingsSectionsToExcludeFromLists(), EnvironmentProjectWebRootPath = this.env.WebRootPath, SiteUrl = this.config.GetAppSettingsSiteUrl(), }; return model; }
private static void ClearDirectory(ContentProperties contentProperties) { var staticSiteRootDirectoryInfo = new DirectoryInfo(contentProperties.StaticSiteRootPath); foreach (var file in staticSiteRootDirectoryInfo.EnumerateFiles()) { file.Delete(); } foreach (var dir in staticSiteRootDirectoryInfo.EnumerateDirectories()) { dir.Delete(true); } }
private void GetPageContent(HttpProtocol obProtocol, bool bIsRefresh) { if (m_bHasContent && !bIsRefresh) { return; } if (obProtocol == null) { throw new ArgumentNullException("obProtocol", "Null HttpProtocol object specified"); } lock (this) { ParserStream stream = null; System.String type = String.Empty; System.String charset = String.Empty; try { m_obProtocolOutput = obProtocol.GetProtocolOutput(); if (m_obProtocolOutput.Status.Code == HttpProtocolStatus.SUCCESS) { m_bHasContent = true; this.m_HttpContentProperties = m_obProtocolOutput.Content.ContentProperties; type = this.ContentType; charset = GetCharset(type); stream = new ParserStream(new System.IO.MemoryStream(m_obProtocolOutput.Content.ContentData)); } if (null != stream) { mSource = new InputStreamSource(stream, charset, m_obProtocolOutput.Content.ContentData.Length); } } catch (System.Exception e) { throw new ParserException("Failed to get page content", e); } mUrl = obProtocol.URL.ToString(); mIndex = new PageIndex(this); } }
public ContextObject(Thing thing, IContextListener owner, bool placement = true) : base(owner) { this._placement = placement; this._thing = thing; this._image = thing.GeneratePreview(); this.itemSize.y = 16f; this._text = thing.editorName; this.itemSize.x = (float)(this._text.Length * 8 + 26); this._thingBag = ContentProperties.GetBag(thing.GetType()); if (Main.isDemo && !this._thingBag.GetOrDefault <bool>("isInDemo", false)) { this.greyOut = true; } else { this.greyOut = false; } }
public async Task CanSetManifestProperties() { // Arrange ContainerRepositoryClient client = CreateClient(); string tag = "latest"; TagProperties tagProperties = await client.GetTagPropertiesAsync(tag); string digest = tagProperties.Digest; RegistryArtifactProperties artifactProperties = await client.GetRegistryArtifactPropertiesAsync(digest); ContentProperties originalContentProperties = artifactProperties.WriteableProperties; // Act RegistryArtifactProperties properties = await client.SetManifestPropertiesAsync( digest, new ContentProperties() { CanList = false, CanRead = false, CanWrite = false, CanDelete = false }); // Assert Assert.IsFalse(properties.WriteableProperties.CanList); Assert.IsFalse(properties.WriteableProperties.CanRead); Assert.IsFalse(properties.WriteableProperties.CanWrite); Assert.IsFalse(properties.WriteableProperties.CanDelete); RegistryArtifactProperties updatedProperties = await client.GetRegistryArtifactPropertiesAsync(digest); Assert.IsFalse(updatedProperties.WriteableProperties.CanList); Assert.IsFalse(updatedProperties.WriteableProperties.CanRead); Assert.IsFalse(updatedProperties.WriteableProperties.CanWrite); Assert.IsFalse(updatedProperties.WriteableProperties.CanDelete); // Cleanup await client.SetManifestPropertiesAsync(digest, originalContentProperties); }
public async Task CanSetTagProperties() { // Arrange var client = CreateClient(); string tag = "latest"; var artifact = client.GetArtifact(_repositoryName, tag); ArtifactTagProperties tagProperties = await artifact.GetTagPropertiesAsync(tag); ContentProperties originalContentProperties = tagProperties.WriteableProperties; // Act ArtifactTagProperties properties = await artifact.SetTagPropertiesAsync( tag, new ContentProperties() { CanList = false, CanRead = false, CanWrite = false, CanDelete = false }); // Assert Assert.IsFalse(properties.WriteableProperties.CanList); Assert.IsFalse(properties.WriteableProperties.CanRead); Assert.IsFalse(properties.WriteableProperties.CanWrite); Assert.IsFalse(properties.WriteableProperties.CanDelete); ArtifactTagProperties updatedProperties = await artifact.GetTagPropertiesAsync(tag); Assert.IsFalse(updatedProperties.WriteableProperties.CanList); Assert.IsFalse(updatedProperties.WriteableProperties.CanRead); Assert.IsFalse(updatedProperties.WriteableProperties.CanWrite); Assert.IsFalse(updatedProperties.WriteableProperties.CanDelete); // Cleanup await artifact.SetTagPropertiesAsync(tag, originalContentProperties); }
public async Task CanSetRepositoryProperties() { // Arrange var client = CreateClient(); var repository = client.GetRepository(_repositoryName); RepositoryProperties repositoryProperties = await repository.GetPropertiesAsync(); ContentProperties originalContentProperties = repositoryProperties.WriteableProperties; // Act RepositoryProperties properties = await repository.SetPropertiesAsync( new ContentProperties() { CanList = false, CanRead = false, CanWrite = false, CanDelete = false, }); // Assert Assert.IsFalse(properties.WriteableProperties.CanList); Assert.IsFalse(properties.WriteableProperties.CanRead); Assert.IsFalse(properties.WriteableProperties.CanWrite); Assert.IsFalse(properties.WriteableProperties.CanDelete); RepositoryProperties updatedProperties = await repository.GetPropertiesAsync(); Assert.IsFalse(updatedProperties.WriteableProperties.CanList); Assert.IsFalse(updatedProperties.WriteableProperties.CanRead); Assert.IsFalse(updatedProperties.WriteableProperties.CanWrite); Assert.IsFalse(updatedProperties.WriteableProperties.CanDelete); // Cleanup await repository.SetPropertiesAsync(originalContentProperties); }
public HttpProtocolContent(byte[] data, ContentProperties props) { m_Data = data; m_Properties = props; }
private static string CreateDirectoryAndGetFilePath(IRecordCollectorFile page, ContentProperties contentProperties) { var relativePath = page.RelativeUrl.ToString() .Replace( "/", Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal); if (relativePath.EndsWith(Path.DirectorySeparatorChar)) { relativePath += "index.html"; } relativePath = relativePath.TrimStart(Path.DirectorySeparatorChar); var destinationFile = Path.Combine(contentProperties.StaticSiteRootPath, relativePath); var destinationDirectory = Path.GetDirectoryName(destinationFile); Directory.CreateDirectory(destinationDirectory); return(destinationFile); }
public LayoutViewModelBuilder(TModel currentPage, CultureInfo currentCulture, List <CultureInfo> rootCultures, HttpRequest request, IStringLocalizer localizer, ContentProperties contentProperties) { this.currentPage = currentPage; this.vm = new TViewModel(); if (this.vm is IHasCurrentPage <TModel> vmWithCurrentPageProperty) { vmWithCurrentPageProperty.CurrentPage = currentPage; } this.vm.RootCultures = rootCultures ?? new List <CultureInfo>(); this.vm.CurrentCulture = currentCulture; this.vm.NavigationItems = new List <MenuItemViewModel>(); this.vm.CurrentPath = !string.IsNullOrEmpty(request?.Path.Value) ? request.Path.Value : "/"; this.vm.Localizer = localizer; this.vm.ContentProperties = contentProperties; if (!(this.vm is ListPageViewModel listPageViewModel)) { return; } listPageViewModel.Pagination = new PaginationViewModel { Layout = this.vm, Items = new List <PaginationItemViewModel>() }; listPageViewModel.PagedDescendantPages = new List <SinglePage>(); }