public RowFrameTableGenerator(RowFrame rowFrame,
                               int maxColumns              = 10,
                               int maxRows                 = 10,
                               IStringifier stringifier    = null,
                               string customTableClassName = null,
                               string customCss            = null)
     : base(maxColumns, maxRows, stringifier, customTableClassName, customCss)
 {
     _rowFrame = rowFrame;
 }
 public DataTableTableGenerator(
     DataTable table,
     int maxColumns              = 10,
     int maxRows                 = 10,
     IStringifier stringifier    = null,
     string customTableClassName = null,
     string customCss            = null)
     : base(maxColumns, maxRows, stringifier, customTableClassName, customCss)
 {
     _table = table;
 }
Beispiel #3
0
        /// <summary>
        /// Instantiate a new low level elasticsearch client
        /// </summary>
        /// <param name="settings">Specify how and where the client connects to elasticsearch, defaults to a static single node connectionpool
        /// to http://localhost:9200
        /// </param>
        /// <param name="connection">Provide an alternative connection handler</param>
        /// <param name="transport">Provide a custom transport implementation that coordinates between IConnectionPool, IConnection and ISerializer</param>
        /// <param name="serializer">Provide a custom serializer</param>
        /// <param name="stringifier">This interface is responsible for translating non string objects in the querystring to strings</param>
        public ElasticsearchClient(
            IConnectionConfigurationValues settings = null,
            IConnection connection = null,
            ITransport transport   = null,
            IElasticsearchSerializer serializer = null,
            IStringifier stringifier            = null
            )
        {
            settings         = settings ?? new ConnectionConfiguration();
            this.Transport   = transport ?? new Transport(settings, connection, serializer);
            this.Stringifier = stringifier ?? new Stringifier();

            //neccessary to pass the serializer to ElasticsearchResponse
            this.Settings.Serializer = this.Transport.Serializer;
        }
 public EnumerableTableGenerator(
     IEnumerable <TItem> items,
     bool includeProperties      = true,
     bool includeFields          = false,
     int maxColumns              = 10,
     int maxRows                 = 10,
     IStringifier stringifier    = null,
     string customTableClassName = null,
     string customCss            = null)
     : base(maxColumns, maxRows, stringifier, customTableClassName, customCss)
 {
     _items             = items;
     _includeProperties = includeProperties;
     _includeFields     = includeFields;
 }
 public DictionaryTableGenerator(
     IDictionary <TKey, TValue> items,
     bool includeProperties      = true,
     bool includeFields          = false,
     int maxColumns              = 10,
     int maxRows                 = 10,
     IStringifier stringifier    = null,
     string customTableClassName = null,
     string customCss            = null)
     : base(maxColumns, maxRows, stringifier, customTableClassName, customCss)
 {
     _items             = items;
     _includeProperties = includeProperties;
     _includeFields     = includeFields;
 }
