ClrPlus.Scripting.Languages.PropertySheetV3.PropertySheet.ParseFile C# (CSharp) Метод

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

public ParseFile ( string filename ) : void
filename string
Результат void
        public virtual void ParseFile(string filename)
        {
            FullPath = filename.GetFullPath();

            if(!File.Exists(FullPath)) {
                throw new FileNotFoundException("Can't find property sheet file '{0}'".format(filename), FullPath);
            }

            ParseText(File.ReadAllText(FullPath), FullPath);
        }

Usage Example

Пример #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);
        }
All Usage Examples Of ClrPlus.Scripting.Languages.PropertySheetV3.PropertySheet::ParseFile