public void WriteName(string name)
{
if (String.IsNullOrEmpty(name)) {
throw new ArgumentNullException("name");
}
if (_scopes.Count == 0) {
throw new InvalidOperationException("No active scope to write into.");
}
if (_scopes.Peek().Type != ScopeType.Object) {
throw new InvalidOperationException("Names can only be written into Object scopes.");
}
Scope currentScope = _scopes.Peek();
if (currentScope.Type == ScopeType.Object) {
if (currentScope.ObjectCount != 0) {
_writer.WriteTrimmed(", ");
}
currentScope.ObjectCount++;
}
_writer.Write("\"");
_writer.Write(name);
_writer.WriteTrimmed("\": ");
}