| Index: pkg/serialization/lib/serialization.dart
|
| diff --git a/pkg/serialization/lib/serialization.dart b/pkg/serialization/lib/serialization.dart
|
| index 9323ec114f288728052b1f98a908252d95c6362c..9a052de24ff9aa20b4de705c2733e29fc781d4f4 100644
|
| --- a/pkg/serialization/lib/serialization.dart
|
| +++ b/pkg/serialization/lib/serialization.dart
|
| @@ -297,8 +297,10 @@ class Serialization {
|
| this.rules = new UnmodifiableListView(rules);
|
|
|
| /**
|
| - * Create a [BasicRule] rule for the type of
|
| - * [instanceOfType]. Optionally
|
| + * Create a [BasicRule] rule for [instanceOrType]. Normally this will be
|
| + * a type, but for backward compatibilty we also allow you to pass an
|
| + * instance (except an instance of Type), and the rule will be created
|
| + * for its runtimeType. Optionally
|
| * allows specifying a [constructor] name, the list of [constructorFields],
|
| * and the list of [fields] not used in the constructor. Returns the new
|
| * rule. Note that [BasicRule] uses reflection, and so will not work with the
|
| @@ -321,9 +323,8 @@ class Serialization {
|
| * are not inherited, and so may need to be specified separately for each
|
| * subclass.
|
| */
|
| - // TODO(alanknight): Take a type rather than an instance. Issue 6282 and 6433.
|
| BasicRule addRuleFor(
|
| - instanceOfType,
|
| + instanceOrType,
|
| {String constructor,
|
| List constructorFields,
|
| List<String> fields,
|
| @@ -331,7 +332,7 @@ class Serialization {
|
|
|
| var rule = new BasicRule(
|
| turnInstanceIntoSomethingWeCanUse(
|
| - instanceOfType),
|
| + instanceOrType),
|
| constructor, constructorFields, fields, excludeFields);
|
| addRule(rule);
|
| return rule;
|
|
|