Exemple #1
0
        protected string GetVirtualPathAttribute(IDictionary <string, string> attribs, string name, bool checkFileExists)
        {
            string str = GetNonEmptyAttribute(attribs, name);

            if (str != null)
            {
                VirtualPathProvider vpp = this.VirtualPathProvider;

                string combined;

                try {
                    combined = vpp.CombineVirtualPaths(this.VirtualPath, str);
                } catch (Exception ex) {
                    throw CreateParseException(ex.Message);
                }

                if (checkFileExists &&
                    !vpp.FileExists(combined))
                {
                    throw CreateParseException("The file '{0}' does not exist.", str);
                }

                return(combined);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        internal void RegisterCustomControl(string tagPrefix, string tagName, string src)
        {
            string              realpath   = null;
            bool                fileExists = false;
            VirtualFile         vf         = null;
            VirtualPathProvider vpp        = HostingEnvironment.VirtualPathProvider;
            VirtualPath         vp         = new VirtualPath(src, BaseVirtualDir);
            string              vpAbsolute = vpp.CombineVirtualPaths(VirtualPath.Absolute, vp.Absolute);

            if (vpp.FileExists(vpAbsolute))
            {
                fileExists = true;
                vf         = vpp.GetFile(vpAbsolute);
                if (vf != null)
                {
                    realpath = MapPath(vf.VirtualPath);
                }
            }

            if (!fileExists)
            {
                ThrowParseFileNotFound(src);
            }

            if (String.Compare(realpath, inputFile, StringComparison.Ordinal) == 0)
            {
                return;
            }

            string vpath = vf.VirtualPath;

            try {
                RegisterTagName(tagPrefix + ":" + tagName);
                RootBuilder.Foundry.RegisterFoundry(tagPrefix, tagName, vpath);
                AddDependency(vpath);
            } catch (ParseException pe) {
                if (this is UserControlParser)
                {
                    throw new ParseException(Location, pe.Message, pe);
                }
                throw;
            }
        }
Exemple #3
0
        internal static void ApplyMasterPageRecursive(string currentFilePath, VirtualPathProvider vpp, MasterPage master, Dictionary <string, bool> appliedMasterPageFiles)
        {
            /* XXX need to use virtual paths here? */
            string mpFile = master.MasterPageFile;

            if (!String.IsNullOrEmpty(mpFile))
            {
                mpFile = vpp.CombineVirtualPaths(currentFilePath, mpFile);
                if (appliedMasterPageFiles.ContainsKey(mpFile))
                {
                    throw new HttpException("circular dependency in master page files detected");
                }

                MasterPage innerMaster = master.Master;
                if (innerMaster != null)
                {
                    master.Controls.Clear();
                    master.Controls.Add(innerMaster);
                    appliedMasterPageFiles.Add(mpFile, true);
                    MasterPage.ApplyMasterPageRecursive(currentFilePath, vpp, innerMaster, appliedMasterPageFiles);
                }
            }
        }
        public string Combine(string basePath, string path)
        {
            var ix = basePath.LastIndexOf('/');

            return(virtualPathProvider.CombineVirtualPaths(ix > 0 ? basePath.Substring(0, ix + 1) : basePath, path));
        }
Exemple #5
0
 public override string CombineVirtualPaths(string basePath, string relativePath)
 {
     return(parent.CombineVirtualPaths(basePath, relativePath));
 }
Exemple #6
0
 private static string CreateVideoPathFromFileName(VirtualPathProvider provider, string filename)
 {
     return provider.CombineVirtualPaths(provider.RootDirectory.VirtualPath, filename);
 }