Exemplo n.º 1
0
        public static bool AssertErrors(Modifiable mod, Window window)
        {
            string error = GetErrors(mod); 

            if (error.HasText())
            {
                MessageBox.Show(window, NormalWindowMessage.ImpossibleToSaveIntegrityCheckFailed.NiceToString() + error, NormalWindowMessage.ThereAreErrors.NiceToString(), MessageBoxButton.OK, MessageBoxImage.Error);
                return false;
            }
            return true;
        }
Exemplo n.º 2
0
        public static bool AssertErrors(Modifiable mod, Window window)
        {
            var error = GetErrors(mod);

            if (error != null)
            {
                MessageBox.Show(window, NormalWindowMessage.ImpossibleToSaveIntegrityCheckFailed.NiceToString() + error.Values.SelectMany(a=>a.Values).ToString("\r\n"), NormalWindowMessage.ThereAreErrors.NiceToString(), 
                    MessageBoxButton.OK, MessageBoxImage.Error);
                return false;
            }
            return true;
        }
Exemplo n.º 3
0
        public static bool EmbeddedOrNew(Modifiable entity)
        {
            if (entity is EmbeddedEntity)
                return true;

            if (entity is IIdentifiable)
                return ((IIdentifiable)entity).IsNew;

            if(entity is Lite<IIdentifiable>)
                return ((Lite<IIdentifiable>)entity).IsNew;

            return false;
        }
Exemplo n.º 4
0
        public static IEnumerable<Modifiable> IdentifiableExplore(Modifiable obj)
        {
            if (obj == null)//|| obj is Lite)
                yield break;

            if (Reflector.IsMList(obj.GetType()))
            {
                Type t = obj.GetType().ElementType();

                if (t.IsModifiable() && !t.IsIdentifiableEntity())
                {
                    IEnumerable col = obj as IEnumerable;
                    foreach (Modifiable item in col)
                        if (item != null)
                            yield return item;
                }
            }
            else
            {
                foreach (Func<object, object> getter in ModifiableFieldGetters(obj.GetType()))
                {
                    object field = getter(obj);

                    if (field == null || field is IdentifiableEntity)
                        continue;

                    yield return (Modifiable)field;
                }

                IdentifiableEntity ident = obj as IdentifiableEntity;
                if (ident != null)
                {
                    foreach (var mixin in ident.Mixins)
                    {
                        yield return mixin;
                    }
                }
            }
        }
Exemplo n.º 5
0
 public static string GetErrors(Modifiable mod)
 {
     var graph = GraphExplorer.PreSaving(() => GraphExplorer.FromRoot(mod));
     string error = GraphExplorer.FullIntegrityCheck(graph, withIndependentEmbeddedEntities: !(mod is IdentifiableEntity));
     return error;
 }
Exemplo n.º 6
0
 public static Dictionary<Guid, Dictionary<string, string>> GetErrors(Modifiable mod)
 {
     var graph = GraphExplorer.PreSaving(() => GraphExplorer.FromRoot(mod));
     var error = GraphExplorer.FullIntegrityCheck(graph);
     return error;
 }