Beispiel #6
0
        private static void WriteStringifiedObject(object o, TextWriter w)
        {
            IStringifier stringifier = null;
            var          t           = o.GetType();

            while (stringifier == null && t != null)
            {
                stringifier = StringifierLibrary.Instance.All.SingleOrDefault(x => x.SupportedType == t);
                t           = t.BaseType;
            }
            if (stringifier == null)
            {
                throw new Exception("Can't find stringifier to deserialize " + o.GetType());
            }
            w.WriteLine("s:" + stringifier.Stringify(o) + ";");
        }
        protected BaseTableGenerator(
            int maxColumns              = 10,
            int maxRows                 = 10,
            IStringifier stringifier    = null,
            string customTableClassName = null,
            string customCss            = null)
        {
            _maxColumns           = maxColumns;
            _maxRows              = maxRows;
            _stringifier          = stringifier ?? new Stringifier();
            _customTableClassName = customTableClassName ?? "slodgeTable";
            _customCss            = customCss ?? @".slodgeTable { border-collapse: collapse; } 
.slodgeTable th { border: 0px; padding-left: 4px; padding-right: 4px; text-align:left; }
.slodgeTable td { border: 0px; padding-left: 4px; padding-right: 4px; text-align:left; }
";
        }
        public static Representations.VerbatimHtml AsTable(
            this ColumnFrame table,
            int maxColumns              = 10,
            int maxRows                 = 10,
            IStringifier stringifier    = null,
            string customTableClassName = null,
            string customCss            = null)
        {
            var generator = new ColumnFrameTableGenerator(
                table,
                maxColumns,
                maxRows,
                stringifier,
                customTableClassName,
                customCss);

            return(generator.GenerateHtml());
        }
        public static Representations.VerbatimHtml AsTable(
            this System.Data.DataTable table,
            int maxColumns              = 10,
            int maxRows                 = 10,
            bool includeProperties      = true,
            bool includeFields          = false,
            IStringifier stringifier    = null,
            string customTableClassName = null,
            string customCss            = null)
        {
            var generator = new DataTableTableGenerator(
                table,
                maxColumns,
                maxRows,
                stringifier,
                customTableClassName,
                customCss);

            return(generator.GenerateHtml());
        }
        public static VerbatimHtml AsTable <T>(
            this IEnumerable <T> items,
            int maxColumns              = 10,
            int maxRows                 = 10,
            bool includeProperties      = true,
            bool includeFields          = false,
            IStringifier stringifier    = null,
            string customTableClassName = null,
            string customCss            = null)
        {
            var generator = new EnumerableTableGenerator <T>(
                items,
                includeProperties,
                includeFields,
                maxColumns,
                maxRows,
                stringifier,
                customTableClassName,
                customCss);

            return(generator.GenerateHtml());
        }
Beispiel #11
0
 // IServiceLocator should be injected into the constructor as
 // a dependency
 public DisplayFormatter(IServiceLocator locator, IStringifier stringifier)
 {
     _locator = locator;
     _stringifier = stringifier;
 }
 // IServiceLocator should be injected into the constructor as
 // a dependency
 public DisplayFormatter(IServiceLocator locator, IStringifier stringifier)
 {
     _locator     = locator;
     _stringifier = stringifier;
 }
Beispiel #13
0
        private static object DeserializeStringifiedObject(TextReader r, Type type, ObjectGraphContext context, StringBuilder log)
        {
            object o;
            // read tag to see if it's actually a stringified object
            var fin = r.Read();

            while (fin != 0 && char.IsWhiteSpace((char)fin))
            {
                if (log != null)
                {
                    log.Append((char)fin);
                }
                fin = r.Read();
            }
            if (fin != 0 && log != null)
            {
                log.Append((char)fin);
            }
            if (fin == 's')
            {
                IStringifier stringifier = null;
                var          t           = type;
                while (stringifier == null && t != null)
                {
                    stringifier = StringifierLibrary.Instance.All.SingleOrDefault(x => x.SupportedType == t);
                    t           = t.BaseType;
                }
                if (stringifier == null)
                {
                    throw new Exception("Can't find stringifier to deserialize " + type);
                }
                var dummy = r.ReadTo(':', log);
                var val   = r.ReadToEndOfLine(';', log);
                o = stringifier.Destringify(val);
            }
            else if (fin == 'p')
            {
                o = DeserializeObjectWithProperties(r, type, context, log);
            }
            else if (fin == 'i')
            {
                o = DeserializeObjectWithID(r, type, context, log);
            }
            else if (fin == 'n')
            {
                // null object!
                o = null;

                // clean up
                ReadSemicolon(r, type, log);
            }
            else if (fin == 'd')
            {
                o = DeserializeDictionary(r, type, context, log);
            }
            else if (fin == 'c')
            {
                o = DeserializeList(r, type, context, log);
            }
            else
            {
                throw new Exception("Unknown data tag " + fin + ", was expecting s/p/i/n/d/c.");
            }
            if (!context.KnownObjects.ContainsKey(type) || !context.KnownObjects[type].Contains(o))
            {
                context.Add(o);
            }
            return(o);
        }
Beispiel #14
0
 public void Configure(IStringifier stringifier)
 {
     _strategies.Each(s => stringifier.AddStrategy(s));
 }
Beispiel #15
0
 public void SetUp()
 {
     stringifier = new Stringifier();
     locator = new InMemoryServiceLocator();
 }