/// <summary>See <see cref="RolePlayerElementPropertyDescriptor.SetValue"/>.</summary> public override void SetValue(object component, object value) { ObjectType objectType; if (myIsReadOnly || null == (objectType = EditorUtility.ResolveContextInstance(component, false) as ObjectType)) { return; } IORMToolServices toolServices; AutomatedElementFilterCallback callback = null; Store store = objectType.Store; if (null != (toolServices = store as IORMToolServices)) { callback = delegate(ModelElement filterElement) { FactType factType; return(filterElement is ObjectType || (null != (factType = filterElement as FactType) && null == factType.ImpliedByObjectification) ? AutomatedElementDirective.NeverIgnore : AutomatedElementDirective.None); }; toolServices.AutomatedElementFilter += callback; } try { using (Transaction transaction = BeginTransaction(store)) { FactType factType = value as FactType; if (factType != null) { Objectification.CreateExplicitObjectification(factType, objectType); } else { objectType.NestedFactType = null; } if (transaction.HasPendingChanges) { transaction.Commit(); } } } finally { if (toolServices != null) { toolServices.AutomatedElementFilter -= callback; } } }
/// <summary> /// Set a value with a filter in place /// </summary> public override void SetValue(object component, object value) { IORMToolServices toolServices = null; ModelElement element; AutomatedElementFilterCallback callback = null; if (null != (element = component as ModelElement) && null != (toolServices = element.Store as IORMToolServices)) { callback = FilterAutomatedElement; toolServices.AutomatedElementFilter += callback; } try { base.SetValue(component, value); } finally { if (toolServices != null) { toolServices.AutomatedElementFilter -= callback; } } }