C# FileInfo.GetType的代码示例
通过代码示例来学习C# FileInfo.GetType方法
通过代码示例来学习编程是非常高效的。
1. 代码示例提供了一个具体而直观的学习环境,使初学者能够立即看到编程概念和语法的实际应用。
2. 通过分析和模仿现有的代码实例,初学者可以更好地理解编程逻辑和算法的工作原理。
3. 代码实例往往涵盖了多种编程技巧和最佳实践,通过学习和模仿这些实例,学习者可以逐步掌握如何编写高效、可读性强和可维护的代码。这对于初学者来说,是一种快速提升编程水平的有效途径。
FileInfo.GetType是C#的System.IO命名空间下中的一个方法, 小编为大家找了一些网络大拿们常见的代码示例,源码中的FileInfo.GetType() 已经帮大家高亮显示了,大家可以重点学习FileInfo.GetType() 方法的写法,从而快速掌握该方法的应用。
FileInfo.GetType的代码示例1 - LoadConfig()
using System.IO; public void LoadConfig(string configDir) { XmlSerializer xml = new XmlSerializer(ConfigData.GetType()); FileInfo configFile = new FileInfo(configDir + "\\" + "sftpfilesystem.cfg"); if (!configFile.Exists) { return; } FileStream fs = null; try { fs = configFile.OpenRead(); ConfigData = (ConfigData) xml.Deserialize(fs); } catch (IOException e) { _logger.LogError(e.Message); } finally { fs?.Flush(); fs?.Close(); fs?.Dispose(); } }
开发者ID:zarunbal,项目名称:LogExpert,代码行数:32,代码来源:SftpFileSystem.cs
在LoadConfig()方法中,FileInfo的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
FileInfo.GetType的代码示例2 - BuildDelegate()
using System.IO; public static TDelegate BuildDelegate
(string sourceFilePath, string fullFunctionName, Assembly[] assemblies) where TDelegate : class { FileInfo fileInfo = new FileInfo(sourceFilePath); if (!fileInfo.Exists) throw new Error("source file name not found: {0}", sourceFilePath); Type delegateType = typeof(TDelegate); Error.Valid(IsDelegate(delegateType), "BuildDelegate (), FUNC_TYPE is not a delegate"); MethodInfo delegateMethodInfo = GetDelegateMethodInfo(delegateType); ParameterInfo[] delegateParameterInfos = delegateMethodInfo.GetParameters(); ParameterInfo delegateReturnInfos = delegateMethodInfo.ReturnParameter; Assembler assembler = new Assembler(); assembler.AddSharpmakeAssemblies(); assembler.Assemblies.AddRange(assemblies); Assembly assembly = assembler.BuildAssembly(fileInfo.FullName); List matchMethods = new List (); foreach (Type type in assembly.GetTypes()) { MethodInfo[] methodInfos = type.GetMethods(); foreach (MethodInfo methodInfo in methodInfos) { string fullName = methodInfo.DeclaringType.FullName + "." + methodInfo.Name; if (fullFunctionName == fullName && methodInfo.IsStatic && methodInfo.GetParameters().Length == delegateMethodInfo.GetParameters().Length) { ParameterInfo[] parameterInfos = methodInfo.GetParameters(); ParameterInfo returnInfos = methodInfo.ReturnParameter; bool equal = (returnInfos.GetType() == delegateReturnInfos.GetType() && parameterInfos.Length == delegateParameterInfos.Length); if (equal) { for (int i = 0; i < parameterInfos.Length; ++i) { if (parameterInfos[i].GetType() != delegateParameterInfos[i].GetType()) { equal = false; break; } } } if (equal) matchMethods.Add(methodInfo); } } } if (matchMethods.Count != 1) throw new Error("Cannot find method name {0} that match {1} in {2}", fullFunctionName, delegateMethodInfo.ToString(), sourceFilePath); MethodInfo method = matchMethods[0]; // bind the method Delegate returnDelegate; try { returnDelegate = method.CreateDelegate(delegateType); InternalError.Valid(returnDelegate != null); } catch (Exception e) { throw new InternalError(e); } TDelegate result = returnDelegate as TDelegate; InternalError.Valid(result != null, "Cannot cast built delegate into user delegate"); return result; }
开发者ID:ubisoft,项目名称:Sharpmake,代码行数:80,代码来源:Assembler.cs
在BuildDelegate()方法中,FileInfo的代码示例类中的GetType的代码示例方法一共出现了2次, 见黄色背景高亮显示的地方,欢迎大家点赞
FileInfo.GetType的代码示例3 - GenerateApplicationMakefile()
using System.IO; private string GenerateApplicationMakefile(Solution solution, List
configurations, string solutionPath, string solutionFile, out bool updated) { // Create the target folder. string solutionFolder = Util.GetCapitalizedPath(solutionPath); Directory.CreateDirectory(solutionFolder); // Main solution file. string solutionFileContentsPath = solutionFolder + Path.DirectorySeparatorChar + solutionFile + _solutionExtension; FileInfo solutionFileContentsInfo = new FileInfo(solutionFileContentsPath); // Write the makefile in a file in memory as to not overwrite if no changes detected. var fileGenerator = new FileGenerator(); using (fileGenerator.Declare("item", new ApplicationSettings(configurations))) { fileGenerator.Write(Template.ApplicationContent); } // Write the solution file updated = _builder.Context.WriteGeneratedFile(solution.GetType(), solutionFileContentsInfo, fileGenerator); return solutionFileContentsInfo.FullName; }
开发者ID:ubisoft,项目名称:Sharpmake,代码行数:24,代码来源:MakeApplication.cs
在GenerateApplicationMakefile()方法中,FileInfo的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
FileInfo.GetType的代码示例4 - GenerateProject()
using System.IO; public string GenerateProject(Project project, List
configurations, string projectPath, string projectFileName, out bool updated) { string projectDirectory = Util.GetCapitalizedPath(projectPath); Directory.CreateDirectory(projectDirectory); string fileFullPath = projectDirectory + Path.DirectorySeparatorChar + projectFileName + _makefileExtension; FileInfo fileInfo = new FileInfo(fileFullPath); var fileGenerator = new FileGenerator(); using (fileGenerator.Declare("item", new ProjectSettings(project, configurations, fileGenerator.Resolver))) { fileGenerator.Write(Template.GlobalTemplate); } fileGenerator.RemoveTaggedLines(); updated = _builder.Context.WriteGeneratedFile(project.GetType(), fileInfo, fileGenerator); return fileInfo.FullName; }
开发者ID:ubisoft,项目名称:Sharpmake,代码行数:22,代码来源:MakeProject.cs
在GenerateProject()方法中,FileInfo的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
FileInfo.GetType的代码示例5 - GenerateUserFile()
using System.IO; // Generate the user file. The base class is responsible for generating the file header and footer. // Actual user content is generated by the specialized user file class. public void GenerateUserFile(Builder builder, Project project, IEnumerable
configurations, IList generatedFiles, IList skipFiles) { var fileGenerator = new FileGenerator(); bool needToWriteFile = false; bool overwriteFile = true; foreach (Project.Configuration conf in configurations) { bool overwriteFileConfig; if (HasContentForConfiguration(conf, out overwriteFileConfig)) { if (!needToWriteFile) { fileGenerator.WriteLine(Template.UserFileHeader); needToWriteFile = true; } overwriteFile &= overwriteFileConfig; using (fileGenerator.Declare("platformName", Util.GetPlatformString(conf.Platform, conf.Project, conf.Target))) using (fileGenerator.Declare("conf", conf)) using (fileGenerator.Declare("project", project)) { fileGenerator.WriteLine(Template.PropertyGroupHeader); GenerateConfigurationContent(fileGenerator, conf); fileGenerator.WriteLine(Template.PropertyGroupFooter); } } } if (needToWriteFile) { fileGenerator.WriteLine(Template.UserFileFooter); // remove all line that contain RemoveLineTag fileGenerator.RemoveTaggedLines(); FileInfo userFileInfo = new FileInfo(_userFilePath); //Skip overwriting user file if it exists already so he can keep his setup // unless the UserProjSettings specifies to overwrite bool shouldWrite = !userFileInfo.Exists || overwriteFile; if (shouldWrite && builder.Context.WriteGeneratedFile(project.GetType(), userFileInfo, fileGenerator)) { generatedFiles.Add(userFileInfo.FullName); } else { // prevent deletion of skipped files. Util.RecordInAutoCleanupDatabase(userFileInfo.FullName); skipFiles.Add(userFileInfo.FullName); } } }
开发者ID:ubisoft,项目名称:Sharpmake,代码行数:55,代码来源:UserFile.cs
在GenerateUserFile()方法中,FileInfo的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
FileInfo.GetType的代码示例6 - Generate()
using System.IO; private string Generate(Solution solution, List
configurations, string solutionPath, string solutionFile, out bool updated) { // Create the target folder (solutions and projects are folders in XCode). string solutionFolder = Util.GetCapitalizedPath(solutionPath + Path.DirectorySeparatorChar + solutionFile + SolutionExtension); Directory.CreateDirectory(solutionFolder); // Main solution file. string solutionFileContentsPath = solutionFolder + Path.DirectorySeparatorChar + SolutionContentsFileName; FileInfo solutionFileContentsInfo = new FileInfo(solutionFileContentsPath); bool projectsWereFiltered; List solutionProjects = solution.GetResolvedProjects(configurations, out projectsWereFiltered).ToList(); solutionProjects.Sort((a, b) => string.Compare(a.ProjectName, b.ProjectName)); // Ensure all projects are always in the same order to avoid random shuffles // Move the first executable project on top. foreach (Solution.ResolvedProject resolvedProject in solutionProjects) { if (resolvedProject.Configurations[0].Output == Project.Configuration.OutputType.Exe) { solutionProjects.Remove(resolvedProject); solutionProjects.Insert(0, resolvedProject); break; } } if (solutionProjects.Count == 0) { updated = solutionFileContentsInfo.Exists; if (updated) File.Delete(solutionFileContentsPath); return solutionFolder; } var fileGenerator = new FileGenerator(); fileGenerator.Write(Template.Header); _solutionFolderCache.Clear(); List solutionsFiles = solutionProjects.Select(project => { var solutionFileItem = new SolutionFile() { Name = project.ProjectFile, Parent = ParseSolutionFolder(project.SolutionFolder) }; solutionFileItem.RegisterToParent(); return solutionFileItem; }).ToList(); List solutionsItems = solutionsFiles.GroupBy(solutionsItem => solutionsItem.GetRoot()).Select(group => group.Key).ToList(); solutionsItems.Sort((a, b) => string.Compare(a.Name, b.Name)); foreach (var solutionItem in solutionsItems) { //Sort of folders content (solutionItem as SolutionFolder)?.Sort(); WriteSolutionItem(fileGenerator, solutionItem); } fileGenerator.Write(Template.Footer); // Write the solution file updated = _builder.Context.WriteGeneratedFile(solution.GetType(), solutionFileContentsInfo, fileGenerator); return solutionFileContentsInfo.FullName; }
开发者ID:ubisoft,项目名称:Sharpmake,代码行数:58,代码来源:XCWorkspace.cs
在Generate()方法中,FileInfo的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
FileInfo.GetType的代码示例7 - GenerateProject()
using System.IO; private string GenerateProject( XCodeGenerationContext context, List
configurations, string projectFile, out bool updated ) { // Create the target folder (solutions and projects are folders in XCode). string projectFolder = Util.GetCapitalizedPath(Path.Combine(context.ProjectDirectoryCapitalized, projectFile + ProjectExtension)); Directory.CreateDirectory(projectFolder); string projectFilePath = Path.Combine(projectFolder, ProjectFileName); FileInfo projectFileInfo = new FileInfo(projectFilePath); var fileGenerator = InitProjectGenerator(context, configurations); // Write the project file updated = context.Builder.Context.WriteGeneratedFile(context.Project.GetType(), projectFileInfo, fileGenerator); OutputCustomProperties(context, projectFolder); string projectFileResult = projectFileInfo.FullName; return projectFileResult; }
开发者ID:ubisoft,项目名称:Sharpmake,代码行数:26,代码来源:XCodeProj.cs
在GenerateProject()方法中,FileInfo的代码示例类中的GetType的代码示例方法一共出现了1次, 见黄色背景高亮显示的地方,欢迎大家点赞
本文中的FileInfo.GetType方法示例由csref.cn整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。