public void SerializerConfigTest()
        {
            ElasticSearchClusterConfig config     = ElasticSearchClusterConfig.Create();
            List <ESCluster>           esClusters = new List <ESCluster>();
            ESCluster defaultCluster = new ESCluster();

            defaultCluster.Name      = "Dev1";
            defaultCluster.Default   = true;
            defaultCluster.HttpNodes = new List <ESNode>()
            {
                new ESNode()
                {
                    Enabled = true, Host = "localhost", Port = 9200
                }
            };
            defaultCluster.ThriftNodes = new List <ESNode>()
            {
                new ESNode()
                {
                    Enabled = true, Host = "127.0.0.1", Port = 9500
                },
                new ESNode()
                {
                    Enabled = true, Host = "127.0.0.1", Port = 9500
                }
            };
            esClusters.Add(defaultCluster);

            ESCluster devCluster = new ESCluster();

            devCluster.Name      = "Dev2";
            devCluster.Default   = false;
            devCluster.HttpNodes = new List <ESNode>()
            {
                new ESNode()
                {
                    Enabled = true, Host = "localhost", Port = 9200
                }
            };
            devCluster.ThriftNodes = new List <ESNode>()
            {
                new ESNode()
                {
                    Enabled = true, Host = "127.0.0.1", Port = 9500
                },
            };
            esClusters.Add(devCluster);
            config.Clusters = esClusters;

            Console.Write(XMLUtility.Serialize(config));
        }
Ejemplo n.º 2
0
        protected override void Render(HtmlTextWriter writer)
        {
            Response.AddHeader("Pragma", "no-cache");
            Response.AddHeader("Cache-Control", "no-cache");

            if (result is AjaxResult)
            {
                base.Render(writer);
            }
            else if (result is StringResult)
            {
                Response.Write(((StringResult)result).Result);
            }
            else if (result is JsonResult)
            {
                Response.ContentType = "application/json";
                Response.Write(jsSerializer.Serialize(((JsonResult)result).Result));
            }
            else if (result is XmlResult)
            {
                Response.ContentType = "text/xml";
                Response.Write(XMLUtility.Serialize(((XmlResult)result).Result));
            }
        }