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


C# SaveClasses.ReferencedFileSave类代码示例

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


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

示例1: AdjustDataFilesIfIsCsv

        public static void AdjustDataFilesIfIsCsv(string oldName, ReferencedFileSave rfs)
        {
            // We'll remove the old file from the project, delete it, then have the RFS regenerate/add the new one to the project

            //////////////Early Out///////////////////

            if (!rfs.IsCsvOrTreatedAsCsv || UsesAlterntaiveClass(rfs))
            {
                return;
            }
            ////////////End Early Out/////////////////
            string className = rfs.GetTypeForCsvFile(oldName);

            string whatToRemove = "DataTypes/" + className + ".Generated.cs";
            ProjectManager.ProjectBase.RemoveItem(whatToRemove);
            string fileToDelete = whatToRemove;
            fileToDelete = ProjectManager.MakeAbsolute(fileToDelete);
            if (System.IO.File.Exists(fileToDelete))
            {
                try
                {
                    FileHelper.DeleteFile(fileToDelete);
                }
                catch (Exception e)
                {
                    GlueGui.ShowMessageBox("Could not delete the file " + fileToDelete + "\n\nThe file is no longer referneced by the project so it is not necessary to delete this file manually.");
                }
            }

            CsvCodeGenerator.GenerateAndSaveDataClass(rfs, rfs.CsvDelimiter);
        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:31,代码来源:ReferencedFileSaveSetVariableLogic.cs

示例2: GetTreeNodeFor

        private TreeNode GetTreeNodeFor(ReferencedFileSave referencedFileSave, string currentPath, TreeNode treeNode)
        {

            return null;


		}
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:7,代码来源:ReferencedFileListTreeNode.cs

示例3: GetMemberNamesFrom

        internal static List<string> GetMemberNamesFrom(ReferencedFileSave rfs)
        {
            List<string> toReturn = new List<string>();
                
                        
            string fileName = rfs.Name;
            fileName = ProjectManager.MakeAbsolute(fileName);

            RuntimeCsvRepresentation rcr = CsvFileManager.CsvDeserializeToRuntime(
                fileName);

                            
            for (int i = 0; i < rcr.Headers.Length; i++)
            {
                string memberName = rcr.Headers[i].Name;

                if (memberName.Trim().StartsWith("//"))
                {
                    continue;
                }

                memberName = StringFunctions.RemoveWhitespace(memberName); 

                if (memberName.Contains("("))
                {
                    memberName = memberName.Substring(0, memberName.IndexOfAny(new char[] { '(' }));
                }

                toReturn.Add(memberName);
            }


            return toReturn;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:34,代码来源:CsvCodeGenerator.cs

示例4: CreateZip

        public static string CreateZip(ReferencedFileSave rfs)
        {
            string absoluteFile = ProjectManager.MakeAbsolute(rfs.Name, true);

            List<string> allFiles = FileReferenceManager.Self.GetFilesReferencedBy(
                absoluteFile, TopLevelOrRecursive.Recursive);

            #region Check for relative files

            string directoryOfMainFile = FileManager.GetDirectory(absoluteFile);
            bool areAnyFilesOutsideOfMainDirectory = false;
            foreach (string referencedFile in allFiles)
            {
                if (!FileManager.IsRelativeTo(referencedFile, directoryOfMainFile))
                {
                    areAnyFilesOutsideOfMainDirectory = true;
                    break;
                }
            }


            #endregion
            string outputFile;

            if (areAnyFilesOutsideOfMainDirectory)
            {
                outputFile = null;    
            }
            else
            {
                allFiles.Add(absoluteFile);

                string extension = FileManager.GetExtension(rfs.Name);
                string newExtension = "zip";
                if (extension.Length == 4 && extension[3] == 'x')
                {
                    newExtension = extension.Substring(0, 3) + 'z';
                }

                outputFile = FileManager.RemoveExtension(absoluteFile) + "." + newExtension;

                using (ZipFile zip = new ZipFile())
                {
                    foreach (string fileToAdd in allFiles)
                    {
                        string directory = FileManager.MakeRelative(FileManager.GetDirectory(fileToAdd), directoryOfMainFile);
                        if (directory.EndsWith("/"))
                        {
                            directory = directory.Substring(0, directory.Length - 1);
                        }

                        zip.AddFile(fileToAdd, directory);
                    }

                    zip.Save(outputFile);
                }
            }
            return outputFile;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:59,代码来源:Zipper.cs

示例5: GenerateTimedEmit

 public static void GenerateTimedEmit(ICodeBlock codeBlock, ReferencedFileSave rfs, IElement element)
 {
     if (rfs.LoadedAtRuntime && !rfs.LoadedOnlyWhenReferenced && (element is ScreenSave || rfs.IsSharedStatic == false)
         && !string.IsNullOrEmpty(rfs.Name) && FileManager.GetExtension(rfs.Name) == "emix")
     {
         codeBlock.Line(rfs.GetInstanceName() + ".TimedEmit();");
     }
 }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:8,代码来源:ParticleCodeGenerator.cs

示例6: Select

        public void Select(ReferencedFileSave referencedFile, string objectInFile = null)
        {
            // first let's select it:
            GlueState.Self.CurrentReferencedFileSave = referencedFile;

            // Next lets tell the plugin manager to try to find this object:
            if( string.IsNullOrEmpty(objectInFile) == false)
            {
                PluginManager.SelectItemInCurrentFile(objectInFile);
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:11,代码来源:SelectCommands.cs

示例7: CreateCsvContainerEntitySave

        private void CreateCsvContainerEntitySave()
        {
            mCsvContainerEntitySave = new EntitySave();
            mCsvContainerEntitySave.Name = "CsvContainerEntityInExposedVariableTests";
            ObjectFinder.Self.GlueProject.Entities.Add(mCsvContainerEntitySave);

            ReferencedFileSave rfs = new ReferencedFileSave();
            rfs.SourceFile = "Whatever.csv";
            rfs.Name = "Whatever.csv";
            mCsvContainerEntitySave.ReferencedFiles.Add(rfs);
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:11,代码来源:ExposedVariableTests.cs

示例8: RenameReferencedFile

        public static void RenameReferencedFile(string oldName, string newName, ReferencedFileSave rfs, IElement container)
        {
            string oldDirectory = FileManager.GetDirectory(oldName);
            string newDirectory = FileManager.GetDirectory(newName);
            string newFileNameAbsolute = ProjectManager.MakeAbsolute(newName);
            string instanceName = FileManager.RemovePath(FileManager.RemoveExtension(newName));
            string whyIsntValid;
            if (oldDirectory != newDirectory)
            {
                MessageBox.Show("The old file was located in \n" + oldDirectory + "\n" +
                    "The new file is located in \n" + newDirectory + "\n" +
                    "Currently Glue does not support changing directories.", "Warning");

                rfs.SetNameNoCall(oldName);
            }
            else if (NameVerifier.IsReferencedFileNameValid(instanceName, rfs.GetAssetTypeInfo(), rfs, container, out whyIsntValid) == false)
            {
                MessageBox.Show(whyIsntValid);
                rfs.SetNameNoCall(oldName);

            }
            else
            {
                bool shouldMove = true;
                bool shouldContinue = true;

                CheckForExistingFileOfSameName(oldName, rfs, newFileNameAbsolute, ref shouldMove, ref shouldContinue);

                if (shouldContinue)
                {
                    MoveFileIfNecessary(oldName, newName, shouldMove);

                    string rfsType = rfs.RuntimeType;
                    if (rfsType != null && rfsType.Contains("."))
                    {
                        // We dont want the fully qualified type.
                        rfsType = FileManager.GetExtension(rfsType);
                    }
                    UpdateObjectsUsingFile(container, oldName, rfs, rfsType);

                    RegenerateCodeAndUpdateUiAccordingToRfsRename(oldName, newName, rfs);

                    UpdateBuildItemsForRenamedRfs(oldName, newName);

                    AdjustDataFilesIfIsCsv(oldName, rfs);

                    GluxCommands.Self.SaveGlux();

                    ProjectManager.SaveProjects();
                }
            }
        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:52,代码来源:ReferencedFileSaveSetVariableLogic.cs

示例9: GetDictionaryTypes

        public static void GetDictionaryTypes(ReferencedFileSave referencedFileSave, out string keyType, out string valueType)
        {
            valueType = referencedFileSave.GetTypeForCsvFile();

            // To know the value type, we gotta pop this bad boy open and find the first requied type
            keyType = null;

            char oldDelimiter = CsvFileManager.Delimiter;

            switch (referencedFileSave.CsvDelimiter)
            {
                case AvailableDelimiters.Comma:
                    CsvFileManager.Delimiter = ',';
                    break;
                case AvailableDelimiters.Tab:
                    CsvFileManager.Delimiter = '\t';
                    break;
                case AvailableDelimiters.Pipe:
                    CsvFileManager.Delimiter = '|';
                    break;
            }

            string absoluteFileName = ProjectManager.MakeAbsolute(referencedFileSave.Name);

            // If the file doesn't exist this will generate bad code.  But this isn't
            // considered a silent failure because Glue will raise flags about missing
            // files earlier (like when it first starts up).  We don't want to crash the
            // entire application in this case.
            if (System.IO.File.Exists(absoluteFileName))
            {
                RuntimeCsvRepresentation rcr = CsvFileManager.CsvDeserializeToRuntime(absoluteFileName);

                // See if any of the headers are required
                foreach (CsvHeader header in rcr.Headers)
                {
                    int indexOfOpeningParen = header.Name.IndexOf("(");

                    if (indexOfOpeningParen != -1)
                    {
                        if (header.Name.IndexOf("required", indexOfOpeningParen) != -1)
                        {
                            keyType = CsvHeader.GetClassNameFromHeader(header.Name);
                            break;
                        }
                    }
                }
            }

            CsvFileManager.Delimiter = oldDelimiter;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:50,代码来源:CsvCodeGenerator.cs

示例10: SetFrom

        public void SetFrom(ReferencedFileSave rfs)
        {
            backingData = rfs;

            foreach(var project in GlueState.Self.GetProjects())
            {
                var projectName = project.Name;

                var settings = new IndividualProjectSetting();
                settings.ProjectName = projectName;
                settings.IsEnabled = backingData.ProjectsToExcludeFrom.Contains(projectName) == false;
                settings.PropertyChanged += HandlePropertyChanged;

                ProjectSettings.Add(settings);
            }
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:16,代码来源:FileExclusionViewModel.cs

示例11: ExcludeFileFromProject

        private static void ExcludeFileFromProject(string projectName, ReferencedFileSave rfs)
        {
            rfs.ProjectsToExcludeFrom.Add(projectName);

            var syncedProject = GlueState.Self.GetProjects().FirstOrDefault(item => item.Name == projectName);

            if(syncedProject != null)
            {
                string absolute = GlueCommands.Self.GetAbsoluteFileName(rfs);
                syncedProject.RemoveItem(absolute);
                if (syncedProject.ContentProject != null)
                {
                    syncedProject.ContentProject.RemoveItem(absolute);
                }
            }
        }
开发者ID:gitter-badger,项目名称:FlatRedBall,代码行数:16,代码来源:FileExclusionViewModel.cs

示例12: PopulateWithReferencesTo

        public void PopulateWithReferencesTo(ReferencedFileSave rfs)
        {
            List<IElement> elements = ObjectFinder.Self.GetAllElementsReferencingFile(rfs.Name);

            foreach (IElement element in elements)
            {
                var rfsInThisElement = element.GetReferencedFileSave(rfs.Name);
                listBox1.Items.Add(rfsInThisElement);

                foreach(var namedObject in element.AllNamedObjects)
                {
                    if(namedObject.SourceType == SourceType.File &&
                        namedObject.SourceFile == rfsInThisElement.Name)
                    {
                        listBox1.Items.Add(namedObject);
                    }
                }
            }

            // If this is a CSV, then loop through all of the variables and see if any of them use this type
            if (rfs.IsCsvOrTreatedAsCsv)
            {
                string className = rfs.Name;
                CustomClassSave customClass = ObjectFinder.Self.GlueProject.GetCustomClassReferencingFile(rfs.Name);
                if (customClass != null)
                {
                    className = customClass.Name;
                }

                foreach (IElement element in ObjectFinder.Self.GlueProject.Screens)
                {
                    foreach (CustomVariable customVariable in element.CustomVariables.Where(customVariable => customVariable.Type == className))
                    {
                        listBox1.Items.Add(customVariable);
                    }
                }
                foreach (IElement element in ObjectFinder.Self.GlueProject.Entities)
                {
                    foreach (CustomVariable customVariable in element.CustomVariables.Where(customVariable => customVariable.Type == className))
                    {
                        listBox1.Items.Add(customVariable);
                    }
                }
            }

        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:46,代码来源:ElementReferenceListWindow.cs

示例13: CopyToBuildFolder

        public void CopyToBuildFolder(ReferencedFileSave rfs)
        {
            string projectName = FileManager.RemovePath(FileManager.RemoveExtension(GlueState.Self.CurrentGlueProjectFileName));
            string buildFolder = FileManager.GetDirectory(GlueState.Self.CurrentGlueProjectFileName) + "bin/x86/debug/Content/";

            string destination = buildFolder + rfs.Name;
            string source = ProjectManager.ContentDirectory + rfs.Name;

            try
            {
                System.IO.File.Copy(source, destination, true);

                PluginManager.ReceiveOutput("Copied " + source + " ==> " + destination);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Error copying file:\n\n" + e.ToString());

            }
        }
开发者ID:GorillaOne,项目名称:FlatRedBall,代码行数:20,代码来源:ProjectCommands.cs

示例14: Initialize

        public void Initialize()
        {

            // Couldn't run tests here because it requires FRB to be initialized.  
            OverallInitializer.Initialize();

            mBaseEntity = new EntitySave();
            mBaseEntity.Name = "ReferencedFileSaveTestsBaseEntity";

            ReferencedFileSave rfs = new ReferencedFileSave();


            ObjectFinder.Self.GlueProject.Entities.Add(mBaseEntity);

            mDerivedEntity = new EntitySave();
            mDerivedEntity.Name = "ReferencedFileSaveTestsDerivedEntity";
            mDerivedEntity.BaseEntity = mBaseEntity.Name;
            ObjectFinder.Self.GlueProject.Entities.Add(mDerivedEntity);

        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:20,代码来源:ReferencedFileSaveTests.cs

示例15: ContainsRecursively

        public static bool ContainsRecursively(this IElement element, ReferencedFileSave whatToLookFor)
        {
            foreach (ReferencedFileSave rfs in element.ReferencedFiles)
            {
                if (rfs == whatToLookFor)
                {
                    return true;
                }
            }

            if (!string.IsNullOrEmpty(element.BaseElement))
            {
                IElement baseElement = ObjectFinder.Self.GetIElement(element.BaseElement);
                if (baseElement != null)
                {
                    return baseElement.ContainsRecursively(whatToLookFor);
                }
            }
            return false;
        }
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:20,代码来源:IElementHelper.cs


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