Unlimited.Framework.Converters.Graph.String.StringInterrogator.CreateNavigator C# (CSharp) Method

CreateNavigator() public method

public CreateNavigator ( object data, Type pathType ) : INavigator
data object
pathType System.Type
return INavigator
        public INavigator CreateNavigator(object data, Type pathType)
        {
            if (!pathType.GetInterfaces().Contains(typeof (IPath)))
            {
                throw new Exception("'" + pathType + "' doesn't implement '" + typeof (IPath) + "'");
            }

            INavigator navigator;

            if (pathType == typeof (XmlPath))
            {
                navigator = new XmlNavigator(data);
            }
            else if (pathType == typeof (JsonPath))
            {
                navigator = new JsonNavigator(data);
            }
            else if (pathType == typeof (PocoPath))
            {
                navigator = new PocoNavigator(data);
            }
            else if( pathType == typeof(StringPath))
            {
                navigator = new StringNavigator(data);
            }
            else
            {
                navigator = null;
            }

            return navigator;
        }

Usage Example

Exemplo n.º 1
0
        public void CreateNavigator_Expected_XmlNavigator() {            
            StringInterrogator stringInterrogator = new StringInterrogator();

            INavigator navigator = stringInterrogator.CreateNavigator(XmlGiven(), typeof(XmlPath));

            Type expected = typeof(XmlNavigator);
            Type actual = navigator.GetType();

            Assert.AreEqual(expected, actual);
        }