public PrimitiveTypeSerializer(ResourceType resourceType, ResourceProperty resourceProperty) : base(resourceType) { object defaultValue; object[] resourceTypeKind = new object[2]; resourceTypeKind[0] = resourceType.ResourceTypeKind; resourceTypeKind[1] = ResourceTypeKind.Primitive; ExceptionHelpers.ThrowArgumentExceptionIf("resourceType", resourceType.ResourceTypeKind != ResourceTypeKind.Primitive, new ExceptionHelpers.MessageLoader(SerializerBase.GetInvalidArgMessage), resourceTypeKind); this.defaultValue = null; if (resourceProperty != null) { if ((resourceProperty.Kind & ResourcePropertyKind.Primitive) != ResourcePropertyKind.Primitive || resourceProperty.ResourceType.InstanceType != resourceType.InstanceType) { throw new ArgumentException("resourceProperty"); } else { PropertyCustomState customState = resourceProperty.GetCustomState(); PrimitiveTypeSerializer primitiveTypeSerializer = this; if (customState != null) { defaultValue = customState.DefaultValue; } else { defaultValue = null; } primitiveTypeSerializer.defaultValue = defaultValue; this.name = resourceProperty.Name; } } }
public void Reset() { foreach (ResourceProperty property in this.resourceType.Properties) { if ((property.Kind & ResourcePropertyKind.Key) == ResourcePropertyKind.Key) { continue; } PropertyCustomState customState = property.GetCustomState(); if (!customState.IsUpdatable) { continue; } this.propertyUpdates.Remove(property.Name); } }