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

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

Issue 14188048: add installation instructions to pkg packages (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
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 * ## Installing ##
11 *
12 * Use [pub][] to install this package. Add the following to your `pubspec.yaml`
13 * file.
14 *
15 * dependencies:
16 * serialization: any
17 *
18 * And then run `pub install`.
19 *
10 * Setup 20 * Setup
11 * ===== 21 * =====
12 * A simple example of usage is 22 * A simple example of usage is
13 * 23 *
14 * var address = new Address(); 24 * var address = new Address();
15 * address.street = 'N 34th'; 25 * address.street = 'N 34th';
16 * address.city = 'Seattle'; 26 * address.city = 'Seattle';
17 * var serialization = new Serialization() 27 * var serialization = new Serialization()
18 * ..addRuleFor(address); 28 * ..addRuleFor(address);
19 * Map output = serialization.write(address); 29 * Map output = serialization.write(address);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 * take a [ClassMirror] in their constructor, and we cannot serialize those. So 184 * take a [ClassMirror] in their constructor, and we cannot serialize those. So
175 * when we read the rules, we must provide a Map<String, Object> which maps from 185 * when we read the rules, we must provide a Map<String, Object> which maps from
176 * the simple name of classes we are interested in to a [ClassMirror]. This can 186 * the simple name of classes we are interested in to a [ClassMirror]. This can
177 * be provided either in the [namedObjects] variable of the Serialization, 187 * be provided either in the [namedObjects] variable of the Serialization,
178 * or as an additional parameter to the reading and writing methods on the 188 * or as an additional parameter to the reading and writing methods on the
179 * [Reader] or [Writer] respectively. 189 * [Reader] or [Writer] respectively.
180 * 190 *
181 * new Serialization() 191 * new Serialization()
182 * ..addRuleFor(new Person(), constructorFields: ["name"]) 192 * ..addRuleFor(new Person(), constructorFields: ["name"])
183 * ..namedObjects['Person'] = reflect(new Person()).type; 193 * ..namedObjects['Person'] = reflect(new Person()).type;
194 *
195 * [pub]: http://pub.dartlang.org
184 */ 196 */
185 library serialization; 197 library serialization;
186 198
187 import 'src/mirrors_helpers.dart'; 199 import 'src/mirrors_helpers.dart';
188 import 'src/serialization_helpers.dart'; 200 import 'src/serialization_helpers.dart';
189 import 'dart:async'; 201 import 'dart:async';
190 import 'dart:json' as json; 202 import 'dart:json' as json;
191 import 'dart:collection'; 203 import 'dart:collection';
192 204
193 part 'src/reader_writer.dart'; 205 part 'src/reader_writer.dart';
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 } 481 }
470 482
471 /** 483 /**
472 * An exception class for errors during serialization. 484 * An exception class for errors during serialization.
473 */ 485 */
474 class SerializationException implements Exception { 486 class SerializationException implements Exception {
475 final String message; 487 final String message;
476 const SerializationException([this.message]); 488 const SerializationException([this.message]);
477 toString() => "SerializationException($message)"; 489 toString() => "SerializationException($message)";
478 } 490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698