Beispiel #1
0
        public void Init()
        {
            var alias             = "NamedTypeHandlerCacheTest";
            var namedTypeHandlers = new Dictionary <string, ITypeHandler>
            {
                { "Json", new JsonTypeHandler() },
                { "Xml", new XmlTypeHandler() }
            };

            NamedTypeHandlerCache.Build(alias, namedTypeHandlers);
            var jsonHandlerField = NamedTypeHandlerCache.GetTypeHandlerField(alias, "Json");
            var jsonTypeHandler  = jsonHandlerField.GetValue(null);
        }
Beispiel #2
0
 public SmartSqlBuilder Build()
 {
     if (Built)
     {
         return(this);
     }
     Built = true;
     BeforeBuildInitService();
     DbSessionFactory = SmartSqlConfig.DbSessionFactory;
     SqlMapper        = new SqlMapper(SmartSqlConfig);
     SmartSqlContainer.Instance.Register(this);
     NamedTypeHandlerCache.Build(Alias, SmartSqlConfig.TypeHandlerFactory.GetNamedTypeHandlers());
     SetupSmartSql();
     return(this);
 }
        public void Build()
        {
            var alias = "NamedTypeHandlerCacheTest";

            JsonTypeHandler expectedJson      = new JsonTypeHandler();
            XmlTypeHandler  expectedXml       = new XmlTypeHandler();
            var             namedTypeHandlers = new Dictionary <string, ITypeHandler>
            {
                { "Json", expectedJson },
                { "Xml", expectedXml }
            };

            NamedTypeHandlerCache.Build(alias, namedTypeHandlers);
            var actualJson = NamedTypeHandlerCache.GetTypeHandlerField(alias, "Json").GetValue(null);

            Assert.Equal(expectedJson, actualJson);

            var actualXml = NamedTypeHandlerCache.GetTypeHandlerField(alias, "Xml").GetValue(null);

            Assert.Equal(expectedXml, actualXml);
        }