public string[] Preprocess(IFileContent filename, Dictionary <string, bool> defs) { PreProcessor pp = new PreProcessor(); pp.SetFileProcessingChain(Plugins); Definitions definitions; if (defs == null) { definitions = new Definitions(); } else { definitions = new Definitions(defs); } string[] ret; try { ret = pp.Run(new[] { filename }, new Settings(), definitions); } catch (ProcessorException ex) { throw new TextProcessingException("Could not preprocess file: " + filename.GetFilePath(), ex); } return(ret); }
public string[] Preprocess(IFileContent filename, Dictionary <string, bool> defs) { PreProcessor pp = new PreProcessor(); Logger.VerbosityLevel = VerbosityLevel; pp.SetFileProcessingChain(Plugins); Definitions definitions; if (defs == null) { definitions = new Definitions(); } else { definitions = new Definitions(defs); } string[] ret = { "FILE NOT FOUND" }; try { ret = pp.Run(new[] { filename }, new Settings(), definitions); } catch (ProcessorException ex) { DebugHelper.Crash( new TextProcessingException("Could not preprocess file: " + filename.GetFilePath(), ex), true); } return(ret); }
/// <summary> /// Returns true if the path is valid relative to the current path(the current script that is processed /// </summary> /// <param name="currentPath">the current path of the program</param> /// <param name="file">the relative file path</param> /// <returns>true if the relative path is pointing towards a valid file.</returns> public static bool FileExistsRelativeTo(string currentPath, IFileContent file) { if (file.HasValidFilepath) { return(FileExistsRelativeTo(currentPath, file.GetFilePath())); } return(true); }
public FunctionSettings(string moduleName, string functionHandler, IFileContent <string> code, IFileContent <string> requirements, IFileContent <byte[]> assembly) { ModuleName = moduleName; FunctionHandler = functionHandler; Code = code; Requirements = requirements; Assembly = assembly; }
public OpenFile( IFileContent data ) { Data = data; Data.PropertyChanged += ( s, e ) => InvokePropertyChanged( "Data" ); EditCommand = new RelayCommand( InvokeEdit ); StopEditCommand = new RelayCommand( InvokeStopEdit ); SaveAsCommand = new RelayCommand( SaveAs ); CloseCommand = new RelayCommand( InvokeClose ); }
/// <summary> /// Constructor /// </summary> /// <param name="separator">the separator used.</param> /// <param name="path">the path to the file</param> /// <param name="key">the key of the source file</param> /// <param name="pluginCache">the plugin cache that is used.</param> public SourceScript(string separator, IFileContent path, ImportResult importInfo, bool isInline) : base( ExtPPDebugConfig.Settings, "" ) { this.importInfo = importInfo; IsInline = isInline; filepath = path; }
public void TestSetup() { parser = new KeyValueParser(); contentBuilder = new StringBuilder(); content = Substitute.For <IFileContent>(); content.AsStream.Returns(_ => new MemoryStream(Encoding.UTF8.GetBytes(contentBuilder.ToString()))); fileName = Guid.NewGuid().ToString(); }
/// <summary> /// Loads and preprocesses the file specified /// </summary> /// <param name="filename">the filepath</param> /// <param name="defs">definitions</param> /// <returns>the source as string</returns> internal static string PreprocessSource(IFileContent filename, Dictionary <string, bool> defs) { StringBuilder sb = new StringBuilder(); string[] src = PreprocessLines(filename, defs); for (int i = 0; i < src.Length; i++) { sb.Append(src[i] + "\n"); } return(sb.ToString()); }
public void TestGetTopWords_FileContentsNull_ValueReturnedNull() { //Arrange fc = null; WordCount wc = new WordCount(fc); //Act var actual = wc.GetTopWords(2); //Assert Assert.IsNull(actual); }
/// <summary> /// Convenience wrapper to create a source script without knowing the actual type of the script. /// </summary> /// <param name="separator">the separator used.</param> /// <param name="file">the path of the file</param> /// <param name="key">the key of the file</param> /// <param name="importInfo">the import info of the key and path importation</param> /// <returns>the success state of the operation</returns> public bool TryCreateScript(out ISourceScript script, string separator, IFileContent file, ImportResult importInfo) { if (LockScriptCreation) { script = null; this.Warning("A Plugin is trying to add a file outside of the main stage. Is the configuration correct?"); return(false); } script = new SourceScript(separator, file, importInfo); return(true); }
internal static string[] PreprocessLines(IFileContent file, Dictionary <string, bool> defs) { string ext = new string(file.GetFilePath().TakeLast(3).ToArray()); if (_configs.ContainsKey(ext)) { DebugHelper.Log("Found Matching PreProcessor Config for: " + ext, 1 | 1 << 21); return(_configs[ext].Preprocess(file, defs)); } DebugHelper.Log("Loading File with Default PreProcessing", 1 | 1 << 21); return(_configs["***"].Preprocess(file, defs)); }
/// <summary> /// Convenience wrapper to create a source script without knowing the actual type of the script. /// </summary> /// <param name="separator">the separator used.</param> /// <param name="file">the path of the file</param> /// <param name="key">the key of the file</param> /// <param name="importInfo">the import info of the key and path importation</param> /// <returns>the success state of the operation</returns> public bool TryCreateScript(out ISourceScript script, string separator, IFileContent file, ImportResult importInfo) { if (lockScriptCreation) { script = null; Logger.Log(PPLogType.Warning, Verbosity.Level3, "A Plugin is trying to add a file outside of the main stage. Is the configuration correct?"); return(false); } script = new SourceScript(separator, file, importInfo); return(true); }
async Task <File> IFileConnector.CreateAsync(string spaceIdOrWikiName, IFileContent fileContent, File file, string folderName) { if (spaceIdOrWikiName == null) { throw new ArgumentNullException(nameof(spaceIdOrWikiName)); } if (fileContent == null) { throw new ArgumentNullException(nameof(fileContent)); } var content = CreateContent(fileContent, folderName, file); var createdDocument = await PostAsync <File>("https://bigfiles.assembla.com" + $"/v1/spaces/{spaceIdOrWikiName}/documents", content).ConfigureAwait(false); return(createdDocument); }
protected object GetFileObjectField(string name, IFileObject file) { if (name == "is_file") { return(file.Type == FileType.File); } if (name == "is_folder") { return(file.Type == FileType.Folder); } string fName = file.Name.Replace('\\', '/'); if (name == "name") { return(Path.GetFileName(fName)); } if (name == "full_name") { return(fName); } if (name == "ext") { return(Path.GetExtension(fName)); } if (name == "folder_name") { return(Path.GetDirectoryName(fName)); } IFileContent fContent = file.Content; if (name == "size") { return(fContent.Size); } if (name == "last_modified") { return(fContent.LastModifiedTime); } throw new ArgumentException("Unknown field name: " + name); }
public ObjectNode Parse(string name, IFileContent content) { var index = new Dictionary <string, List <string> >(); var reader = new StreamReader(content.AsStream, Encoding.UTF8); while (!reader.EndOfStream) { var line = reader.ReadLine()?.Trim(ByteOrderMarks)?.Trim(); if (string.IsNullOrEmpty(line) || line.StartsWith(CommentToken)) { continue; } ParseLine(line, out var key, out var value); if (index.TryGetValue(key, out var values)) { values.Add(value); } else { index[key] = new List <string> { value } }; } if (index.Count == 0) { index.Add(string.Empty, new List <string> { string.Empty }); } return(new ObjectNode(name, index.Select(pair => ConvertToNode(pair.Key, pair.Value)))); }
async Task IFileConnector.UpdateAsync(string spaceIdOrWikiName, File file, IFileContent fileContent) { if (spaceIdOrWikiName == null) { throw new ArgumentNullException(nameof(spaceIdOrWikiName)); } if (file == null) { throw new ArgumentNullException(nameof(file)); } if (file.Id == null) { throw new ArgumentNullException(nameof(file.Id)); } if (fileContent == null) { throw new ArgumentNullException(nameof(fileContent)); } var content = CreateContent(fileContent, file: file); await PutAsync("https://bigfiles.assembla.com" + $"/v1/spaces/{spaceIdOrWikiName}/documents/{file.Id}", content).ConfigureAwait(false); }
private HttpContent CreateContent(IFileContent fileContent, string folderName = null, File file = null) { var content = new MultipartFormDataContent { { fileContent.ToContent(), "document[file]", fileContent.FileName } }; if (folderName != null) { content.Add(new StringContent(folderName), "folder_name"); } if (file != null) { if (file.IsAttachedToTicket() || file.IsAttachedToMessage() || file.IsAttachedToMilestone()) { content.Add(new StringContent(file.AttachableType.Value.ToString("G")), "document[attachable_type]"); content.Add(new StringContent(file.AttachableId), "document[attachable_id]"); } if (file.Description != null) { content.Add(new StringContent(file.Description), "document[description]"); } if (file.FileName != null) { content.Add(new StringContent(file.FileName), "document[filename]"); } if (file.Name != null) { content.Add(new StringContent(file.Name), "document[name]"); } } return(content); }
internal static string[] PreprocessLines(IFileContent file, Dictionary <string, bool> defs) { string ext = new string(file.GetFilePath().Reverse().Take(3).Reverse().ToArray()); string key = ""; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { key = "WIN"; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { key = "OSX"; } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { key = "LINUX"; } if (defs == null) { defs = new Dictionary <string, bool>(); } if (!defs.ContainsKey(key)) { defs.Add(key, true); } if (Configs.ContainsKey(ext)) { Logger.Log(DebugChannel.Log, "Found Matching PreProcessor Config for: " + ext); return(Configs[ext].Preprocess(file, defs)); } Logger.Log(DebugChannel.Log, "Loading File with Default PreProcessing"); return(Configs["***"].Preprocess(file, defs)); }
/// <summary> /// Constructor Inject the filecontent interface member type /// </summary> /// <param name="filecontent"></param> /// public WordCount(IFileContent filecontent) { this.FileContent = filecontent; }
public ObjectNode Parse(string name, IFileContent content) => null;
/// <summary> /// Constructor /// </summary> /// <param name="separator">the separator used.</param> /// <param name="path">the path to the file</param> /// <param name="key">the key of the source file</param> /// <param name="pluginCache">the plugin cache that is used.</param> public SourceScript(string separator, IFileContent path, ImportResult importInfo) : base(ExtPPDebugConfig .Settings) { this.importInfo = importInfo; filepath = path; }
// upload the content public DoMyAction(IFileContent content, IApplyBusinessLogic doMyThing, IUploadContent uploader) { _content = content; _doMyThing = doMyThing; _uploader = uploader; }
public ObjectNode Parse(string name, IFileContent content) => new ObjectNode(name, new [] { new ValueNode(string.Empty, content.AsString) });
public FunctionSettings(string moduleName, string functionHandler, IFileContent <byte[]> assembly) { ModuleName = moduleName; FunctionHandler = functionHandler; Assembly = assembly; }
public DbFileFactory(IFileContent fileContentContext) { _fileContentContext = fileContentContext; }
public ObjectNode Parse(string name, IFileContent content) => parser(name, content);
/// <summary> /// 创建 /// </summary> /// <param name="fileContent"></param> /// <param name="fileIndex"></param> public FileManager(IFileContent fileContent, IFileIndex fileIndex) { FileContent = fileContent; FileIndex = fileIndex; }
/// <summary> /// Constructor /// </summary> /// <param name="separator">the separator used.</param> /// <param name="path">the path to the file</param> /// <param name="key">the key of the source file</param> /// <param name="pluginCache">the plugin cache that is used.</param> public SourceScript(string separator, IFileContent path, ImportResult importInfo) { this.importInfo = importInfo; filepath = path; }
public FunctionSettings(string moduleName, string functionHandler, string assemblyPath, IFileContent <byte[]> assembly) { this.ModuleName = moduleName; this.FunctionHandler = functionHandler; this.AssemblyPath = assemblyPath; this.Assembly = assembly; }
public void AddFile(IFileContent ifc) { Files.TryAdd(ifc.FileId, ifc); }
public ObjectNode Parse(string name, IFileContent content) => new ObjectNode(name, new[] { new ValueNode(string.Empty, Convert.ToBase64String(content.AsBytes)) });