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


C# ReferencedFileSave.GetRelativePath方法代码示例

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


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

示例1: RemoveReferencedFile


//.........这里部分代码省略.........
                ProjectManager.GlueProjectSave.GlobalContentHasChanged = true;

                // Much faster to just remove the tree node.  This was done
                // to reuse code and make things reactive, but this has gotten
                // slow on bigger projects.
                //ElementViewWindow.UpdateGlobalContentTreeNodes(false); // don't save here because projects will get saved below 

                Action refreshUiAction = () =>
                {
                    TreeNode treeNode = GlueState.Self.Find.ReferencedFileSaveTreeNode(referencedFileToRemove);

                    if (treeNode.Tag != referencedFileToRemove)
                    {
                        throw new Exception("Error removing the tree node - the selected tree node doesn't reference the file being removed");
                    }

                    treeNode.Parent.Nodes.Remove(treeNode);
                };

                MainGlueWindow.Self.Invoke((MethodInvoker)delegate
                    {
                        refreshUiAction();
                    }
                    );


                ContentLoadWriter.UpdateLoadGlobalContentCode();

                List<IElement> elements = ObjectFinder.Self.GetAllElementsReferencingFile(referencedFileToRemove.Name);

                foreach (IElement element in elements)
                {
                    if (regenerateCode)
                    {
                        CodeWriter.GenerateCode(element);
                    }
                }
            }

            #endregion


            // November 10, 2015
            // I feel like this may
            // have been old code before
            // we had full dependency tracking
            // in Glue. This file should only be
            // removed from the project if nothing
            // else references it, including no entities.
            // This code does just entities/screens/global
            // content, but doesn't check the full dependency
            // tree. I think we can just remove it and depend on
            // the code below.
            // Actually, removing this seems to cause problems - files
            // that should be removed aren't. So instead we'll chnage the
            // call to use the dependency tree:
            // replace:

            List<string> referencedFiles =
                GlueCommands.Self.FileCommands.GetAllReferencedFileNames().Select(item=>item.ToLowerInvariant()).ToList();

            string absoluteToLower = GlueCommands.Self.GetAbsoluteFileName(referencedFileToRemove).ToLowerInvariant();
            string relativeToProject = FileManager.MakeRelative(absoluteToLower, GlueState.Self.ContentDirectory);

            bool isReferencedByOtherContent = referencedFiles.Contains(relativeToProject);

            if (isReferencedByOtherContent == false)
            {
                additionalFilesToRemove.Add(referencedFileToRemove.GetRelativePath());

                string itemName = referencedFileToRemove.GetRelativePath();
                string absoluteName = ProjectManager.MakeAbsolute(referencedFileToRemove.Name, true);

                // I don't know why we were removing the file from the ProjectBase - it should
                // be from the Content project
                //ProjectManager.RemoveItemFromProject(ProjectManager.ProjectBase, itemName);
                ProjectManager.RemoveItemFromProject(ProjectManager.ProjectBase.ContentProject, itemName, performSave: false);

                foreach (ProjectBase syncedProject in ProjectManager.SyncedProjects)
                {
                    ProjectManager.RemoveItemFromProject(syncedProject.ContentProject, absoluteName);
                }
            }



            if (ProjectManager.IsContent(referencedFileToRemove.GetRelativePath()))
            {

                UnreferencedFilesManager.Self.RefreshUnreferencedFiles(false);
                foreach (var file in UnreferencedFilesManager.LastAddedUnreferencedFiles)
                {
                    additionalFilesToRemove.Add(file.FilePath);
                }
            }

            ReactToRemovalIfCsv(referencedFileToRemove, additionalFilesToRemove);

            GluxCommands.Self.SaveGlux();
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:101,代码来源:GluxCommands.cs

示例2: UpdateFileMembershipInProject

        /// <summary>
        /// Updates the presence of the RFS in the main project.  If the RFS has project specific files, then those
        /// files are updated in the appropriate synced project.  
        /// </summary>
        /// <remarks>
        /// This method does not update synced projects if the synced projects use the same file.  The reason is because
        /// this is taken care of when the projects are saved later on.
        /// </remarks>
        /// <param name="referencedFileSave">The RFS representing the file to update membership on.</param>
        /// <returns>Whether anything was added to any projects.</returns>
        public static bool UpdateFileMembershipInProject(ReferencedFileSave referencedFileSave)
        {
            var assetTypeInfo = referencedFileSave.GetAssetTypeInfo();

            bool shouldSkip = assetTypeInfo != null && assetTypeInfo.ExcludeFromContentProject;

            bool wasAnythingAdded = false;

            if (!shouldSkip)
            {

                bool useContentPipeline = referencedFileSave.UseContentPipeline || (assetTypeInfo != null && assetTypeInfo.MustBeAddedToContentPipeline);

                wasAnythingAdded = UpdateFileMembershipInProject(ProjectBase, referencedFileSave.GetRelativePath(), useContentPipeline, false);

                foreach (ProjectSpecificFile projectSpecificFile in referencedFileSave.ProjectSpecificFiles)
                {
                    wasAnythingAdded |= UpdateFileMembershipInProject(GetProjectByTypeId(projectSpecificFile.ProjectId), projectSpecificFile.FilePath, useContentPipeline, true);
                }
                if (wasAnythingAdded)
                {
                    int m = 3;
                }
            }
            return wasAnythingAdded;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:36,代码来源:ProjectManager.cs


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