private void AddReferenceProperty(ResourceType resourceType, string name, ResourceSet targetResourceSet, bool resourceSetReference)
{
var property = new ResourceProperty(
name,
resourceSetReference ? ResourcePropertyKind.ResourceSetReference : ResourcePropertyKind.ResourceReference,
targetResourceSet.ResourceType);
property.CanReflectOnInstanceTypeProperty = false;
resourceType.AddProperty(property);
// We don't support type inheritance so the property can only point to the base resource type of the target resource set
// We also don't support MEST, that is having two resource sets with the same resource type, so we can determine
// the resource set from the resource type. That also means that the property can never point to different resource sets
// so we can precreate the ResourceAssociationSet for this property right here as we have all the information.
property.CustomState = new ResourcePropertyAnnotation()
{
ResourceAssociationSet = new ResourceAssociationSet(
resourceType.Name + "_" + name + "_" + targetResourceSet.Name,
new ResourceAssociationSetEnd(resourceType.GetAnnotation().ResourceSet, resourceType, property),
new ResourceAssociationSetEnd(targetResourceSet, targetResourceSet.ResourceType, null))
};
}