当前位置: 首页>>代码示例>>C#>>正文


C# UFile.ToWindowsPath方法代码示例

本文整理汇总了C#中SiliconStudio.Core.IO.UFile.ToWindowsPath方法的典型用法代码示例。如果您正苦于以下问题:C# UFile.ToWindowsPath方法的具体用法?C# UFile.ToWindowsPath怎么用?C# UFile.ToWindowsPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SiliconStudio.Core.IO.UFile的用法示例。


在下文中一共展示了UFile.ToWindowsPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpgradeProject

        private async Task UpgradeProject(MSBuildWorkspace workspace, UFile projectPath)
        {
            // Upgrade .csproj file
            // TODO: Use parsed file?
            var fileContents = File.ReadAllText(projectPath);

            // Rename referenced to the package, shaders and effects
            var newFileContents = fileContents.Replace(".pdx", ".xk");

            // Rename variables
            newFileContents = newFileContents.Replace("Paradox", "Xenko");

            // Save file if there were any changes
            if (newFileContents != fileContents)
            {
                File.WriteAllText(projectPath, newFileContents);
            }

            // Upgrade source code
            var project = await workspace.OpenProjectAsync(projectPath.ToWindowsPath());
            var compilation = await project.GetCompilationAsync();
            var tasks = compilation.SyntaxTrees.Select(syntaxTree => Task.Run(() => UpgradeSourceFile(syntaxTree))).ToList();

            await Task.WhenAll(tasks);
        }
开发者ID:hsabaleuski,项目名称:paradox,代码行数:25,代码来源:XenkoPackageUpgrader.cs

示例2: Save


//.........这里部分代码省略.........
                    filesToDelete.Clear();
                }

                //batch projects
                var vsProjs = new Dictionary<string, Project>();

                foreach (var asset in Assets)
                {
                    if (asset.IsDirty)
                    {
                        var assetPath = asset.FullPath;

                        try
                        {
                            //Handle the ProjectSourceCodeAsset differently then regular assets in regards of Path
                            var sourceCodeAsset = asset.Asset as ProjectSourceCodeAsset;
                            if (sourceCodeAsset != null)
                            {
                                var profile = Profiles.FindSharedProfile();

                                var lib = profile?.ProjectReferences.FirstOrDefault(x => x.Type == ProjectType.Library && asset.Location.FullPath.StartsWith(x.Location.GetFileName()));
                                if (lib == null) continue;

                                var projectFullPath = UPath.Combine(RootDirectory, lib.Location);
                                var fileFullPath = UPath.Combine(RootDirectory, asset.Location);
                                var filePath = fileFullPath.MakeRelative(projectFullPath.GetFullDirectory());
                                var codeFile = new UFile(filePath + AssetRegistry.GetDefaultExtension(sourceCodeAsset.GetType()));

                                Project project;
                                if (!vsProjs.TryGetValue(projectFullPath, out project))
                                {
                                    project = VSProjectHelper.LoadProject(projectFullPath);
                                    vsProjs.Add(projectFullPath, project);
                                }

                                //check if the item is already there, this is possible when saving the first time when creating from a template
                                if (project.Items.All(x => x.EvaluatedInclude != codeFile.ToWindowsPath()))
                                {
                                    project.AddItem(AssetRegistry.GetDefaultExtension(sourceCodeAsset.GetType()) == ".cs" ? "Compile" : "None", codeFile.ToWindowsPath());
                                    //todo None case needs Generator and LastGenOutput properties support! (eg xksl)
                                }

                                asset.SourceProject = projectFullPath;
                                asset.SourceFolder = RootDirectory.GetFullDirectory();
                                sourceCodeAsset.ProjectInclude = codeFile;
                                sourceCodeAsset.ProjectName = Path.GetFileNameWithoutExtension(projectFullPath.ToWindowsPath());
                                sourceCodeAsset.AbsoluteSourceLocation = UPath.Combine(projectFullPath.GetFullDirectory(), codeFile);
                                sourceCodeAsset.AbsoluteProjectLocation = projectFullPath;

                                assetPath = sourceCodeAsset.AbsoluteSourceLocation;
                            }

                            // Notifies the dependency manager that an asset with the specified path is being saved
                            if (session != null && session.HasDependencyManager)
                            {
                                session.DependencyManager.AddFileBeingSaveDuringSessionSave(assetPath);
                            }

                            // Incject a copy of the base into the current asset when saving
                            var assetBase = asset.Asset.Base;
                            if (assetBase != null && !assetBase.IsRootImport)
                            {
                                var assetBaseItem = session != null ? session.FindAsset(assetBase.Id) : Assets.Find(assetBase.Id);
                                if (assetBaseItem != null)
                                {
                                    var newBase = (Asset)AssetCloner.Clone(assetBaseItem.Asset);
                                    newBase.Base = null;
                                    asset.Asset.Base = new AssetBase(asset.Asset.Base.Location, newBase);
                                }
                            }

                            AssetSerializer.Save(assetPath, asset.Asset);
                            asset.IsDirty = false;
                        }
                        catch (Exception ex)
                        {
                            log.Error(this, asset.ToReference(), AssetMessageCode.AssetCannotSave, ex, assetPath);
                        }
                    }
                }

                foreach (var project in vsProjs.Values)
                {
                    project.Save();
                    project.ProjectCollection.UnloadAllProjects();
                    project.ProjectCollection.Dispose();
                }

                Assets.IsDirty = false;

                // Save properties like the Xenko version used
                PackageSessionHelper.SaveProperties(this);
            }
            finally
            {
                // Rollback all relative UFile to absolute paths
                analysis.Parameters.ConvertUPathTo = UPathType.Absolute;
                analysis.Run();
            }
        }
