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

CreateMapper() public method

public CreateMapper ( object data ) : IMapper
data object
return IMapper
        public IMapper CreateMapper(object data)
        {
            IMapper mapper;

            if (IsXml(data.ToString()))
            {
                mapper = new XmlMapper();
            }
            else if (IsJson(data.ToString()))
            {
                mapper = new JsonMapper();
            }
            else
            {
                if(data.GetType().IsPrimitive)
                {
                    mapper = new PocoMapper();
                }
                else
                {
                    mapper = new StringMapper();
                }
            }
            return mapper;
        }

Usage Example

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

            IMapper mapper = stringInterrogator.CreateMapper(XmlGiven());

            Type expected = typeof(XmlMapper);
            Type actual = mapper.GetType();

            Assert.AreEqual(expected, actual);
        }