private static void RebuildDisplayIfNeed(DictionaryGUIState state, Inspector.Options options) { if (state.display == null || Event.current.type == EventType.Layout && (state.searchInput.changed || IsKeyChanged(state, options) || state.display.bucketSize != options.listBucketSize || state.display.sort != options.sortFields)) { var display = new DictionaryDisplay(); display.keys = state.Keys(options); display.bucketSize = options.listBucketSize; display.sort = options.sortFields; if (!string.IsNullOrEmpty(state.searchInput.text)) { display.resultKeys = FilterKeys(display.keys, state.searchInput); } else { display.resultKeys = display.keys; } if (options.sortFields) { display.resultKeys = Sorted(display.resultKeys); } state.display = display; } }
public override object[] Keys(Inspector.Options options, object collection) { object[] keys = new object[((ICollection)collection).Count]; for (int i = 0; i < keys.Length; ++i) { keys[i] = i; } return(keys); }
private static void DrawSearchInput(DictionaryGUIState state, Inspector.Options options) { if (state.searchInput == null) { state.searchInput = new SearchInputState(); } if (state.Size() < options.showSearchAtSize) { ClearSearchInput(state); return; } var now = DateTime.Now; SearchInputState input = state.searchInput; using (GUITools.Indent()) { using (GUITools.HorizontalScope()) { var newInput = GUITools.TextField("Search: ", input.text ?? ""); if (newInput != input.text) { input.text = newInput; input.lastTextChange = now; if (input.inputStart.Ticks == 0) { input.inputStart = now; } } else { if (Math.Abs((now - input.lastTextChange).TotalSeconds) > 0.5) { input.inputStart = new DateTime(); } } if (input.text != input.filter && ( input.inputStart.Ticks == 0 || Math.Abs((now - input.lastFilterChange).TotalSeconds) > 1 && Math.Abs((now - input.inputStart).TotalSeconds) > 1 )) { input.changed = true; input.filter = input.text; input.lastFilterChange = DateTime.Now; } else { input.changed = false; } } } }
private static BindingFlags GetBindingFlags(Inspector.Options options) { var flags = BindingFlags.Static | BindingFlags.Public; if (options.showNonPublicFields) { flags |= BindingFlags.NonPublic; } return(flags); }
public override object[] Keys(Inspector.Options options, object collection) { object[] keys = new object[((IDictionary)collection).Count]; int index = 0; foreach (var key in ((IDictionary)collection).Keys) { keys[index++] = key; } TypeTools.TrySort(keys); return(keys); }
private static TypeData GetMembers(Type type, Inspector.Options options) { if (!cached.ContainsKey(type)) { cached.Add(type, new TypeData()); } var data = cached[type]; BindingFlags flags = GetBindingFlags(options); if (data.flags != flags || data.hasProperties != options.showProperties) { UpdateMembers(data, type, flags, options.showProperties); } return(data); }
public override object[] Keys(Inspector.Options options, object collection) { return(GetMembers((Type)collection, options).memberNames); }
public object[] Keys(Inspector.Options options) { return(parser.Keys(options, dict.Target)); }
private static bool IsKeyChanged(DictionaryGUIState state, Inspector.Options options) { return(state.display != null && !ArrayEqual(state.display.keys, state.Keys(options))); }
//------------------------------------------------------ // 通过实现下面的成员方法,来定义容器的行为 // 必须功能:访问和遍历 public abstract object[] Keys(Inspector.Options options, object collection);