Inheritance: ObjectNode
        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);
        }
        public override void ImportText(string propertySheetText, string originalFilename) {
            if(Root._imports.Any(each => each.FullPath.Equals(originalFilename, StringComparison.CurrentCulture))) {
                return;
            }

            var importedSheet = new PropertySheet(Root);
            importedSheet.ParseText(propertySheetText, originalFilename);
            Root._imports.Add(importedSheet);
            Root.AddChildRoutes(importedSheet.Routes);
            Root._view.InitializeAtRootLevel(importedSheet);
        }
Exemplo n.º 3
0
        private void AddRoutesForImport(PropertySheet importedSheet)
        {
            Root._view.AddChildRoute(importedSheet.Routes);

            foreach(var i in importedSheet.Imports) {
                AddRoutesForImport(i);
            }
        }
Exemplo n.º 4
0
 private PropertySheet(PropertySheet root)
     : base(root)
 {
     // used by imported sheets to bind themselves to the right root object.
 }
Exemplo n.º 5
0
        public void ImportText(string propertySheetText, string originalFilename)
        {
            if(Root._imports.Any(each => each._fullPath.Equals(originalFilename, StringComparison.CurrentCulture))) {
                return;
            }

            var propertySheet = new PropertySheet(this);
            propertySheet.ParseText(propertySheetText, originalFilename);
            Root._imports.Add(propertySheet);
        }