public sealed override void ResetValue(object component)
        {
            ORMModelElement modelElement = EditorUtility.ResolveContextInstance(component, false) as ORMModelElement;

            System.Diagnostics.Debug.Assert(modelElement != null);
            CustomProperty customProperty = FindCustomProperty(modelElement);

            if (customProperty != null)
            {
                using (Transaction transaction = this.StartTransaction(modelElement))
                {
                    customProperty.Delete();
                    transaction.Commit();
                }
            }
        }
Esempio n. 2
0
        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();
                }
            }
        }