private static void GenerateGameResSrcFile_ScanFile(StringBuilder builder, string filePath, int indent, out string propName) { if (!PathHelper.IsPathVisible(filePath)) { propName = null; return; } if (!Resource.IsResourceFile(filePath)) { propName = null; return; } Type resType = Resource.GetTypeByFileName(filePath); if (resType == null) { propName = null; return; } string typeStr = resType.GetTypeCSCodeName(); string indentStr = new string('\t', indent); propName = GenerateGameResSrcFile_ClassName(filePath); builder.Append(indentStr); builder.Append("public static Duality.ContentRef<"); builder.Append(typeStr); builder.Append("> "); builder.Append(propName); builder.Append(" { get { return Duality.ContentProvider.RequestContent<"); builder.Append(typeStr); builder.Append(">(@\""); builder.Append(filePath); builder.AppendLine("\"); }}"); }
private static void PushSourceDirEvent(FileSystemEventArgs e) { if (!PathHelper.IsPathVisible(e.FullPath)) { return; } sourceDirEventBuffer.RemoveAll(f => f.FullPath == e.FullPath && f.ChangeType == e.ChangeType); sourceDirEventBuffer.Add(e); }
private static void PushFileEvent(FileEventQueue queue, FileSystemEventArgs watcherEvent, bool isDirectory) { // Do not track hidden paths if (!PathHelper.IsPathVisible(watcherEvent.FullPath)) { return; } // Translate the file system watcher event into our own data structure FileEvent fileEvent = TranslateFileEvent( watcherEvent, isDirectory); queue.Add(fileEvent); }
private static bool IsPathIgnored(string filePath) { if (!File.Exists(filePath) && !Directory.Exists(filePath)) { return(false); } if (!PathHelper.IsPathVisible(filePath)) { return(true); } if (filePath.Contains(@"/.svn/") || filePath.Contains(@"\.svn\")) { return(true); } return(false); }
private static void PushDataDirEvent(FileSystemEventArgs e, bool isDirectory) { if (!PathHelper.IsPathVisible(e.FullPath)) { return; } // In case we're dealing with a deletion, we'll need to add some meta information to know whether it was a file or directory. if (e.ChangeType == WatcherChangeTypes.Deleted) { string baseDir = (e.Name.Length > 0) ? e.FullPath.Remove(e.FullPath.Length - e.Name.Length, e.Name.Length) : ""; e = new DeletedEventArgsExt(e.ChangeType, baseDir, e.Name, isDirectory); } dataDirEventBuffer.RemoveAll(f => f.FullPath == e.FullPath && f.ChangeType == e.ChangeType); dataDirEventBuffer.Add(e); }
private static void GenerateGameResSrcFile_ScanDir(StringBuilder builder, string dirPath, int indent, out string className) { if (!PathHelper.IsPathVisible(dirPath)) { className = null; return; } dirPath = dirPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); string indentStr = new string('\t', indent); className = GenerateGameResSrcFile_ClassName(dirPath); // ---------- Begin class ---------- builder.Append(indentStr); builder.Append("public static class "); builder.Append(className); builder.AppendLine(" {"); // ---------- Sub directories ---------- string[] subDirs = Directory.GetDirectories(dirPath); List <string> dirClassNames = new List <string>(); foreach (string dir in subDirs) { string dirClassName; GenerateGameResSrcFile_ScanDir(builder, dir, indent + 1, out dirClassName); if (!string.IsNullOrEmpty(dirClassName)) { dirClassNames.Add(dirClassName); } } // ---------- Files ---------- string[] files = Directory.GetFiles(dirPath); List <string> filePropNames = new List <string>(); foreach (string file in files) { string propName; GenerateGameResSrcFile_ScanFile(builder, file, indent + 1, out propName); if (!string.IsNullOrEmpty(propName)) { filePropNames.Add(propName); } } // ---------- LoadAll() method ---------- builder.Append(indentStr); builder.Append('\t'); builder.AppendLine("public static void LoadAll() {"); foreach (string dirClassName in dirClassNames) { builder.Append(indentStr); builder.Append('\t'); builder.Append('\t'); builder.Append(dirClassName); builder.AppendLine(".LoadAll();"); } foreach (string propName in filePropNames) { builder.Append(indentStr); builder.Append('\t'); builder.Append('\t'); builder.Append(propName); builder.AppendLine(".MakeAvailable();"); } builder.Append(indentStr); builder.Append('\t'); builder.AppendLine("}"); // ---------- End class ---------- builder.Append(indentStr); builder.AppendLine("}"); }