Exemplo n.º 1
0
        /// <summary>
        /// Fills the name value.
        /// </summary>
        /// <param name="nodes">The nodes.</param>
        /// <returns></returns>
        static Dictionary <string, object> FillNameValue(XPathNodeIterator nodes)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            foreach (XPathNavigator node in nodes)
            {
                object data;
                if (!string.IsNullOrEmpty(node.GetAttribute("value", string.Empty)))
                {
                    data = Convert.ChangeType(node.GetAttribute("value", string.Empty), Type.GetType(node.GetAttribute("type", string.Empty)), CultureInfo.InvariantCulture);
                }
                else if (!string.IsNullOrEmpty(node.Value))
                {
                    try
                    {
                        data = BugSerializer.Deserialize(node.Value);
                    }
                    catch (SerializationException)
                    {
                        continue;
                    }
                }
                else
                {
                    continue;
                }
                result[node.GetAttribute("name", string.Empty)] = data;
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReBugContext"/> class.
        /// </summary>
        /// <param name="bug">The bug.</param>
        protected ReBugContext(IXPathNavigable bug)
        {
            XPathNavigator xml = bug.CreateNavigator();

            _QueryString = HttpValueCollection.CreateCollectionFromXmlNode(xml.SelectSingleNode("/bugx/queryString"));

            _Form = HttpValueCollection.CreateCollectionFromXmlNode(xml.SelectSingleNode("/bugx/form"));

            XPathNavigator cookie = xml.SelectSingleNode("/bugx/headers/Cookie");

            if (cookie != null)
            {
                _Cookies = HttpValueCollection.CreateCollectionFromCookieHeader(cookie.Value);
            }
            _Headers = HttpValueCollection.CreateCollectionFromXmlNode(xml.SelectSingleNode("/bugx/headers"));

            _Session     = FillNameValue(xml.Select("/bugx/sessionVariables/add"));
            _Cache       = FillNameValue(xml.Select("/bugx/cacheVariables/add"));
            _Application = FillNameValue(xml.Select("/bugx/applicationVariables/add"));
            _Context     = FillHashtable(xml.Select("/bugx/contextVariables/add"));

            XPathNavigator exception = xml.SelectSingleNode("/bugx/exception");

            if (exception != null)
            {
                try
                {
                    _Exception = (Exception)BugSerializer.Deserialize(exception.Value);
                }catch (SerializationException) {}
            }
            XPathNavigator url = xml.SelectSingleNode("/bugx/url");

            if (url != null)
            {
                _Url = new Uri(url.Value);
            }
            XPathNavigator pathInfo = xml.SelectSingleNode("/bugx/pathInfo");

            if (pathInfo != null)
            {
                _PathInfo = pathInfo.Value;
            }
            XPathNavigator machineName = xml.SelectSingleNode("/bugx/machineName");

            if (machineName != null)
            {
                _MachineName = machineName.Value;
            }
            XPathNavigator scriptTimeout = xml.SelectSingleNode("/bugx/scriptTimeout");

            if (scriptTimeout != null)
            {
                _ScriptTimeout = Convert.ToInt32(scriptTimeout.Value, CultureInfo.InvariantCulture);
            }
            XPathNavigator user = xml.SelectSingleNode("/bugx/user");

            if (user != null)
            {
                try
                {
                    _User = (IPrincipal)BugSerializer.Deserialize(user.Value);
                }
                catch (SerializationException) {}
                catch (TargetInvocationException) {}
            }
        }