public void Test_SaveTextAppService_OverHttp_Save_WithValidationMessages() { try { string url = "http://localhost:6371/savetextappservice.svc"; string soapAction = "http://tempuri.org/ISaveTextAppService/Save"; byte[] dataToSend = EmbeddedResourceHelper.GetEmbeddedResourceBytes( Assembly.GetExecutingAssembly(), "TestResources", "Save_WithValidationMessages.xml"); HttpWebRequest request = CreateSoapRequest(url, soapAction, dataToSend); using (var response = (HttpWebResponse)request.GetResponse()) { using (Stream responseStream = response.GetResponseStream()) { if (responseStream == null) { throw new NullException(nameof(responseStream)); } using (var reader = new StreamReader(responseStream, Encoding.UTF8)) { string dataReceived = reader.ReadToEnd(); SaveTextViewModel viewModel = ParseReceivedData(dataReceived); } } } } catch (WebException ex) { Assert.Inconclusive(ex.Message); } }
public void testCorrect() { string asmName = "CustomerScreen.xml"; Stream str = EmbeddedResourceHelper.GetEmbeddedResource(Assembly.GetExecutingAssembly().FullName, asmName); Assert.IsNotNull(str); }
public void Setup() { var solrExpressOptions = new SolrExpressOptions(); var solrConnection = new FakeSolrConnection <TestDocument>(); var expressionBuilder = new ExpressionBuilder <TestDocument>(solrExpressOptions, solrConnection); expressionBuilder.LoadDocument(); var facetRange1 = (IFacetRangeParameter <TestDocument>) new FacetRangeParameter <TestDocument>(expressionBuilder, null); facetRange1.FieldExpression = field => field.Age; facetRange1.AliasName = "facetRange"; this._searchParameters = new List <ISearchParameter> { facetRange1 }; this._result = new FacetsResult <TestDocument>(); // Data using http://www.json-generator.com/ var assembly = typeof(FacetsResultBenchmarks).GetTypeInfo().Assembly; var jsonPlainText = EmbeddedResourceHelper.GetByName(assembly, $"SolrExpress.Benchmarks.Solr4.Search.Result.FacetsResultBenchmarks_{this.FacetTypes}{this.ElementsCount}.json"); this._jsonStream = new MemoryStream(Encoding.GetEncoding(0).GetBytes(jsonPlainText)); }
/// <summary> /// Landing point, execution starts here /// </summary> protected override void ExecuteTask() { EmbeddedResourceHelper.Bind(this); if (LoadDefaultVendor() && LoadDefaultLanguage() && LoadDefaultConnector() && LoadProductExporterSettings()) { if (LoadDatabaseCache()) { IFtpClient ftpClient; try { ftpClient = FtpClientFactory.Create(new Uri(ExportSettings.Server), ExportSettings.UserName, ExportSettings.Password); ftpClient.Update(); } catch (Exception ex) { TraceError("Unable to establish FTP connection to remote server \"{0}\" for exporting BizTalk files.", ExportSettings.Server); return; } ExportProducts(ftpClient); } else { TraceError("Could not cache Concentrator database data, further processing not possible now."); } } else { TraceError("Could not load context data, further processing not possible now."); } }
public JsValue ExportDefault(BaristaContext context, BaristaModuleRecord referencingModule) { var tsBuffer = TypeScriptTranspiler.GetSerializedTypeScriptCompiler(context); var fnTypeScript = context.ParseSerializedScript(tsBuffer, () => EmbeddedResourceHelper.LoadResource(TypeScriptTranspiler.ResourceName), "[typescript]"); return(fnTypeScript.Call <JsObject>()); }
private void CheckForLatestVersion() { UpdaterPath = EmbeddedResourceHelper.GetEmbeddedResourcePath( "YTMusicUploader.Updater.exe", "Embedded", EmbeddedResourceHelper.TargetAssemblyType.Executing, false); if (VersionHelper.LatestVersionGreaterThanCurrentVersion(out string htmlUrl, out string latestVersion)) { Logger.DontLogToSourdceCauseEarlierVersion = true; LatestVersionUrl = htmlUrl; LatestVersionTag = latestVersion; SetVersionWarningVisible(true); NewVersionTooltip.SetToolTip(pbUpdate, "\nVersion " + LatestVersionTag + " available.\nClick for details."); Logger.LogInfo("CheckForLatestVersion", "Newer software version detected"); } else { Logger.DontLogToSourdceCauseEarlierVersion = false; LatestVersionUrl = null; LatestVersionTag = null; SetVersionWarningVisible(false); } }
private static Guid ExtractResourceInfo(string assemblyName, string resourcePath, out string assembly, out string resource, out string encoding) { Contract.Requires <ArgumentException>(!StringExtensions.IsNullOrWhiteSpace(assemblyName)); Contract.Requires <ArgumentException>(!StringExtensions.IsNullOrWhiteSpace(resourcePath)); assembly = TrimPath(assemblyName); resource = TrimPath(resourcePath); encoding = UrlCrypto.ToUrlEncodedString(resource); try { //--------------------------------------------------------------------------------- // The guid's are used to ensure that the client's browser does not use stale // files from their cache. This is because whenever a new module's assembly is // generated, the compiler assigns a new guid for it and new links are created //--------------------------------------------------------------------------------- Assembly module = EmbeddedResourceHelper.GetResourceModule(assembly); Guid guid = module.ManifestModule.ModuleVersionId; return(guid); } catch (Exception) { return(Guid.Empty); // couldn't retrieve the file info, probably a wrong file name } }
/// <summary> /// Get widget template content /// </summary> /// <param name="widgetSetup"></param> /// <returns></returns> public static string GetTemplateStyle(WidgetSetupModel widgetSetup) { return (EmbeddedResourceHelper.GetNullableString( string.Format("{0}.{1}.{2}.Style.cshtml", DataSetupResourceType.WidgetTemplate.GetEnumName(), widgetSetup.Widget, widgetSetup.DefaultTemplate), ResourceNamespace)); }
public async Task <string> UsingTemplateFromEmbedded <T>(string path, T model) { var template = EmbeddedResourceHelper.GetResourceAsString(_assembly, GenerateFileAssemblyPath(path, _assembly)); var result = await Parse(template, model); return(result); }
public JsValue ExportDefault(BaristaContext context, BaristaModuleRecord referencingModule) { var buffer = SerializedScriptService.GetSerializedScript(ResourceName, context, mapWindowToGlobal: true); var fnScript = context.ParseSerializedScript(buffer, () => EmbeddedResourceHelper.LoadResource(ResourceName), "[uuid]"); return(fnScript.Call <JsObject>()); }
/// <summary> /// Initialise the shader /// </summary> public void Initialise() { try { string fs; EmbeddedResourceHelper.GetEmbeddedFileAsString(Assembly.GetExecutingAssembly(), "textureshader.frag", out fs); string vs; EmbeddedResourceHelper.GetEmbeddedFileAsString(Assembly.GetExecutingAssembly(), "textureshader.vert", out vs); base.Initialise(fs, vs); // get attribute locations VertexAttribLocation = GL.GetAttribLocation(m_Program, "aVert"); TextureCoordAttribLocation = GL.GetAttribLocation(m_Program, "aTexCoord"); // get uniform locations ProjectionMatrixLocation = GL.GetUniformLocation(m_Program, "uProjection_matrix"); ModelViewMatrixLocation = GL.GetUniformLocation(m_Program, "uModelview_matrix"); // get the texture sampler location TextureSlotLocation = GL.GetUniformLocation(m_Program, "uTexSlot0"); } catch (ShaderException se) { System.Diagnostics.Debug.WriteLine(se.Message); } }
/// <summary> /// Get plugin widget template content /// </summary> /// <param name="widgetSetup"></param> /// <param name="pluginResourceNameSpace"></param> /// <returns></returns> public static string GetPluginTemplateScript(WidgetSetupModel widgetSetup, string pluginResourceNameSpace) { return (EmbeddedResourceHelper.GetNullableString( string.Format("{0}.{1}.{2}.Script.cshtml", DataSetupResourceType.WidgetTemplate.GetEnumName(), widgetSetup.Widget, widgetSetup.DefaultTemplate), pluginResourceNameSpace)); }
public ProductMediaRepository(Database database, string sourceDatabaseName, string destinationDatabaseName) { _database = database; SourceDatabaseName = sourceDatabaseName; DestinationDatabaseName = destinationDatabaseName; EmbeddedResourceHelper.Bind(GetType()); }
/// <summary> /// Get plugin resource content /// </summary> /// <param name="resourceName"></param> /// <param name="pluginResourceNameSpace"></param> /// <param name="type"></param> /// <returns></returns> public static string GetPluginResourceContent(string resourceName, string pluginResourceNameSpace, DataSetupResourceType type = DataSetupResourceType.None) { if (type == DataSetupResourceType.None) { return(EmbeddedResourceHelper.GetString(resourceName, ResourceNamespace)); } return(EmbeddedResourceHelper.GetString(string.Format("{0}.{1}", type.GetEnumName(), resourceName), pluginResourceNameSpace)); }
public JsValue ExportDefault(BaristaContext context, BaristaModuleRecord referencingModule) { var buffer = SerializedScriptService.GetSerializedScript(ResourceName, context); var fnScript = context.ParseSerializedScript(buffer, () => EmbeddedResourceHelper.LoadResource(ResourceName), "[react-dom-server]"); var jsReact = fnScript.Call <JsObject>(); return(jsReact); }
/// <summary> /// Get module resource content /// </summary> /// <param name="resourceName"></param> /// <param name="moduleResourceNameSpace"></param> /// <param name="type"></param> /// <returns></returns> public static string GetModuleResourceContent(string resourceName, string moduleResourceNameSpace, ResourceType type = ResourceType.None) { if (type == ResourceType.None) { return(EmbeddedResourceHelper.GetString(resourceName, ResourceNamespace)); } return(EmbeddedResourceHelper.GetString(string.Format("{0}.{1}", type.GetEnumName(), resourceName), moduleResourceNameSpace)); }
public void Should_Throw_If_Unknown_Report_Name() { // Given / When var result = Record.Exception(() => EmbeddedResourceHelper.GetReportStyleSheet("Foo")); // Then result.IsArgumentOutOfRangeException("reportName"); }
public void Should_Read_Embedded_Resource(string reportName) { // When var result = EmbeddedResourceHelper.GetReportStyleSheet(reportName); // Then result.ShouldNotBeNullOrWhiteSpace(); }
public void Should_Throw_If_ReportName_Is_Empty() { // Given / When var result = Record.Exception(() => EmbeddedResourceHelper.GetReportStyleSheet(string.Empty)); // Then result.IsArgumentOutOfRangeException("reportName"); }
public void Should_Throw_If_ReportName_Is_Null() { // Given / When var result = Record.Exception(() => EmbeddedResourceHelper.GetReportStyleSheet(null)); // Then result.IsArgumentNullException("reportName"); }
public void GetResourcesThatDoNotExist() { Assert.IsNull(EmbeddedResourceHelper.GetResource(null)); Assert.IsNull(EmbeddedResourceHelper.GetResource(string.Empty)); // file extension is for client dependency framework, so used not needed for html files Assert.IsNull(EmbeddedResourceHelper.GetResource(EmbeddedResource.RESOURCE_PREFIX + CSS_RESOURCE + EmbeddedResource.FILE_EXTENSION)); Assert.IsNull(EmbeddedResourceHelper.GetResource(EmbeddedResource.RESOURCE_PREFIX + JS_RESOURCE + EmbeddedResource.FILE_EXTENSION)); }
public Flashing(Printing printer) { _printer = printer; EmbeddedResourceHelper.ExtractResources(_resources); var query = new System.Management.SelectQuery("Win32_SystemDriver") { Condition = "Name = 'libusb0'" }; var searcher = new System.Management.ManagementObjectSearcher(query); var drivers = searcher.Get(); if (drivers.Count > 0) { printer.Print("libusb0 driver found on system", MessageType.Info); } else { printer.Print("libusb0 driver not found - attempting to install", MessageType.Info); if (Directory.Exists(Path.Combine(Application.LocalUserAppDataPath, "dfu-prog-usb-1.2.2"))) { Directory.Delete(Path.Combine(Application.LocalUserAppDataPath, "dfu-prog-usb-1.2.2"), true); } ZipFile.ExtractToDirectory(Path.Combine(Application.LocalUserAppDataPath, "dfu-prog-usb-1.2.2.zip"), Application.LocalUserAppDataPath); var size = 0; var success = Program.SetupCopyOEMInf(Path.Combine(Application.LocalUserAppDataPath, "dfu-prog-usb-1.2.2", "atmel_usb_dfu.inf"), "", Program.OemSourceMediaType.SpostNone, Program.OemCopyStyle.SpCopyNewer, null, 0, ref size, null); if (!success) { var errorCode = Marshal.GetLastWin32Error(); var errorString = new Win32Exception(errorCode).Message; printer.Print("Error: " + errorString, MessageType.Error); } } _process = new Process(); //process.EnableRaisingEvents = true; //process.OutputDataReceived += OnOutputDataReceived; //process.ErrorDataReceived += OnErrorDataReceived; _startInfo = new ProcessStartInfo { UseShellExecute = false, RedirectStandardError = true, RedirectStandardOutput = true, RedirectStandardInput = true, CreateNoWindow = true }; }
public void GetResourceNameFromInvalidPath() { Assert.IsNull(EmbeddedResourceHelper.GetResourceNameFromPath(null)); Assert.IsNull(EmbeddedResourceHelper.GetResourceNameFromPath(string.Empty)); Assert.IsNull(EmbeddedResourceHelper.GetResourceNameFromPath("folder/file.ext")); Assert.IsNull(EmbeddedResourceHelper.GetResourceNameFromPath("/folder/file.ext")); Assert.IsNull(EmbeddedResourceHelper.GetResourceNameFromPath("~/folder/file.ext")); Assert.IsNull(EmbeddedResourceHelper.GetResourceNameFromPath("~/folder/file.ext" + EmbeddedResource.FILE_EXTENSION)); }
public FirebirdRepository(String connectionString, DateTime?lastExecutionTime = null) { EmbeddedResourceHelper.Bind(this); Connection = new FbConnection(connectionString); Connection.Open(); LastExecutionTime = lastExecutionTime; }
public void GetSomeData() { XDocument inputDocument = EmbeddedResourceHelper.ExtractManifestResourceAsXDocument("TestData.Input.CsProjArrangeInput.csproj"); var target = CreateDefaultTestTarget(CsProjArrange.ArrangeOptions.CombineRootElements); target.Arrange(inputDocument); inputDocument.Save(@"CsProjArrangeExpectedCombineRootElements.csproj"); }
private X509Certificate2 GetCertificate() { const string certificatePath = "IdentityServer4.RavenDB.Storage.Tests.DocumentStoreHolderTests.certificate.txt"; var cert = EmbeddedResourceHelper.GetFileContent(certificatePath); var bytes = Convert.FromBase64String(cert); return(new X509Certificate2(bytes)); }
static IANASettings() { var domains = EmbeddedResourceHelper.ReadDomainsSettings() .ConfigureAwait(false); var schemes = EmbeddedResourceHelper.ReadSchemesSettings() .ConfigureAwait(false); Domains = new HashSet <string>(domains.GetAwaiter().GetResult()); Schemes = new HashSet <string>(schemes.GetAwaiter().GetResult()); }
public void Setup() { this._emptyParameters = new List <ISearchParameter>(); this._documentResult = new DocumentResult <TestDocument>(); // Data using http://www.json-generator.com/ var assembly = typeof(DocumentResultBenchmarks).GetTypeInfo().Assembly; var str = EmbeddedResourceHelper.GetByName(assembly, $"SolrExpress.Benchmarks.Solr4.Search.Result.DocumentResultBenchmarks{this.ElementsCount}.json"); this._jsonObject = JObject.Parse(str); }
public CGenericode() { GetAssembly(); GENERICODE_04_XSDS = new List <XmlSchema>(new XmlSchema[] { XmlSchema.Read(EmbeddedResourceHelper.GetEmbeddedResourceAsStream(assembly, "GeneriCode.Schemas.genericode-code-list-0.4.xsd"), null), XmlSchema.Read(EmbeddedResourceHelper.GetEmbeddedResourceAsStream(assembly, "GeneriCode.Schemas.xml.xsd"), null) }); GENERICODE_10_XSDS = new List <XmlSchema>(new XmlSchema[] { XmlSchema.Read(EmbeddedResourceHelper.GetEmbeddedResourceAsStream(assembly, "GeneriCode.Schemas.genericode-1.0.xsd"), null), XmlSchema.Read(EmbeddedResourceHelper.GetEmbeddedResourceAsStream(assembly, "GeneriCode.Schemas.xml.xsd"), null) }); }
public void Setup() { this._searchParameters = new List <ISearchParameter>(); this._result = new DocumentResult <TestDocument>(); // Data using http://www.json-generator.com/ var assembly = typeof(DocumentResultBenchmarks).GetTypeInfo().Assembly; var jsonPlainText = EmbeddedResourceHelper.GetByName(assembly, $"SolrExpress.Benchmarks.Solr4.Search.Result.DocumentResultBenchmarks{this.ElementsCount}.json"); this._jsonStream = new MemoryStream(Encoding.GetEncoding(0).GetBytes(jsonPlainText)); }