Inheritance: System.EventArgs
Beispiel #1
0
        public Stream Load(string url)
        {
            if (url == null)
                throw new ArgumentNullException("url");

            // Take out the path part.

            var e = new HelpResolveEventArgs(url);
            OnResolve(e);
            if (e.Stream != null)
                return e.Stream;

            // Extract the root.

            string root = null;
            string path = url.TrimStart('/');
            int index = path.IndexOf('/');

            if (index != -1)
            {
                root = path.Substring(0, index);
                path = path.Substring(index + 1);
            }

            // Find the registration for this root.

            foreach (var registration in Registrations)
            {
                if (String.Equals(registration.Root, root, StringComparison.OrdinalIgnoreCase))
                    return Load(registration, path);
            }

            return null;
        }
Beispiel #2
0
        protected virtual void OnResolve(HelpResolveEventArgs e)
        {
            var ev = Resolve;

            if (ev != null)
            {
                ev(this, e);
            }
        }
Beispiel #3
0
        public Stream Load(string url)
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }

            // Take out the path part.

            var e = new HelpResolveEventArgs(url);

            OnResolve(e);
            if (e.Stream != null)
            {
                return(e.Stream);
            }

            // Extract the root.

            string root  = null;
            string path  = url.TrimStart('/');
            int    index = path.IndexOf('/');

            if (index != -1)
            {
                root = path.Substring(0, index);
                path = path.Substring(index + 1);
            }

            // Find the registration for this root.

            foreach (var registration in Registrations)
            {
                if (String.Equals(registration.Root, root, StringComparison.OrdinalIgnoreCase))
                {
                    return(Load(registration, path));
                }
            }

            return(null);
        }
Beispiel #4
0
 protected virtual void OnResolve(HelpResolveEventArgs e)
 {
     var ev = Resolve;
     if (ev != null)
         ev(this, e);
 }
Beispiel #5
0
        void Manager_Resolve(object sender, HelpResolveEventArgs e)
        {
            string path = e.Url;
            int index = path.IndexOf('?');
            if (index != -1)
                path = path.Substring(0, index);

            byte[] bytes;
            if (Resources.TryGetValue(path, out bytes))
                e.Stream = new MemoryStream(bytes);
            else if (path == "/find")
                e.Stream = PerformFind(e.Url);
            else if (path == "/")
                e.Stream = PerformRoot();
        }