/// <summary> /// Clears any existing relations when deleting a node with a MultiPickerRelations datatype /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="umbraco.cms.businesslogic.DeleteEventArgs"/> instance containing the event data.</param> private void BeforeDelete(Content sender, DeleteEventArgs e) { var multiPickerRelationsId = new Guid(DataTypeConstants.MultiPickerRelationsId); // Clean up any relations // For each MultiPickerRelations datatype foreach (var multiPickerRelationsProperty in from property in sender.GenericProperties where property.PropertyType.DataTypeDefinition.DataType.Id == multiPickerRelationsId select property) { // used to identify this datatype instance - relations created are marked with this in the comment field string instanceIdentifier = "[\"PropertyTypeId\":" + multiPickerRelationsProperty.PropertyType.Id.ToString() + "]"; // get configuration options for datatype MultiPickerRelationsOptions options = ((MultiPickerRelationsPreValueEditor)multiPickerRelationsProperty.PropertyType.DataTypeDefinition.DataType.PrevalueEditor).Options; // get relationType from options RelationType relationType = RelationType.GetById(options.RelationTypeId); if (relationType != null) { // clear all exisitng relations DeleteRelations(relationType, sender.Id, options.ReverseIndexing, instanceIdentifier); } } }
/////// NOT CURRENTLY USED, BUT MIGHT BE USEFUL TO MARK BIDIRECTIONAL RELATIONS /////// <summary> /////// string to identify a particular instance of this datatype /////// </summary> ////private string InstanceIdentifier ////{ //// get //// { //// Property multiPickerRelationsProperty = new Property(((DefaultData)this.data).PropertyId); //// return "[" + multiPickerRelationsProperty.PropertyType.Id.ToString() + "]"; //// } ////} /// <summary> /// Initializes a new instance of MultiPickerRelationsDataEditor /// </summary> /// <param name="data">data stored by this instance of this datatype (not currently used)</param> /// <param name="options">configuration options for this datatype as set by the PreValueEditor</param> internal MultiPickerRelationsDataEditor(IData data, MultiPickerRelationsOptions options) { this.data = data; this.options = options; }