/// <summary> /// Query the data object from associated to the <see cref="ExternalObject"/> /// </summary> /// <param name="externalObject"> /// The <see cref="ExternalObject"/> that holds a reference to the data /// </param> /// <param name="token"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns> /// a Base64 encoded string that can be used in an HTML image element /// </returns> /// <remarks> /// The <see cref="ReqIFLoaderService"/> caches the data for fast /// </remarks> public async Task <string> QueryData(ExternalObject externalObject, CancellationToken token) { if (externalObject == null) { throw new ArgumentNullException($"The {nameof(externalObject)} may not be null"); } if (externalObjectDataCache.TryGetValue(externalObject, out var result)) { this.logger.LogDebug("External Object {uri} retrieved from Cache", externalObject.Uri); return(result); } var stream = await this.GetSourceStream(token); var targetStream = new MemoryStream(); externalObject.QueryLocalData(stream, targetStream); result = $"data:{externalObject.MimeType};base64,{Convert.ToBase64String(targetStream.ToArray())}"; if (this.externalObjectDataCache.TryAdd(externalObject, result)) { this.logger.LogDebug("External Object {uri} added to Cache", externalObject.Uri); } return(result); }
private static ExternalObject FillExternalFileData(string[] lines) { bool isValid = false; ExternalObject saObj = new ExternalObject(); foreach (string line in lines) { if (line.Contains("E_StringConn")) { string value = line.Substring(line.IndexOf("=") + 1).Trim(); isValid = value != string.Empty && value != "?"; saObj.StringConn = line.Substring(line.IndexOf("=") + 1).Trim(); } if (line.Contains("E_PATH_XML_FILE")) { string value = line.Substring(line.IndexOf("=") + 1).Trim(); isValid = value != string.Empty && value != "?"; saObj.path = line.Substring(line.IndexOf("=") + 1).Trim(); } } saObj.IsValid = isValid; return(saObj); }
/// <summary> /// Creates the url of a <see cref="ExternalObject"/> /// </summary> /// <param name="externalObject"> /// The <see cref="ExternalObject"/> of which the url is to be created /// </param> /// <returns> /// a string that represents the web-app url /// </returns> public static string CreateUrl(this ExternalObject externalObject) { var url = new StringBuilder(); url.Append($"/reqif/{externalObject.Owner.SpecElAt.ReqIFContent.DocumentRoot.TheHeader.Identifier}"); url.Append($"/externalobject/{externalObject.Uri.Base64Encode()} "); return(url.ToString()); }
public async Task <ExternalObject> ModifyExternalObject(ExternalObject external) { using (var stream = new StreamReader($"{AppDomain.CurrentDomain.BaseDirectory}\\Languages.json")) { var json = await stream.ReadToEndAsync(); var results = System.Text.Json.JsonSerializer.Deserialize <List <LanguageInfo> >(json, new System.Text.Json.JsonSerializerOptions { PropertyNameCaseInsensitive = true }); return(new ExternalObject { Language = results.First(l => l.Culture == external.Language).Culture }); } }
private static ListObjectInfo ReadConfigFile() { string[] lines = File.ReadAllLines("config.txt"); StudentAuthObj studentAuthObj = FillAuthenticationFileData(lines); StudentObj studentObj = FillStudentFileData(lines); ExternalObject externalObject = FillExternalFileData(lines); return(new ListObjectInfo { StudentAuthObj = studentAuthObj, StudentObj = studentObj, ExternalObject = externalObject }); }
private static void CreateXMLFile(ExternalObject externalObject) { XmlDocument doc = new XmlDocument(); doc.Load(externalObject.path); XmlNodeList nodeList = doc.GetElementsByTagName("connectionStrings"); foreach (XmlNode item in nodeList.Item(0).ChildNodes) { var log = (XmlNode)item.Attributes.GetNamedItem("name"); if (log.Value.Equals("CORE_CONNECTION")) { item.Attributes.GetNamedItem("connectionString").Value = externalObject.StringConn; } } doc.Save(externalObject.path); }
public override ConsoleMenuReport Execute() { ExternalObject externalObject = new ExternalObject() { SomeInt = 50, SomeString = "Initial string" }; ConsoleMenuOperation[] menuOperations = new ConsoleMenuOperation[3] { new SubProgram2.Operation_ChangeObjectsInt(externalObject), new SubProgram2.Operation_ChangeObjectsString(externalObject), new SubProgram2.Operation_CloseSubProgram2() }; ConsoleMenu subMenu2 = new ConsoleMenu("Sub Program 2:", menuOperations, externalObject.ToString()); subMenu2.Run(); return(new ConsoleMenuReport("Sub program 2 has been closed.", this.ToString(), Request.Suspend)); }
public Operation_ChangeObjectsString(ExternalObject externalObject) : base() { this.externalObject = externalObject; }
public SomeProxy(ExternalObject obj) { _obj = obj; }
public void SetUp() { this.externalObject = new ExternalObject(null); }
public C() : base() { // This happens *after* the base-class constructor. this.external = new ExternalObject(); }
public Task <ExternalObject> ModifyExternalObject(ExternalObject external) { var methodInfo = typeof(IExternalService).GetMethod(nameof(ModifyExternalObject)); return(PrisePluginBridge.Invoke(this.hostService, methodInfo, external) as Task <ExternalObject>); }