コード例 #1
0
        private void ResetPropertiesRecursive(EditorContentDirectory rootDirectory)
        {
            try
            {
                foreach (var element in rootDirectory.Content)
                {
                    var contentFile = element as EditorContentFile;
                    var contentDirectory = element as EditorContentDirectory;

                    if (contentFile != null)
                    {
                        contentFile.RemoveContentInfo();
                    }
                    else if (contentDirectory != null)
                    {
                        ResetPropertiesRecursive(contentDirectory);
                    }
                }
            }
            catch { }
        }
コード例 #2
0
        /// <summary>
        /// Enumerate the content of the directory excluding elements matching the specified regexes
        /// </summary>
        /// <param name="ignoreRegexes"></param>
        /// <returns></returns>
        private IEnumerable<EditorBaseBoundObject> EnumerateDirectoryContent(Regex[] ignoreRegexes)
        {
            DirectoryInfo directory;

            try
            {
                directory = new DirectoryInfo(CurrentPath);
            }
            catch (Exception ex)
            {
                directory = null;
                ErrorString = ex.ToString();

                IsValid = false;
            }

            if (directory != null)
            {
                DirectoryInfo[] dirs = null;
                try
                {
                    dirs = directory.GetDirectories();
                }
                catch { IsValid = false; }

                if (dirs != null)
                {
                    foreach (var sub_dir in dirs)
                    {
                        string relativeDirPath = Path.Combine(RelativePath, sub_dir.Name);

                        bool ignoreDirectory = false;

                        if (ignoreRegexes != null)
                        {
                            /* test to see if the directory should be ignored */
                            foreach (var regex in ignoreRegexes)
                            {
                                if (regex.IsMatch(relativeDirPath))
                                {
                                    ignoreDirectory = true;
                                    break;
                                }
                            }
                        }

                        if (!ignoreDirectory)
                        {
                            EditorContentDirectory contentDir = null;

                            try
                            {
                                contentDir = new EditorContentDirectory(Editor, relativeDirPath, BasePath, sub_dir.FullName);
                            }
                            catch { }

                            if (contentDir != null)
                                yield return contentDir;
                        }
                    }
                }

                FileInfo[] files = null;
                try
                {
                    files = directory.GetFiles();
                }
                catch { IsValid = false; }

                if (files != null)
                {
                    foreach (var sub_file in files)
                    {
                        if (!CirrusDesignHelper.CirrusPackageExtention.Equals(sub_file.Extension, StringComparison.OrdinalIgnoreCase))
                        {
                            string relativeFilePath = Path.Combine(RelativePath, sub_file.Name);

                            bool ignoreFile = false;

                            if (ignoreRegexes != null)
                            {
                                /* test to see if the directory should be ignored */
                                foreach (var regex in ignoreRegexes)
                                {
                                    if (regex.IsMatch(relativeFilePath))
                                    {
                                        ignoreFile = true;
                                        break;
                                    }
                                }
                            }

                            if (!ignoreFile)
                            {
                                EditorContentFile contentFile = null;

                                try
                                {
                                    contentFile = new EditorContentFile(Editor, relativeFilePath, BasePath, sub_file.FullName);
                                }
                                catch { }

                                if (contentFile != null)
                                    yield return contentFile;
                            }
                        }
                    }
                }
            }
        }