Пример #1
0
        /// <summary>
        /// Helper function to add an error to the task provider
        /// when the error display filter changes.
        /// </summary>
        /// <param name="error"></param>
        public static void AddToTaskProvider(ModelError error)
        {
            if (error.IsDeleted)
            {
                return;
            }
            IORMToolTaskProvider taskProvider;

            if (null != (taskProvider = ((IORMToolServices)error.Store).TaskProvider) &&
                ModelError.IsDisplayed(error, error.Model.ModelErrorDisplayFilter))
            {
                taskProvider = (error.Store as IORMToolServices).TaskProvider;
                IORMToolTaskItem newTask = taskProvider.CreateTask();
                newTask.ElementLocator = error as IRepresentModelElements;
                newTask.Text           = error.ErrorText;
                Debug.Assert(error.TaskData == null);
                error.TaskData = newTask;
                taskProvider.AddTask(newTask);
            }
        }
Пример #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);
                    }
                }
            }
Пример #3
0
 /// <summary>
 /// Test if an error would normally be displayed but is currently hidden
 /// based on the current type-based filter state and the <see cref="ErrorState"/>
 /// of the error itself.
 /// </summary>
 /// <param name="error">The error to test.</param>
 /// <param name="filter">The filter to apply. Can be <see langword="null"/>.</param>
 /// <returns><see langword="true"/> if the error exists in a non-ignored state
 /// and the error type is allowed by the current filter.</returns>
 public static bool IsDisplayFiltered(ModelError error, ModelErrorDisplayFilter filter)
 {
     return(error != null &&
            error.ErrorState != ModelErrorState.Ignored &&
            (filter != null && filter.IsErrorExcluded(error.GetType())));
 }
Пример #4
0
 /// <summary>
 /// Create a ModelErrorUsage with default usage
 /// </summary>
 /// <param name="error">The error. Cannot be null.</param>
 public ModelErrorUsage(ModelError error) : this(error, ModelErrorUses.Verbalize)
 {
 }
Пример #5
0
 /// <summary>
 /// Adds the extension <see cref="ModelError"/> specified by <paramref name="extensionError"/> to the
 /// <see cref="IORMExtendableElement"/> specified by <paramref name="extendedElement"/>.
 /// </summary>
 public static void AddExtensionModelError(IORMExtendableElement extendedElement, ModelError extensionError)
 {
     if (extendedElement == null)
     {
         throw new ArgumentNullException("extendedElement");
     }
     if (extensionError == null)
     {
         throw new ArgumentNullException("extensionError");
     }
     extendedElement.ExtensionModelErrorCollection.Add(extensionError);
 }
Пример #6
0
            IORMExtendableElement IORMExtendableElementService.ResolveExtendedErrorOwner(ModelError extensionError)
            {
                List <Guid>           errorRoles = myExtensionErrorRoles;
                IORMExtendableElement retVal     = null;

                if (errorRoles != null)
                {
                    for (int i = 0, count = errorRoles.Count; i < count; ++i)
                    {
                        if (null != (retVal = DomainRoleInfo.GetLinkedElement(extensionError, errorRoles[i]) as IORMExtendableElement))
                        {
                            break;
                        }
                    }
                }
                return(retVal);
            }