ParseFile() публичный Метод

public ParseFile ( string filename ) : void
filename string
Результат void
Пример #1
0
        public override void ImportFile(string filename)
        {
            if (!Path.IsPathRooted(filename))
            {
                // only try to search for the file if we're not passed an absolute location.
                var currentDir = Path.GetDirectoryName(FullPath);
                if (filename.IndexOfAny(new[] { '/', '\\' }) > -1)
                {
                    // does have a slash, is meant to be a relative path from the parent sheet.

                    var fullPath = Path.Combine(currentDir, filename);
                    if (!File.Exists(fullPath))
                    {
                        throw new FileNotFoundException("Unable to locate imported property sheet '{0}'".format(filename), fullPath);
                    }
                    filename = fullPath;
                }
                else
                {
                    // just a filename. Scan up the tree and into known locations for it.
                    var paths = filename.GetAllCustomFilePaths(currentDir);

                    var chkPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), filename);
                    if (File.Exists(chkPath))
                    {
                        paths = paths.ConcatSingleItem(chkPath);
                    }

                    chkPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "etc", filename);
                    if (File.Exists(chkPath))
                    {
                        paths = paths.ConcatSingleItem(chkPath);
                    }
                    foreach (var i in paths)
                    {
                        ImportFile(i);
                    }
                    return;
                }
            }

            if (Root._imports.Any(each => each.FullPath.Equals(filename, StringComparison.CurrentCulture)))
            {
                return;
            }

            // filename is now the absolute path.
            var importedSheet = new PropertySheet(this);

            importedSheet.ParseFile(filename);
            _imports.Add(importedSheet);
            AddChildRoutes(importedSheet.Routes);
            _view.InitializeAtRootLevel(importedSheet);
        }
        public override void ImportFile(string filename) {
            if (!Path.IsPathRooted(filename)) {
                // only try to search for the file if we're not passed an absolute location.
                var currentDir = Path.GetDirectoryName(FullPath);
                if (filename.IndexOfAny(new[] { '/', '\\' }) > -1) {
                    // does have a slash, is meant to be a relative path from the parent sheet.
                    
                    var fullPath = Path.Combine(currentDir, filename);
                    if (!File.Exists(fullPath)) {
                        throw new FileNotFoundException("Unable to locate imported property sheet '{0}'".format(filename), fullPath);
                    }
                    filename = fullPath;
                } else {
                    // just a filename. Scan up the tree and into known locations for it.
                    var paths = filename.GetAllCustomFilePaths(currentDir);

                    var chkPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),filename);
                    if(File.Exists(chkPath)) {
                        paths = paths.ConcatSingleItem(chkPath);
                    }

                    chkPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "etc" ,filename);
                    if (File.Exists(chkPath)) {
                        paths = paths.ConcatSingleItem(chkPath);
                    }
                    foreach (var i in paths) {
                        ImportFile(i);
                    }
                    return;
                }
            }

            if (Root._imports.Any(each => each.FullPath.Equals(filename, StringComparison.CurrentCulture))) {
                return;
            }

            // filename is now the absolute path.
            var importedSheet = new PropertySheet(Root);
            importedSheet.ParseFile(filename);
            Root._imports.Add(importedSheet);
            Root.AddChildRoutes(importedSheet.Routes);
            Root._view.InitializeAtRootLevel(importedSheet);
        }