public string ProvideLanguageContent(string languageId) { string languageFile = Path.Combine(this.LanguagesRegistration, $"{languageId}.xml"); return(Development.ReadFileAsString(languageFile)); }
private static string ReadFileAsString(string fileLocation) { byte[] buffer = new byte[102400]; Stream fileStream = null; try { fileStream = new FileStream(fileLocation, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); Encoding encoding = Development.DetectEncoding(ref fileStream); StringBuilder fileContent = new StringBuilder(); int rB; do { rB = fileStream.Read(buffer, 0, buffer.Length); if (rB > 0) { fileContent.Append(encoding.GetString(buffer, 0, rB)); } } while (rB != 0); return(fileContent.ToString()); } finally { fileStream?.Close(); } }
public string ProvideTemplateContent(string serviceFullPath) { string templateFile = Path.Combine(this.TemplatesRegistration, $"{serviceFullPath}.xchtml"); try { return(Development.ReadFileAsString(templateFile)); } catch (FileNotFoundException) { throw new Exceptions.DeploymentException(string.Format(Global.SystemMessages.TEMPLATE_NOTFOUND + "!", serviceFullPath)); } }
public string ProvideConfigurationContent() { string configurationFile = Path.Combine(this.TemplatesRegistration, "Configuration.xml"); try { return(Development.ReadFileAsString(configurationFile)); } catch (FileNotFoundException ex) { throw new Exceptions.DeploymentException(Global.SystemMessages.ESSENTIAL_CONFIGURATIONNOTFOUND, ex); } }