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

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

Issue 11644030: Rename specialTreatmentFor, improve handling of constants as constructor parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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
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 /** 5 /**
6 * This provides a general-purpose serialization facility for Dart objects. A 6 * This provides a general-purpose serialization facility for Dart objects. A
7 * [Serialization] is defined in terms of [SerializationRule]s and supports 7 * [Serialization] is defined in terms of [SerializationRule]s and supports
8 * reading and writing to different formats. 8 * reading and writing to different formats.
9 * 9 *
10 * Setup 10 * Setup
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 * There are cases where the constructor needs values that we can't easily get 78 * There are cases where the constructor needs values that we can't easily get
79 * the serialized object. For example, we may just want to pass null, or a 79 * the serialized object. For example, we may just want to pass null, or a
80 * constant value. To support this, we can specify as constructor fields 80 * constant value. To support this, we can specify as constructor fields
81 * values that aren't field names. If any value isn't a String, it will be 81 * values that aren't field names. If any value isn't a String, it will be
82 * treated as a constant and passed unaltered to the constructor. 82 * treated as a constant and passed unaltered to the constructor.
83 * 83 *
84 * In some cases a non-constructor field should not be set using field 84 * In some cases a non-constructor field should not be set using field
85 * access or a setter, but should be done by calling a method. For example, it 85 * access or a setter, but should be done by calling a method. For example, it
86 * may not be possible to set a List field "foo", and you need to call an 86 * may not be possible to set a List field "foo", and you need to call an
87 * addFoo() method for each entry in the list. In these cases, if you are using 87 * addFoo() method for each entry in the list. In these cases, if you are using
88 * a BasicRule for the object you can call the specialTreatmentFor() method. 88 * a BasicRule for the object you can call the setFieldWith() method.
89 * 89 *
90 * s..addRuleFor(fooHolderInstance).specialTreatmentFor("foo", 90 * s..addRuleFor(fooHolderInstance).setFieldWith("foo",
91 * (parent, value) => for (var each in value) parent.addFoo(value)); 91 * (parent, value) => for (var each in value) parent.addFoo(value));
92 * 92 *
93 * Writing 93 * Writing
94 * ======= 94 * =======
95 * To write objects, we use the write() methods. There are two variations. 95 * To write objects, we use the write() methods. There are two variations.
96 * 96 *
97 * String output = serialization.write(someObject); 97 * String output = serialization.write(someObject);
98 * List output = serialization.writeFlat(someObject); 98 * List output = serialization.writeFlat(someObject);
99 * 99 *
100 * The first uses a representation in which objects are represented as maps 100 * The first uses a representation in which objects are represented as maps
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 427 }
428 } 428 }
429 429
430 /** 430 /**
431 * An exception class for errors during serialization. 431 * An exception class for errors during serialization.
432 */ 432 */
433 class SerializationException implements Exception { 433 class SerializationException implements Exception {
434 final String message; 434 final String message;
435 const SerializationException([this.message]); 435 const SerializationException([this.message]);
436 } 436 }
OLDNEW
« no previous file with comments | « no previous file | pkg/serialization/lib/src/basic_rule.dart » ('j') | pkg/serialization/lib/src/basic_rule.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698