public string[] Top20(string input) { if (input == null) { return(Mappings.Select(x => x.Item1).ToArray()); } Type reqType = Type.GetType(Mappings.First(x => x.Item1 == input).Item3); Type boxType = Type.GetType(Mappings.First(x => x.Item1 == input).Item2); Type boxedType = typeof(BoxQuery <>).MakeGenericType(boxType); var boxQuery = Context.Resolve(boxedType); MethodInfo takeMethod = typeof(Queryable).GetMethod("Take").MakeGenericMethod(boxType); var result = ((IEnumerable <object>)takeMethod.Invoke (null, new object[] { boxQuery, 20 })).ToList(); var presenter = new DumperBoxPresentation(); var box = BoxExtensions.CreateFor(boxType); result.ToList().ForEach(x => box.Add(x)); Writer.WriteLine(presenter.AsString(box)); return(null); }
public virtual void SetValue(object val) { objectCache = null; StringValue = null; NumericValue = null; Contract = null; if (val is string) { StringValue = val.ToString(); return; } if (val is ValueType) { var valType = val as ValueType; if (IsNumericType(valType) || val is Enum) { NumericValue = Convert.ToDecimal(val); return; } if (val is bool) { NumericValue = ((bool)val) == true ? 1 : 0; return; } //structs if (val is DateTime) { NumericValue = ((DateTime)val).Ticks; return; } //fall to contract } //contract if (val != null) { var box = BoxExtensions.CreateFor(val.GetType()); box.Add(val); IBoxPresentation serializer = new BinaryBoxPresentation(); Contract = serializer.AsBytes(box); ContractType = val.GetType().AssemblyQualifiedName; } else { ContractType = null; Contract = null; } }
public void HQL(string query) { var action = Context.Resolve <HQLQueryAction>(); action.Query = query; var result = action.ActionCommand(); var presenter = new DumperBoxPresentation(); var box = BoxExtensions.CreateFor(typeof(object)); foreach (var o in result) { box.Add(o); } Writer.WriteLine(presenter.AsString(box)); }