public HiddenClassSchema DeleteProperty(object key)
{
// Check if there is a transition to the schema already.
HiddenClassSchema newSchema = null;
if (this.deleteTransitions != null)
this.deleteTransitions.TryGetValue(key, out newSchema);
if (newSchema == null)
{
// Create a new schema based on this one.
var properties = this.properties == null ? CreatePropertiesDictionary() : new Dictionary<object, SchemaProperty>(this.properties);
if (properties.Remove(key) == false)
throw new InvalidOperationException(string.Format("The property '{0}' does not exist.", key));
newSchema = new HiddenClassSchema(properties, this.NextValueIndex);
// Add a transition to the new schema.
if (this.deleteTransitions == null)
this.deleteTransitions = new Dictionary<object, HiddenClassSchema>(1);
this.deleteTransitions.Add(key, newSchema);
}
return newSchema;
}