开发者ID:joewan,项目名称:xenko,代码行数:101,代码来源:Package.cs

示例3: Save


//.........这里部分代码省略.........

                foreach (var asset in Assets)
                {
                    if (asset.IsDirty)
                    {
                        var assetPath = asset.FullPath;

                        try
                        {
                            //Handle the ProjectSourceCodeAsset differently then regular assets in regards of Path
                            var sourceCodeAsset = asset.Asset as ProjectSourceCodeAsset;
                            if (sourceCodeAsset != null)
                            {
                                var profile = Profiles.FindSharedProfile();

                                var lib = profile?.ProjectReferences.FirstOrDefault(x => x.Type == ProjectType.Library && asset.Location.FullPath.StartsWith(x.Location.GetFileName()));
                                if (lib == null) continue;

                                var projectFullPath = UPath.Combine(RootDirectory, lib.Location);
                                var fileFullPath = UPath.Combine(RootDirectory, asset.Location);
                                var filePath = fileFullPath.MakeRelative(projectFullPath.GetFullDirectory());
                                var codeFile = new UFile(filePath + AssetRegistry.GetDefaultExtension(sourceCodeAsset.GetType()));

                                Project project;
                                if (!vsProjs.TryGetValue(projectFullPath, out project))
                                {
                                    project = VSProjectHelper.LoadProject(projectFullPath);
                                    vsProjs.Add(projectFullPath, project);
                                }

                                asset.SourceProject = projectFullPath;
                                asset.SourceFolder = RootDirectory.GetFullDirectory();
                                sourceCodeAsset.ProjectInclude = codeFile;
                                sourceCodeAsset.ProjectName = Path.GetFileNameWithoutExtension(projectFullPath.ToWindowsPath());
                                sourceCodeAsset.AbsoluteSourceLocation = UPath.Combine(projectFullPath.GetFullDirectory(), codeFile);
                                sourceCodeAsset.AbsoluteProjectLocation = projectFullPath;
                                assetPath = sourceCodeAsset.AbsoluteSourceLocation;

                                //check if the item is already there, this is possible when saving the first time when creating from a template
                                if (project.Items.All(x => x.EvaluatedInclude != codeFile.ToWindowsPath()))
                                {
                                    var generatorAsset = sourceCodeAsset as ProjectCodeGeneratorAsset;
                                    if (generatorAsset != null)
                                    {
                                        generatorAsset.GeneratedAbsolutePath = new UFile(generatorAsset.AbsoluteSourceLocation).GetFullPathWithoutExtension() + ".cs";
                                        generatorAsset.GeneratedInclude = new UFile(generatorAsset.ProjectInclude).GetFullPathWithoutExtension() + ".cs";

                                        project.AddItem("None", codeFile.ToWindowsPath(), 
                                            new List<KeyValuePair<string, string>>
                                            {
                                                new KeyValuePair<string, string>("Generator", generatorAsset.Generator),
                                                new KeyValuePair<string, string>("LastGenOutput", new UFile(generatorAsset.GeneratedInclude).GetFileNameWithExtension())
                                            });

                                        project.AddItem("Compile", new UFile(generatorAsset.GeneratedInclude).ToWindowsPath(),
                                            new List<KeyValuePair<string, string>>
                                            {
                                                new KeyValuePair<string, string>("AutoGen", "True"),
                                                new KeyValuePair<string, string>("DesignTime", "True"),
                                                new KeyValuePair<string, string>("DesignTimeSharedInput", "True"),
                                                new KeyValuePair<string, string>("DependentUpon", new UFile(generatorAsset.ProjectInclude).GetFileNameWithExtension())
                                            });
                                    }
                                    else
                                    {
                                        project.AddItem("Compile", codeFile.ToWindowsPath());
开发者ID:cg123,项目名称:xenko,代码行数:67,代码来源:Package.cs

示例4: UpgradeProject

        private async Task UpgradeProject(MSBuildWorkspace workspace, UFile projectPath)
        {
            // Upgrade .csproj file
            // TODO: Use parsed file?
            var fileContents = File.ReadAllText(projectPath);

            // Rename referenced to the package, shaders and effects
            var newFileContents = fileContents.Replace(".pdx", ".xk");

            // Rename variables
            newFileContents = newFileContents.Replace("Paradox", "Xenko");

            // Create fallback for old environment variable
            var index = newFileContents.IndexOf("<SiliconStudioCurrentPackagePath>", StringComparison.InvariantCulture);
            if (index >= 0)
            {
                newFileContents = newFileContents.Insert(index, "<SiliconStudioXenkoDir Condition=\"'$(SiliconStudioXenkoDir)' == ''\">$(SiliconStudioParadoxDir)</SiliconStudioXenkoDir>\n    ");
            }

            // Save file if there were any changes
            if (newFileContents != fileContents)
            {
                File.WriteAllText(projectPath, newFileContents);
            }

            // Upgrade source code
            var project = await workspace.OpenProjectAsync(projectPath.ToWindowsPath());
            var compilation = await project.GetCompilationAsync();
            var tasks = compilation.SyntaxTrees.Select(syntaxTree => Task.Run(() => UpgradeSourceFile(syntaxTree))).ToList();

            await Task.WhenAll(tasks);
        }
开发者ID:joewan,项目名称:xenko,代码行数:32,代码来源:XenkoPackageUpgrader.cs


注:本文中的SiliconStudio.Core.IO.UFile.ToWindowsPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。