public sealed override void SetValue(object component, object value) { CustomPropertyDefinition customPropertyDefinition = this.customPropertyDefinition; IORMExtendableElement modelElement; if (null != (modelElement = ResolveComponent(component))) { CustomProperty customProperty = FindCustomProperty(modelElement); using (Transaction transaction = this.StartTransaction(modelElement.Store)) { if (customProperty != null) { if (!object.Equals(customProperty.Value, value)) { if (value == null || object.Equals(customPropertyDefinition.DefaultValue, value)) { customProperty.Delete(); } else { customProperty.Value = value; } } } else if (value != null && !object.Equals(customPropertyDefinition.DefaultValue, value)) { customProperty = new CustomProperty(modelElement.Store.DefaultPartition, new PropertyAssignment(CustomProperty.ValueDomainPropertyId, value)); customProperty.CustomPropertyDefinition = customPropertyDefinition; modelElement.ExtensionCollection.Add(customProperty); } if (transaction.HasPendingChanges) { transaction.Commit(); } } } }
public sealed override void SetValue(object component, object value) { CustomPropertyDefinition customPropertyDefinition = this.customPropertyDefinition; ORMModelElement modelElement = EditorUtility.ResolveContextInstance(component, false) as ORMModelElement; System.Diagnostics.Debug.Assert(modelElement != null); CustomProperty customProperty = FindCustomProperty(modelElement); using (Transaction transaction = this.StartTransaction(modelElement)) { if (customProperty != null) { if (!object.Equals(customProperty.Value, value)) { if (value == null || object.Equals(customPropertyDefinition.DefaultValue, value)) { customProperty.Delete(); } else { customProperty.Value = value; } } } else if (value != null && !object.Equals(customPropertyDefinition.DefaultValue, value)) { customProperty = new CustomProperty(modelElement.Partition, new PropertyAssignment(CustomProperty.ValueDomainPropertyId, value)); customProperty.CustomPropertyDefinition = customPropertyDefinition; modelElement.ExtensionCollection.Add(customProperty); } if (transaction.HasPendingChanges) { transaction.Commit(); } } }
/// <summary> /// Constructor /// Creates a CustomPropertyHasCustomPropertyDefinition link in the same Partition as the given CustomProperty /// </summary> /// <param name="source">CustomProperty to use as the source of the relationship.</param> /// <param name="target">CustomPropertyDefinition to use as the target of the relationship.</param> internal CustomPropertyHasCustomPropertyDefinition(CustomProperty source, CustomPropertyDefinition target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[] { new DslModeling::RoleAssignment(CustomPropertyHasCustomPropertyDefinition.CustomPropertyDomainRoleId, source), new DslModeling::RoleAssignment(CustomPropertyHasCustomPropertyDefinition.CustomPropertyDefinitionDomainRoleId, target) }, null) { }
internal static void SetCustomPropertyDefinition(CustomProperty element, CustomPropertyDefinition newCustomPropertyDefinition) { DslModeling::DomainRoleInfo.SetLinkedElement(element, CustomPropertyDomainRoleId, newCustomPropertyDefinition); }
internal static CustomPropertyDefinition GetCustomPropertyDefinition(CustomProperty element) { return(DslModeling::DomainRoleInfo.GetLinkedElement(element, CustomPropertyDomainRoleId) as CustomPropertyDefinition); }
/// <summary> /// Constructor /// Creates a CustomPropertyHasCustomPropertyDefinition link in the same Partition as the given CustomProperty /// </summary> /// <param name="source">CustomProperty to use as the source of the relationship.</param> /// <param name="target">CustomPropertyDefinition to use as the target of the relationship.</param> public CustomPropertyHasCustomPropertyDefinition(CustomProperty source, CustomPropertyDefinition target) : base((source != null ? source.Partition : null), new DslModeling::RoleAssignment[]{new DslModeling::RoleAssignment(CustomPropertyHasCustomPropertyDefinition.CustomPropertyDomainRoleId, source), new DslModeling::RoleAssignment(CustomPropertyHasCustomPropertyDefinition.CustomPropertyDefinitionDomainRoleId, target)}, null) { }
public static void SetCustomPropertyDefinition(CustomProperty element, CustomPropertyDefinition newCustomPropertyDefinition) { DslModeling::DomainRoleInfo.SetLinkedElement(element, CustomPropertyDomainRoleId, newCustomPropertyDefinition); }
public static CustomPropertyDefinition GetCustomPropertyDefinition(CustomProperty element) { return DslModeling::DomainRoleInfo.GetLinkedElement(element, CustomPropertyDomainRoleId) as CustomPropertyDefinition; }