Skip to content

Commit

Permalink
refactor: factor out expansion editor
Browse files Browse the repository at this point in the history
  • Loading branch information
rdavisau committed Apr 27, 2019
1 parent 01c4910 commit 758b61a
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/DumpEditable/EditorRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public static EditorRule ForType<T>(Func<object, PropertyInfo, Func<object>, Act
Editor = getEditor,
};

public static EditorRule ForExpansionAttribute()
public static EditorRule ForExpansion(Func<object, PropertyInfo, bool> rule)
=> EditorRule.For(
(_, p) => p.GetCustomAttributes<DumpEditableExpandAttribute>().Any(),
rule,
(o, p, get, set) =>
{
var v = get();
Expand All @@ -43,16 +43,11 @@ public static EditorRule ForExpansionAttribute()
return editor;
});

public static EditorRule ForExpansionAttribute()
=> EditorRule.ForExpansion((_, p) => p.GetCustomAttributes<DumpEditableExpandAttribute>().Any());

public static EditorRule ForNestedAnonymousType()
=> EditorRule.For(
(_, p) => p.PropertyType.IsAnonymousType(),
(o, p, get, set) =>
{
var v = get();
var editor = EditableDumpContainer.For(v);
editor.OnChanged += () => set(v);
return editor;
});
=> EditorRule.ForExpansion((_, p) => p.PropertyType.IsAnonymousType());

public static EditorRule ForEnums() =>
EditorRule.For(
Expand Down

0 comments on commit 758b61a

Please sign in to comment.