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

Side by Side Diff: pkg/serialization/lib/src/basic_rule.dart

Issue 126383003: Fix serialization doc bug, update to use class literals in a few more places (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/serialization/lib/serialization.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of serialization; 5 part of serialization;
6 6
7 // TODO(alanknight): Figure out how to reasonably separate out the things 7 // TODO(alanknight): Figure out how to reasonably separate out the things
8 // that require reflection without making the API more awkward. Or if that is 8 // that require reflection without making the API more awkward. Or if that is
9 // in fact necessary. Maybe the tree-shaking will just remove it if unused. 9 // in fact necessary. Maybe the tree-shaking will just remove it if unused.
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 * 90 *
91 * This method lets you designate a function to use to set the value of a 91 * This method lets you designate a function to use to set the value of a
92 * field. It also makes the contents of that field be treated as essential, 92 * field. It also makes the contents of that field be treated as essential,
93 * which currently only has meaning if the field is a list. This is done 93 * which currently only has meaning if the field is a list. This is done
94 * because you might set a list field's special treatment function to add 94 * because you might set a list field's special treatment function to add
95 * each item individually and that will only work if those objects already 95 * each item individually and that will only work if those objects already
96 * exist. 96 * exist.
97 * 97 *
98 * For example, to serialize a Serialization, we need its rules to be 98 * For example, to serialize a Serialization, we need its rules to be
99 * individually added rather than just setting the rules field. 99 * individually added rather than just setting the rules field.
100 * ..addRuleFor(new Serialization()).setFieldWith('rules', 100 * ..addRuleFor(Serialization).setFieldWith('rules',
101 * (InstanceMirror s, List rules) { 101 * (InstanceMirror s, List rules) {
102 * rules.forEach((x) => s.reflectee.addRule(x)); 102 * rules.forEach((x) => s.reflectee.addRule(x));
103 * Note that the function is passed the owning object as well as the field 103 * Note that the function is passed the owning object as well as the field
104 * value, but that it is passed as a mirror. 104 * value, but that it is passed as a mirror.
105 */ 105 */
106 void setFieldWith(String fieldName, SetWithFunction setWith) { 106 void setFieldWith(String fieldName, SetWithFunction setWith) {
107 _fields.addAllByName([fieldName]); 107 _fields.addAllByName([fieldName]);
108 _NamedField field = _fields.named(_asSymbol(fieldName)); 108 _NamedField field = _fields.named(_asSymbol(fieldName));
109 Function setter = (setWith == null) ? field.defaultSetter : setWith; 109 Function setter = (setWith == null) ? field.defaultSetter : setWith;
110 field.customSetter = setter; 110 field.customSetter = setter;
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 if (value is String) { 662 if (value is String) {
663 try { 663 try {
664 return new Symbol(value); 664 return new Symbol(value);
665 } on ArgumentError { 665 } on ArgumentError {
666 return null; 666 return null;
667 }; 667 };
668 } else { 668 } else {
669 return null; 669 return null;
670 } 670 }
671 } 671 }
OLDNEW
« no previous file with comments | « pkg/serialization/lib/serialization.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698