Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1004)

Unified Diff: pkg/serialization/lib/serialization.dart

Issue 23447003: Change reflective serialization rules to be able to take type literals (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/serialization/lib/src/mirrors_helpers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | pkg/serialization/lib/src/mirrors_helpers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698