object ReadList() { object ret = ReadObject(); //Type t = ret.GetType().GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IList<>)).First(); Type t = ret.GetType(); DynamicMethodDelegate dmd = DynamicMethodDelegateFactory.CreateDelegate(t.GetMethod("Add", BindingFlags.Instance | BindingFlags.Public, null, t.GetGenericArguments(), null)); TypeMarker elemt = (TypeMarker)reader.ReadByte(); int len = (int)ReadVInt(); if (TypeMarkerUtil.IsFinal(elemt)) { for (int i = 0; i < len; i++) { dmd(ret, new[] { ReadValue(elemt) }); } } else { for (int i = 0; i < len; i++) { dmd(ret, new[] { ReadValue() }); } } return(ret); }
public object CreateControl() { var uiService = services.RequireService <IDecompilerShellUiService>(); this.control = new LowLevelView(); this.Control.Font = new Font("Lucida Console", 10F); //$TODO: use user preference this.Control.CurrentAddressChanged += LowLevelView_CurrentAddressChanged; this.Control.ImageMapView.SelectedAddressChanged += ImageMapView_SelectedAddressChanged; this.Control.MemoryView.SelectionChanged += MemoryView_SelectionChanged; uiService.SetContextMenu(this.Control.MemoryView, MenuIds.CtxMemoryControl); this.control.MemoryView.Services = this.services; this.Control.DisassemblyView.StyleClass = UiStyles.Disassembler; this.Control.DisassemblyView.SelectedObjectChanged += DisassemblyView_SelectedObjectChanged; uiService.SetContextMenu(this.Control.DisassemblyView, MenuIds.CtxDisassembler); this.Control.DisassemblyView.Services = this.services; this.Control.DisassemblyView.Navigate += DisassemblyControl_Navigate; this.Control.VisualizerControl.Services = services; PopulateVisualizers(); this.Control.VisualizerList.SelectedIndexChanged += VisualizerList_SelectedIndexChanged; this.control.VisualizerList.SelectedIndex = 0; this.Control.ToolBarGoButton.Click += ToolBarGoButton_Click; this.Control.ToolBarAddressTextbox.KeyDown += ToolBarAddressTextbox_KeyDown; this.navInteractor = new NavigationInteractor <Address>(); this.navInteractor.Attach(this.Control); typeMarker = new TypeMarker(control.MemoryView); return(control); }
object GetValue(object obj, TypeMarker type) { switch (type) { case TypeMarker.Null: return(null); case TypeMarker.SByte: case TypeMarker.Byte: case TypeMarker.Short: case TypeMarker.UShort: case TypeMarker.Bool: case TypeMarker.Char: case TypeMarker.Int: case TypeMarker.UInt: case TypeMarker.Long: case TypeMarker.ULong: return(obj); case TypeMarker.Float: return(GetFloatRef((float)obj)); case TypeMarker.Double: return(GetDoubleRef((double)obj)); case TypeMarker.Decimal: return(GetDecimalRef((decimal)obj)); case TypeMarker.String: return(GetStringRef((string)obj)); case TypeMarker.Date: return(GetDateRef((DateTime)obj)); case TypeMarker.Array: return(ConvertArray((Array)obj)); case TypeMarker.IList: return(ConvertList((IEnumerable)obj)); case TypeMarker.IDictionary: return(ConvertDictionary(obj)); case TypeMarker.Dynamic: throw new NotSupportedException("DynamicObjects are not supported"); case TypeMarker.Object: return(ConvertObject(obj)); default: throw new NotSupportedException("Type <" + type + "> is not supported"); } }
private static void DeserializeAndAddProperty( TypeMarker typeMarker, byte[] serializedBytes, JObject jObject, string key) { SqlSerializerFactory sqlSerializerFactory = new SqlSerializerFactory(); // UTF-8 encoding. SqlVarcharSerializer sqlVarcharSerializer = new SqlVarcharSerializer(size: -1, codePageCharacterEncoding: 65001); switch (typeMarker) { case TypeMarker.Boolean: jObject.Add(key, sqlSerializerFactory.GetDefaultSerializer <bool>().Deserialize(serializedBytes)); break; case TypeMarker.Double: jObject.Add(key, sqlSerializerFactory.GetDefaultSerializer <double>().Deserialize(serializedBytes)); break; case TypeMarker.Long: jObject.Add(key, sqlSerializerFactory.GetDefaultSerializer <long>().Deserialize(serializedBytes)); break; case TypeMarker.String: jObject.Add(key, sqlVarcharSerializer.Deserialize(serializedBytes)); break; case TypeMarker.Array: jObject.Add(key, JsonConvert.DeserializeObject <JArray>(sqlVarcharSerializer.Deserialize(serializedBytes))); break; case TypeMarker.Object: jObject.Add(key, JsonConvert.DeserializeObject <JObject>(sqlVarcharSerializer.Deserialize(serializedBytes))); break; default: Debug.Fail(string.Format("Unexpected type marker {0}", typeMarker)); break; } }
Array ReadArray() { TypeMarker elemt = (TypeMarker)reader.ReadByte(); Type t = types[(int)ReadVInt()]; Array arr = Array.CreateInstance(t, (int)ReadVInt()); if (TypeMarkerUtil.IsFinal(elemt)) { for (int i = 0; i < arr.Length; i++) { arr.SetValue(ReadValue(elemt), i); } } else { for (int i = 0; i < arr.Length; i++) { arr.SetValue(ReadValue(), i); } } return(arr); }
private static void DeserializeAndAddProperty( TypeMarker typeMarker, byte[] serializedBytes, JObject jObject, string key) { switch (typeMarker) { case TypeMarker.Boolean: jObject.Add(key, SqlSerializerFactory.GetDefaultSerializer <bool>().Deserialize(serializedBytes)); break; case TypeMarker.Double: jObject.Add(key, SqlSerializerFactory.GetDefaultSerializer <double>().Deserialize(serializedBytes)); break; case TypeMarker.Long: jObject.Add(key, SqlSerializerFactory.GetDefaultSerializer <long>().Deserialize(serializedBytes)); break; case TypeMarker.String: jObject.Add(key, SqlVarCharSerializer.Deserialize(serializedBytes)); break; case TypeMarker.Array: jObject.Add(key, JsonConvert.DeserializeObject <JArray>(SqlVarCharSerializer.Deserialize(serializedBytes), JsonSerializerSettings)); break; case TypeMarker.Object: jObject.Add(key, JsonConvert.DeserializeObject <JObject>(SqlVarCharSerializer.Deserialize(serializedBytes), JsonSerializerSettings)); break; default: Debug.Fail(string.Format("Unexpected type marker {0}", typeMarker)); break; } }
public SearchResultView(ListView lv) { this.listView = lv; this.listView.Columns.Clear(); this.typeMarker = new TypeMarker(listView); }
public Control CreateControl() { var uiService = services.RequireService<IDecompilerShellUiService>(); var uiPrefsSvc = services.RequireService<IUiPreferencesService>(); this.control = new LowLevelView(); this.Control.Font = uiPrefsSvc.DisassemblerFont ?? new Font("Lucida Console", 10F); //$TODO: use user preference this.Control.CurrentAddressChanged += LowLevelView_CurrentAddressChanged; this.Control.ImageMapView.SelectedAddressChanged += ImageMapView_SelectedAddressChanged; this.Control.MemoryView.SelectionChanged += MemoryView_SelectionChanged; this.Control.MemoryView.ContextMenu = uiService.GetContextMenu(MenuIds.CtxMemoryControl); this.control.MemoryView.Services = this.services; this.Control.DisassemblyView.SelectedObjectChanged += DisassemblyView_SelectedObjectChanged; this.Control.DisassemblyView.ContextMenu = uiService.GetContextMenu(MenuIds.CtxDisassembler); this.Control.DisassemblyView.Navigate += DisassemblyControl_Navigate; this.Control.ToolBarGoButton.Click += ToolBarGoButton_Click; this.Control.ToolBarAddressTextbox.KeyDown += ToolBarAddressTextbox_KeyDown; this.navInteractor = new NavigationInteractor(); this.navInteractor.Attach(this.Control); typeMarker = new TypeMarker(control.MemoryView); typeMarker.TextChanged += typeMarker_FormatType; typeMarker.TextAccepted += typeMarker_TextAccepted; return control; }
object ReadValue(TypeMarker t) { switch (t) { case TypeMarker.Null: return(null); case TypeMarker.SByte: return((sbyte)reader.ReadSByte()); case TypeMarker.Byte: return(reader.ReadByte()); case TypeMarker.Short: return((short)ReadVSInt()); case TypeMarker.UShort: return((ushort)ReadVInt()); case TypeMarker.Int: return((int)ReadVSInt()); case TypeMarker.UInt: return((uint)ReadVInt()); case TypeMarker.Long: return((long)ReadVSInt()); case TypeMarker.ULong: return((ulong)ReadVInt()); case TypeMarker.Float: return(floats[(int)ReadVInt()]); case TypeMarker.Double: return(doubles[(int)ReadVInt()]); case TypeMarker.Decimal: return(decimals[(int)ReadVInt()]); case TypeMarker.Bool: return(reader.ReadBoolean()); case TypeMarker.Char: return((char)ReadVInt()); case TypeMarker.String: return(strings[(int)ReadVInt()]); case TypeMarker.Date: return(dates[(int)ReadVInt()]); case TypeMarker.Array: return(ReadArray()); case TypeMarker.IList: return(ReadList()); case TypeMarker.IDictionary: return(ReadDictionary()); case TypeMarker.Object: return(ReadObject()); default: throw new NotSupportedException("Type <" + t + "> is not supported"); } }
public SearchResultView(ListView lv) { this.listView = lv; this.listView.Columns.Clear(); this.typeMarker = new TypeMarker(listView); }
public static bool IsFinal(TypeMarker type) { return(!(type == TypeMarker.Array || type == TypeMarker.IList || type == TypeMarker.IDictionary || type == TypeMarker.Dynamic || type == TypeMarker.Object)); }