public void AddWatermarkWithAuthentication( [Values( FileAuthentication.None, FileAuthentication.Password, FileAuthentication.CertificateFile, FileAuthentication.CertificateStore)] FileAuthentication watermarkAuth) { string inputFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.AddWatermark.Resources.Watermark.pdf", this.inputDirectory); string watermarkFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.AddWatermark.Resources.Overlay.pdf", this.inputDirectory); string outputFilePath = Path.Combine(this.outputDirectory, "Watermark.pdf"); FunctionDesigner designer = ProviderHelpers.CreateDesigner <AddWatermarkProvider>(); ConfigureInputFileFunctionValues(designer, FileAuthentication.None, inputFilePath); var watermarkPages = string.Empty; ConfigureWatermarkFunctionValues(designer, watermarkAuth, watermarkFilePath, WatermarkPosition.Below, watermarkPages); designer.Properties[Pdf.Common.PropertyNames.OutputFilePath].Value = outputFilePath; var tester = new FunctionTester <AddWatermarkProvider>(); tester.Execute(designer.GetProperties(), designer.GetParameters()); PdfComparer.AssertText(outputFilePath, FileAuthentication.None, this.authenticationManager, "1\nWatermark\r\n2\nWatermark\r\n3\nWatermark\r\n4\nWatermark", null); }
public void Concatenate() { string inputFilePath1 = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.PdfOperations.Resources.Concatenate1.pdf", this.inputDirectory); PdfComparer.AssertPageCount(inputFilePath1, FileAuthentication.None, this.authenticationManager, 1); PdfComparer.AssertText(inputFilePath1, FileAuthentication.None, this.authenticationManager, "1", "function Script1()\r\n{}\n"); string inputFilePath2 = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.PdfOperations.Resources.Concatenate2.pdf", this.inputDirectory); PdfComparer.AssertPageCount(inputFilePath2, FileAuthentication.None, this.authenticationManager, 1); PdfComparer.AssertText(inputFilePath2, FileAuthentication.None, this.authenticationManager, "2", "function Script2()\r\n{}\n"); string outputFilePath = Path.Combine(this.outputDirectory, "Concat.pdf"); FunctionDesigner designer = ProviderHelpers.CreateDesigner <PdfOperationsProvider>(); designer.Properties[PropertyNames.Operation].Value = Operation.Concatenate; designer.Properties[PropertyNames.InputFiles].Value = new List <string> { inputFilePath1, inputFilePath2 }; designer.Properties[PropertyNames.InputAuthenticationType].Value = AuthenticationType.None; designer.Properties[PropertyNames.OutputFilePath].Value = outputFilePath; var tester = new FunctionTester <PdfOperationsProvider>(); tester.Execute(designer.GetProperties(), designer.GetParameters()); Assert.IsTrue(File.Exists(outputFilePath)); PdfComparer.AssertPageCount(outputFilePath, FileAuthentication.None, this.authenticationManager, 2); PdfComparer.AssertText(outputFilePath, FileAuthentication.None, this.authenticationManager, $"1{Environment.NewLine}2", "function Script1()\r\n{}\n\nfunction Script2()\r\n{}\n\n"); }
public void SetUp() { _filesCreated = new HashSet <string>(); _component = new ZipFileAugmentor(new TraceLogger()); _zipFileName = GetTempFileName(); ResourceHelpers.SaveResourceToDiskAsFilename(_zipFileName, "Tests.Resources.Archive.zip"); }
public async Task Should_list_all_nodes_at_root_2() { await ResourceHelpers.CreateFileWithContentAsync(ResourceHelpers.GetLocalDevelopmentContainer(), $"{Guid.NewGuid()}.txt", "stuff"); var sut = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = new List <IEnchiladaAdapterConfiguration> { new BlobStorageAdapterConfiguration { AdapterName = "blob_filesystem", CreateContainer = true, ConnectionString = "UseDevelopmentStorage=true;", ContainerReference = "test", IsPublicAccess = true } } }); var directory = sut.OpenDirectoryReference("enchilada://blob_filesystem"); var nodes = await directory.GetFilesAsync(); nodes.Count().Should().Be(1); await directory.DeleteAsync(); }
public async Task Should_not_hang(FtpEncryption encryption) { string randomFileName = $"{Guid.NewGuid()}.jpg"; var tempFile = ResourceHelpers.GetTempFileInfo(); tempFile.Length.Should().Be(0); using (var sut = new FtpClient(new FtpClientConfiguration { Host = Program.FtpConfiguration.Host, Username = Program.FtpConfiguration.Username, Password = Program.FtpConfiguration.Password, Port = encryption == FtpEncryption.Implicit ? 990 : Program.FtpConfiguration.Port, EncryptionType = encryption, IgnoreCertificateErrors = true })) { await sut.LoginAsync(); var stream = await OpenWriteAsync(sut, "/", randomFileName); stream.Dispose(); } }
public void ReadAcroFormDataWithListOutput() { string inputFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Read.Resources.FormData.pdf", this.inputDirectory); FunctionDesigner designer = ProviderHelpers.CreateDesigner<ReadProvider>(); ConfigureInputFileFunctionValues(designer, FileAuthentication.None, inputFilePath); designer.Properties[PropertyNames.ReadFormData].Value = true; designer.Properties[PropertyNames.ReturnFormDataAs].Value = FormExtraction.List; var tester = new FunctionTester<ReadProvider>(); FunctionResult result = tester.Execute(designer.GetProperties(), designer.GetParameters()); List<KeyValuePair<string, string>> dataList = result.Value.FormDataList; Assert.AreEqual(4, dataList.Count); KeyValuePair<string, string> item = dataList[0]; Assert.AreEqual("First Name", item.Key); Assert.AreEqual("Jeremy", item.Value); item = dataList[1]; Assert.AreEqual("Surname", item.Key); Assert.AreEqual("Woods", item.Value); item = dataList[2]; Assert.AreEqual("Gender", item.Key); Assert.AreEqual("Male", item.Value); item = dataList[3]; Assert.AreEqual("AcceptTCs", item.Key); Assert.AreEqual("Yes", item.Value); }
public void ReadXfaFormDataWithListOutput() { string inputFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Read.Resources.FormDataXFA.pdf", this.inputDirectory); FunctionDesigner designer = ProviderHelpers.CreateDesigner<ReadProvider>(); ConfigureInputFileFunctionValues(designer, FileAuthentication.None, inputFilePath); designer.Properties[PropertyNames.ReadFormData].Value = true; designer.Properties[PropertyNames.ReturnFormDataAs].Value = FormExtraction.List; var tester = new FunctionTester<ReadProvider>(); FunctionResult result = tester.Execute(designer.GetProperties(), designer.GetParameters()); List<KeyValuePair<string, string>> dataList = result.Value.FormDataList; Assert.AreEqual(5, dataList.Count); KeyValuePair<string, string> item = dataList[0]; Assert.AreEqual("form1[0].FullName[0]", item.Key); Assert.AreEqual("John", item.Value); item = dataList[1]; Assert.AreEqual("form1[0].Surname[0]", item.Key); Assert.AreEqual("Doe", item.Value); item = dataList[2]; Assert.AreEqual("form1[0].EmailMe[0]", item.Key); Assert.AreEqual("1", item.Value); item = dataList[3]; Assert.AreEqual("form1[0].Email[0]", item.Key); Assert.AreEqual("*****@*****.**", item.Value); item = dataList[4]; Assert.AreEqual("form1[0]", item.Key); Assert.AreEqual("*****@*****.**", item.Value); }
public bool InjectJs(string path) { var script = string.Empty; if (File.Exists(path)) { script = File.ReadAllText(path); } else if (File.Exists(Path.Combine(LibraryPath, path))) { path = Path.Combine(LibraryPath, path); script = File.ReadAllText(path); } else { script = ResourceHelpers.ReadResource(path); } if (string.IsNullOrEmpty(script)) { return(false); } var oldPath = LibraryPath; LibraryPath = Path.GetDirectoryName(path); engine.Evaluate(path, script); LibraryPath = oldPath; return(true); }
public void SignAcroWithPageSignature() { string inputFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Sign.Resources.Sign.pdf", this.inputDirectory); string outputFilePath = Path.Combine(this.outputDirectory, "Sign.pdf"); int left = 45; int top = 223; int width = 109; int height = 79; int page = 2; this.lockDocument = !this.lockDocument; FunctionDesigner designer = ProviderHelpers.CreateDesigner <SignProvider>(); ConfigureInputFileFunctionValues(designer, FileAuthentication.None, inputFilePath); ConfigureSignCertificateProperties(designer, FileAuthentication.CertificateFile, this.lockDocument); designer.Properties[PropertyNames.Placement].Value = SignaturePosition.OnPage; designer.Properties[PropertyNames.PositionX].Value = left; designer.Properties[PropertyNames.PositionY].Value = top; designer.Properties[PropertyNames.Width].Value = width; designer.Properties[PropertyNames.Height].Value = height; designer.Properties[PropertyNames.Page].Value = page; designer.Properties[PropertyNames.BackgroundImage].Value = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Sign.Resources.Sign_Image.png", this.inputDirectory); designer.Properties[Pdf.Common.PropertyNames.OutputFilePath].Value = outputFilePath; var tester = new FunctionTester <SignProvider>(); tester.Execute(designer.GetProperties(), designer.GetParameters()); PdfComparer.AssertPageSignature(outputFilePath, FileAuthentication.None, this.authenticationManager, signName, signLocation, signReason, this.lockDocument, page, Utilities.MillimetersToPoints(left), Utilities.MillimetersToPoints(top), Utilities.MillimetersToPoints(width), Utilities.MillimetersToPoints(height)); }
public void Should_give_correct_filesystem_provider() { string firstProviderPath = ResourceHelpers.GetResourceDirectoryInfo("test_filesystem").FullName; string secondProviderPath = ResourceHelpers.GetResourceDirectoryInfo("another_filesystem").FullName; var sut = new EnchiladaFileProviderResolver(new EnchiladaConfiguration { Adapters = new List <IEnchiladaAdapterConfiguration> { new FilesystemAdapterConfiguration { AdapterName = "test_filesystem", Directory = firstProviderPath }, new FilesystemAdapterConfiguration { AdapterName = "another_filesystem", Directory = secondProviderPath } } }); var firstProvider = sut.OpenDirectoryReference("enchilada://test_filesystem/"); firstProvider.Should().BeOfType <FilesystemDirectory>(); firstProvider.RealPath.Should().Be(firstProviderPath); var secondProvider = sut.OpenDirectoryReference("enchilada://another_filesystem/"); secondProvider.Should().BeOfType <FilesystemDirectory>(); secondProvider.RealPath.Should().Be(secondProviderPath); }
public void ReadSignature() { var store = new X509Store(StoreName.TrustedPeople, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadWrite); store.Add(this.authenticationManager.Certificate); store.Close(); string inputFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Read.Resources.Signature.pdf", this.inputDirectory); FunctionDesigner designer = ProviderHelpers.CreateDesigner<ReadProvider>(); ConfigureInputFileFunctionValues(designer, FileAuthentication.None, inputFilePath); designer.Properties[PropertyNames.ReadSignature].Value = true; var tester = new FunctionTester<ReadProvider>(); FunctionResult result = tester.Execute(designer.GetProperties(), designer.GetParameters()); Assert.IsTrue(result.Value.Signatures.IsSigned); AssertSignature(result.Value.Signatures.LatestSignature, false, "I moderated the doc", "Office location 2", "Jane Doe", new DateTime(2016, 8, 8, 15, 12, 57, DateTimeKind.Utc), true, 1, "A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.\r\n", false); dynamic allSignatures = result.Value.Signatures.AllSignatures; Assert.AreEqual(2, allSignatures.Count); AssertSignature(allSignatures[0], false, "I created the doc", "Office location 1", "John Smith", new DateTime(2016, 8, 8, 15, 12, 14, DateTimeKind.Utc), true, 1, string.Empty, true); AssertSignature(allSignatures[1], false, "I moderated the doc", "Office location 2", "Jane Doe", new DateTime(2016, 8, 8, 15, 12, 57, DateTimeKind.Utc), true, 1, "A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.\r\n", false); store.Open(OpenFlags.ReadWrite); store.Remove(this.authenticationManager.Certificate); store.Close(); }
public void SignWithInvisibleSignature( [Values( FileAuthentication.None, FileAuthentication.Password /*, * Ignore: http://stackoverflow.com/questions/40045745/itextsharp-object-reference-error-on-pdfstamper-for-certificate-protected-file * FileAuthentication.CertificateFile, * FileAuthentication.CertificateStore*/)] FileAuthentication inputAuth, [Values( FileAuthentication.CertificateFile, FileAuthentication.CertificateStore)] FileAuthentication signAuth, [Values( "Sign.pdf", "SignXFA.pdf")] string fileName) { string inputFilePath = ResourceHelpers.WriteResourceToFile($"Twenty57.Linx.Components.Pdf.Tests.Sign.Resources.{fileName}", this.inputDirectory); string outputFilePath = Path.Combine(this.outputDirectory, fileName); this.lockDocument = !this.lockDocument; FunctionDesigner designer = ProviderHelpers.CreateDesigner <SignProvider>(); ConfigureInputFileFunctionValues(designer, inputAuth, inputFilePath); ConfigureSignCertificateProperties(designer, signAuth, this.lockDocument); designer.Properties[PropertyNames.Placement].Value = SignaturePosition.Hidden; designer.Properties[Pdf.Common.PropertyNames.OutputFilePath].Value = outputFilePath; var tester = new FunctionTester <SignProvider>(); tester.Execute(designer.GetProperties(), designer.GetParameters()); PdfComparer.AssertPageSignature(outputFilePath, inputAuth, this.authenticationManager, signName, signLocation, signReason, this.lockDocument, 1, 0, 0, 0, 0); }
public void ProtectWithScreenReaderRestrictions( [Values( FileAuthentication.Password /*, * Ignore: http://stackoverflow.com/questions/40045745/itextsharp-object-reference-error-on-pdfstamper-for-certificate-protected-file * FileAuthentication.CertificateFile, * FileAuthentication.CertificateStore*/)] FileAuthentication protectAuth, [Values( true, false)] bool allowScreenReaders) { string inputFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.ChangeProtection.Resources.Protect.pdf", this.inputDirectory); string outputFilePath = Path.Combine(this.outputDirectory, "Protect.pdf"); FunctionDesigner designer = ProviderHelpers.CreateDesigner <ChangeProtectionProvider>(); ConfigureInputFileFunctionValues(designer, FileAuthentication.None, inputFilePath); ConfigureProtectFunctionValues(designer, protectAuth, Encryption.AES256, true, true, allowScreenReaders: allowScreenReaders); designer.Properties[Pdf.Common.PropertyNames.OutputFilePath].Value = outputFilePath; var tester = new FunctionTester <ChangeProtectionProvider>(); tester.Execute(designer.GetProperties(), designer.GetParameters()); PdfComparer.AssertProtection(outputFilePath, protectAuth, this.authenticationManager, true, true, expectedAllowScreenReaders: allowScreenReaders); if (protectAuth == FileAuthentication.Password) { using (var permissionsAuthHelper = new AuthenticationManager(permissionsPassword)) { PdfComparer.AssertProtectionAllRights(outputFilePath, FileAuthentication.Password, permissionsAuthHelper, true, true); } } }
public void Should_represent_directory() { var sut = new FilesystemDirectory(ResourceHelpers.GetResourceDirectoryInfo()); sut.IsDirectory.Should().BeTrue(); sut.Name.Should().Be("Resources"); }
public async Task Should_present_file() { Program.Initialise(); await ResourceHelpers.CreateFileWithContentAsync("level1/level2/level2content.txt", "Lorem ipsum dolor sit amet", Logger); var filesystemProvider = new FtpFileProvider(new FtpAdapterConfiguration { AdapterName = "ftp_filesystem", Host = Program.FtpConfiguration.Host, Username = Program.FtpConfiguration.Username, Password = Program.FtpConfiguration.Password, Port = Program.FtpConfiguration.Port, Directory = "/" }, "level1/level2/level2content.txt"); filesystemProvider.IsFile.Should().BeTrue(); filesystemProvider.File.Should().NotBeNull(); var bytes = await filesystemProvider.File.ReadToEndAsync(); string contents = Encoding.UTF8.GetString(bytes); contents.Should().StartWith("Lorem ipsum"); }
public async Task Should_not_throw_exception_when_directory_not_present() { var resourceDirectory = new FilesystemDirectory(ResourceHelpers.GetResourceDirectoryInfo()); var sut = resourceDirectory.GetDirectory($"does_not_exist_{Guid.NewGuid()}"); await sut.DeleteAsync(); }
public void AddWatermark( [Values( FileAuthentication.None, FileAuthentication.Password /*, * Ignore: http://stackoverflow.com/questions/40045745/itextsharp-object-reference-error-on-pdfstamper-for-certificate-protected-file * FileAuthentication.CertificateFile, * FileAuthentication.CertificateStore*/)] FileAuthentication inputAuth, [Values( WatermarkPosition.Above, WatermarkPosition.Below)] WatermarkPosition position) { string inputFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.AddWatermark.Resources.Watermark.pdf", this.inputDirectory); string watermarkFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.AddWatermark.Resources.Overlay.pdf", this.inputDirectory); string outputFilePath = Path.Combine(this.outputDirectory, "Watermark.pdf"); FunctionDesigner designer = ProviderHelpers.CreateDesigner <AddWatermarkProvider>(); ConfigureInputFileFunctionValues(designer, inputAuth, inputFilePath); var watermarkPages = "4;1-2,2,2"; ConfigureWatermarkFunctionValues(designer, FileAuthentication.None, watermarkFilePath, position, watermarkPages); designer.Properties[Pdf.Common.PropertyNames.OutputFilePath].Value = outputFilePath; var tester = new FunctionTester <AddWatermarkProvider>(); tester.Execute(designer.GetProperties(), designer.GetParameters()); PdfComparer.AssertText(outputFilePath, inputAuth, this.authenticationManager, "1\nWatermark\r\n2\nWatermark\r\n3\r\n4\nWatermark", null); }
public void ReadXfaFormDataWithCustomTypeOutput() { string inputFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Read.Resources.FormDataXFA.pdf", this.inputDirectory); FunctionDesigner designer = ProviderHelpers.CreateDesigner<ReadProvider>(); ConfigureInputFileFunctionValues(designer, FileAuthentication.None, inputFilePath); designer.Properties[PropertyNames.ReadFormData].Value = true; ITypeReference dataType = TypeReference.CreateGeneratedType( new TypeProperty("form1_910_93_46FullName_910_93", typeof(string)), new TypeProperty("form1_910_93_46Surname_910_93", typeof(string)), new TypeProperty("form1_910_93_46Email_910_93", typeof(string)), new TypeProperty("form1_910_93_46EmailMe_910_93", typeof(string))); designer.Properties[PropertyNames.ReturnFormDataAs].Value = FormExtraction.CustomType; designer.Properties[PropertyNames.FormDataType].Value = dataType; var tester = new FunctionTester<ReadProvider>(); tester.CustomTypes.Add(dataType); FunctionResult result = tester.Execute(designer.GetProperties(), designer.GetParameters()); Assert.AreEqual("John", result.Value.FormData.form1_910_93_46FullName_910_93); Assert.AreEqual("Doe", result.Value.FormData.form1_910_93_46Surname_910_93); Assert.AreEqual("*****@*****.**", result.Value.FormData.form1_910_93_46Email_910_93); Assert.AreEqual("1", result.Value.FormData.form1_910_93_46EmailMe_910_93); }
public void ReadText( [Values( TextSplit.Never, TextSplit.Page)] TextSplit splitText) { string inputFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.ReadPdf.Resources.Text.pdf", this.inputDirectory); FunctionDesigner designer = ProviderHelpers.CreateDesigner <ReadPdfProvider>(); ConfigureInputFileFunctionValues(designer, FileAuthentication.None, inputFilePath); designer.Properties[PropertyNames.ReadText].Value = true; designer.Properties[PropertyNames.SplitText].Value = splitText; var tester = new FunctionTester <ReadPdfProvider>(); FunctionResult result = tester.Execute(designer.GetProperties(), designer.GetParameters()); switch (splitText) { case TextSplit.Never: Assert.AreEqual("Text on page 1\nFooter text on page 1\r\nText on page 2\r\nText on page 3", result.Value.Text); break; case TextSplit.Page: Assert.AreEqual(new List <string> { "Text on page 1\nFooter text on page 1", "Text on page 2", "Text on page 3" }, result.Value.Text); break; } }
public async Task Should_upload_file() { using (var sut = new FtpClient(new FtpClientConfiguration { Host = Program.FtpConfiguration.Host, Username = Program.FtpConfiguration.Username, Password = Program.FtpConfiguration.Password, Port = Program.FtpConfiguration.Port })) { sut.Logger = Logger; string randomDirectoryName = $"{Guid.NewGuid()}"; string randomFileName = $"{Guid.NewGuid()}.jpg"; await sut.LoginAsync(); var fileinfo = ResourceHelpers.GetResourceFileInfo("penguin.jpg"); using (var writeStream = await sut.OpenFileWriteStreamAsync(randomFileName)) { var fileReadStream = fileinfo.OpenRead(); await fileReadStream.CopyToAsync(writeStream); } var files = await sut.ListFilesAsync(); files.Any(x => x.Name == randomFileName).Should().BeTrue(); await sut.DeleteFileAsync(randomFileName); } }
public void ReadAcroFormDataWithCustomTypeOutput() { string inputFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Read.Resources.FormData.pdf", this.inputDirectory); FunctionDesigner designer = ProviderHelpers.CreateDesigner<ReadProvider>(); ConfigureInputFileFunctionValues(designer, FileAuthentication.None, inputFilePath); designer.Properties[PropertyNames.ReadFormData].Value = true; ITypeReference dataType = TypeReference.CreateGeneratedType( new TypeProperty("First_32Name", typeof(string)), new TypeProperty("Surname", typeof(string)), new TypeProperty("Gender", typeof(string)), new TypeProperty("AcceptTCs", typeof(string))); designer.Properties[PropertyNames.ReturnFormDataAs].Value = FormExtraction.CustomType; designer.Properties[PropertyNames.FormDataType].Value = dataType; var tester = new FunctionTester<ReadProvider>(); tester.CustomTypes.Add(dataType); FunctionResult result = tester.Execute(designer.GetProperties(), designer.GetParameters()); Assert.AreEqual("Jeremy", result.Value.FormData.First_32Name); Assert.AreEqual("Woods", result.Value.FormData.Surname); Assert.AreEqual("Male", result.Value.FormData.Gender); Assert.AreEqual("Yes", result.Value.FormData.AcceptTCs); }
private static void RegisterDiagramUiComponents(ContainerBuilder builder) { builder.RegisterType <DiagramWindowService>().As <IDiagramUiService>().SingleInstance(); builder.RegisterType <RoslynDiagramViewModel>().As <IDiagramUi>().SingleInstance(); builder.RegisterType <RoslynDiagramViewportViewModel>().As <IDiagramViewportUi>() .WithParameter("minZoom", AppDefaults.MinZoom) .WithParameter("maxZoom", AppDefaults.MaxZoom) .WithParameter("initialZoom", AppDefaults.InitialZoom) .SingleInstance(); builder.RegisterType <RoslynDiagramShapeViewModelFactory>().As <IDiagramShapeUiFactory>() .WithParameter("isDescriptionVisible", true) .SingleInstance(); builder.RegisterType <MiniButtonPanelViewModel>().As <IDecorationManager <IMiniButton, IDiagramShapeUi> >().SingleInstance(); var resourceDictionary = ResourceHelpers.GetResourceDictionary(DiagramStylesXaml, Assembly.GetExecutingAssembly()); builder.RegisterType <DiagramControl>() .WithParameter("additionalResourceDictionary", resourceDictionary) .SingleInstance(); builder.RegisterType <DataCloningDiagramImageCreator>().As <IDiagramImageCreator>().SingleInstance(); }
/// <summary> /// Gets a statistics for country /// </summary> /// <param name="countryCode">Country code</param> /// <returns>Statistics for country</returns> public string GetStatisticsForCountry(string countryCode) { string resourceName = ResourceHelpers.GetResourceName( AUTOPREFIXER_COUNTRY_STATISTICS_DIRECTORY_NAME + "." + countryCode + ".js"); Assembly assembly = GetType() #if !NET40 .GetTypeInfo() #endif .Assembly ; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) { if (stream == null) { throw new AutoprefixerProcessingException( string.Format(Strings.Processor_CountryStatisticsNotFound, countryCode)); } using (var reader = new StreamReader(stream)) { return(reader.ReadToEnd()); } } }
private async T.Task ExecutePackageAsync(string packageName, Action <Package> packageInit = null) { Requires.SingleCall(ref ExecutePackageAsyncCalled); var dtsxPath = Path.Combine(TempFolderPath, packageName); try { using (var rst = ResourceHelpers.GetEmbeddedResourceAsStream(EtlPackageAssembly, packageName)) { using (var tst = File.Create(dtsxPath)) { await rst.CopyToAsync(tst); } } var app = new Application(); var package = app.LoadPackage(dtsxPath, this); packageInit?.Invoke(package); var res = package.Execute(null, null, this, this, null); } finally { Stuff.FileTryDelete(dtsxPath); } }
public AuthenticationManager(string password = "******") { Password = password; CertificateFilePath = ResourceHelpers.WriteResourceToFile("Twenty57.Linx.Components.Pdf.Tests.Common.Resources.John Smith.pfx", Path.GetTempPath()); CertificateFilePassword = "******"; Certificate = new X509Certificate2(CertificateFilePath, CertificateFilePassword, X509KeyStorageFlags.Exportable); }
public void OnUiInitialized(Window mainWindow, IDiagramStyleProvider diagramStyleProvider) { _window = mainWindow; var resourceDictionary = ResourceHelpers.GetResourceDictionary(DiagramStylesXaml, Assembly.GetExecutingAssembly()); _uiService.Initialize(resourceDictionary, diagramStyleProvider); }
public async Task Should_give_md5_hash_of_file() { var sut = new FilesystemFile(ResourceHelpers.GetResourceFileInfo("SampleContent.txt")); var hash = await sut.GetHashAsync(); hash.Should().NotBeEmpty(); hash.Should().Be("0edb2a42eee7dc39e8a9d15ecd827000"); }
public async Task Should_not_blow_up_if_file_does_not_exist() { string fileName = $"{Guid.NewGuid()}.txt"; var sut = new BlobStorageFile(ResourceHelpers.GetLocalDevelopmentContainer(), fileName); sut.Exists.Should().BeFalse(); await sut.DeleteAsync(); }
public bool IsFile(string path) { if (path.StartsWith(":")) { return(ResourceHelpers.ResourceExists(path.Substring(1))); } return(File.Exists(path)); }
public void TestFixtureSetUp() { _templatesFolder = GetTempFolderName(); Directory.CreateDirectory(_templatesFolder); ResourceHelpers.SaveResourceToDisk(_templatesFolder, "Tests.ExampleTemplates.TemplateWithSubfile.txt"); ResourceHelpers.SaveResourceToDisk(_templatesFolder, "Tests.ExampleTemplates.Subfile1.txt"); ResourceHelpers.SaveResourceToDisk(_templatesFolder, "Tests.ExampleTemplates.Subfile2.txt"); }