Beispiel #1
0
        /// <summary>
        /// Add or remove an event handler. Use in place of the Add and Remove methods available through
        /// <see cref="EventManagerDirectory.RolePlayerOrderChanged"/>. Set the addHandler parameter to true for an Add
        /// and false for a remove.
        /// </summary>
        public void AddOrRemoveHandler(DomainModelInfo domainModel, EventHandler <RolePlayerOrderChangedEventArgs> handler, EventHandlerAction action)
        {
            bool     addHandler      = action == EventHandlerAction.Add;
            Delegate wrapperDelegate = AddOrRemove <RolePlayerOrderChangedEventArgs>(domainModel, handler, addHandler);

            if (wrapperDelegate != null)
            {
                if (addHandler)
                {
                    myStore.EventManagerDirectory.RolePlayerOrderChanged.Add(domainModel, wrapperDelegate);
                }
                else
                {
                    myStore.EventManagerDirectory.RolePlayerOrderChanged.Remove(domainModel, wrapperDelegate);
                }
            }
        }
Beispiel #2
0
            /// <summary>
            /// Add all model errors in the specific store that match the specified domain
            /// model to the task provider.
            /// </summary>
            protected sealed override void PhaseCompleted(Store store)
            {
                DomainModelInfo       modelFilter = myDomainModelFilter;
                IList <ModelHasError> errorLinks  = store.ElementDirectory.FindElements <ModelHasError>();
                int linkCount = errorLinks.Count;

                for (int i = 0; i < linkCount; ++i)
                {
                    ModelHasError errorLink = errorLinks[i];
                    ModelError    error     = errorLink.Error;
                    if (!errorLink.IsDeleted &&
                        !error.IsDeleted &&
                        (modelFilter == null || error.GetDomainClass().DomainModel == modelFilter))
                    {
                        // Make sure the error state is correct based on the full error state
                        error.FixupErrorState();
                        // Make sure the text is up to date
                        error.GenerateErrorText();
                        ModelError.AddToTaskProvider(errorLink);
                    }
                }
            }
Beispiel #3
0
 /// <summary>
 /// Add or remove the provided handler
 /// </summary>
 /// <typeparam name="TEventArgs">The type of the handler</typeparam>
 /// <param name="domainModel">The domainModel to add</param>
 /// <param name="handler">The event to add or remove</param>
 /// <param name="addHandler">true to add an event listener, false to remove one</param>
 /// <returns>Returns non-null if the wrapper needs to be added or removed</returns>
 private Delegate AddOrRemove <TEventArgs>(DomainModelInfo domainModel, EventHandler <TEventArgs> handler, bool addHandler) where TEventArgs : ModelingEventArgs
 {
     return(AddOrRemove <TEventArgs>(new TypeAndDomainObjectKey(typeof(TEventArgs), domainModel, null), handler, addHandler));
 }
Beispiel #4
0
            /// <summary>
            /// Verify that the element belongs to the correct domain model
            /// </summary>
            protected override bool VerifyElementType(ModelElement element)
            {
                DomainModelInfo modelFilter = myDomainModelFilter;

                return((modelFilter != null) ? element.GetDomainClass().DomainModel == modelFilter : true);
            }
Beispiel #5
0
 /// <summary>
 /// Create a new ModelErrorFixupListener
 /// </summary>
 /// <param name="fixupPhase">The phase for this listener</param>
 /// <param name="errorDomainModel">The domain model that owns the errors</param>
 public ModelErrorFixupListener(int fixupPhase, DomainModelInfo errorDomainModel)
     : base(fixupPhase)
 {
     myDomainModelFilter = errorDomainModel;
 }
Beispiel #6
0
 /// <summary>
 /// Return a deserialization fixup listener. Return an error fixup listener
 /// for errors in the specified domain model. The fixup listener validates
 /// all model errors and adds errors to the task provider.
 /// </summary>
 /// <param name="fixupPhase">The phase for this listener</param>
 /// <param name="errorDomainModel">The domain model that owns the errors</param>
 public static IDeserializationFixupListener GetFixupListener(int fixupPhase, DomainModelInfo errorDomainModel)
 {
     return(new ModelErrorFixupListener(fixupPhase, errorDomainModel));
 }