Beispiel #1
0
 public EntityRepeater(Type type, object untypedValue, Context parent, string prefix, PropertyRoute propertyRoute)
     : base(type, untypedValue, parent, prefix, propertyRoute)
 {
     Find = false;
     LabelClass = "sf-label-repeater-line";
     Reorder = false;
 }
Beispiel #2
0
        internal static MetaExpression FromRoute(Type type, Implementations? implementations, PropertyRoute pr)
        {
            if (pr == null)
                return new MetaExpression(type.UnNullify().CleanType(), new DirtyMeta(implementations, new Meta[0]));

            return new MetaExpression(type.UnNullify().CleanType(), new CleanMeta(implementations, new[] { pr }));
        }
        public static IDisposable SetCurrentPropertyRoute(PropertyRoute route)
        {
            var old = currentPropertyRoute.Value;

            currentPropertyRoute.Value = route;

            return new Disposable(() => { currentPropertyRoute.Value = old; });
        }
Beispiel #4
0
 public EntityBase(Type type, object untypedValue, Context parent, string prefix, PropertyRoute propertyRoute)
     : base(type, untypedValue, parent, prefix, propertyRoute)
 {
     View = true;
     Create = true;
     Find = true;
     Remove = true;
 }
        internal EntityPropertyToken(QueryToken parent, PropertyInfo pi, PropertyRoute pr)
            : base(parent)
        {
            if (pi == null)
                throw new ArgumentNullException("pi");

            this.PropertyInfo = pi;
            this.PropertyRoute = pr;
        }
Beispiel #6
0
 public EntityCombo(Type type, object untypedValue, Context parent, string prefix, PropertyRoute propertyRoute)
     : base(type, untypedValue, parent, prefix, propertyRoute)
 {
     Size = 0;
     View = false;
     Create = false;
     Remove = false;
     Find = false;
 }
 public FileLine(Type type, object untypedValue, Context parent, string prefix, PropertyRoute propertyRoute)
     : base(type, untypedValue, parent, prefix, propertyRoute)
 {
     AsyncUpload = true;
     DragAndDrop = true;
     Download = DownloadBehaviour.View;
     Create = false;
     View = false;
 }
Beispiel #8
0
 public EntityListCheckbox(Type type, object untypedValue, Context parent, string prefix, PropertyRoute propertyRoute)
     : base(type, untypedValue, parent, prefix, propertyRoute)
 {
     View = false;
     Create = false;
     Remove = false;
     Find = false;
     Move = false;
     ColumnWidth = 300;
 }
        static MemberInfoTS OnAddPropertyRouteExtension(MemberInfoTS mi, PropertyRoute m)
        {
            if (AddPropertyRouteExtension == null)
                return mi;

            foreach (var a in AddPropertyRouteExtension.GetInvocationListTyped())
                a(mi, m);

            return mi;
        }
        public static PropertyRoute Continue(PropertyRoute route, string continuation)
        {
            string[] steps = continuation.Replace("/", ".Item.").Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);

            PropertyRoute context = route;

            foreach (var step in steps)
            {
                context = context.Add(step);
            }

            return context;
        }
Beispiel #11
0
        public EntityStrip(Type type, object untypedValue, Context parent, string prefix, PropertyRoute propertyRoute)
            : base(type, untypedValue, parent, prefix, propertyRoute)
        {
            bool isEmbedded = type.ElementType().IsEmbeddedEntity();

            Find = false;
            Reorder = false;
            Create = isEmbedded;
            Navigate = !isEmbedded;
            View = isEmbedded;
            Autocomplete = !isEmbedded;
            Remove = true;
        }
Beispiel #12
0
        public static Implementations GetImplementations(PropertyRoute route)
        {
            if (!typeof(ModelEntity).IsAssignableFrom(route.RootType))
                throw new InvalidOperationException("Route {0} is not rooted on a {1}".Formato(route, typeof(ModifiableEntity).Name));

            PropertyRoute fieldRoute = route;
            if (fieldRoute.PropertyRouteType == PropertyRouteType.LiteEntity)
                fieldRoute = fieldRoute.Parent;

            if (fieldRoute.PropertyRouteType == PropertyRouteType.MListItems)
                fieldRoute = fieldRoute.Parent;

            return Implementations.FromAttributes(
                route.Type.CleanType(),
                fieldRoute.FieldInfo.GetCustomAttributes(true).Cast<Attribute>().ToArray(),
                route);
        }
Beispiel #13
0
        public ExtensionToken(QueryToken parent, string key, Type type, bool isProjection,
            string unit, string format, 
            Implementations? implementations,
            string isAllowed, PropertyRoute propertyRoute)
            : base(parent)
        {
            var shouldHaveImplementations = typeof(IEntity).IsAssignableFrom((isProjection ? type.ElementType() : type).CleanType());

            if (shouldHaveImplementations && implementations == null)
                throw new ArgumentException("Extension token '{0}' (of type {1}) registered on type {2} has no implementations".FormatWith(key, type.TypeName(), parent.Type.CleanType().TypeName()));

            this.key= key;
            this.type = type;
            this.isProjection = isProjection;
            this.unit = unit;
            this.format = format;
            this.implementations = implementations;
            this.isAllowed = isAllowed;
            this.propertyRoute = propertyRoute;
        }
Beispiel #14
0
 static void TaskSetNotNullItemsSource(FrameworkElement fe, string route, PropertyRoute context)
 {
     ValueLine vl = fe as ValueLine;
     if (vl != null && vl.NotSet(ValueLine.ItemSourceProperty) && context.PropertyRouteType == PropertyRouteType.FieldOrProperty)
     {
         if (context.Type.IsNullable() && context.Type.UnNullify().IsEnum &&
            Validator.TryGetPropertyValidator(context).Let(pv => pv != null && pv.Validators.OfType<NotNullValidatorAttribute>().Any()))
         {
             vl.ItemSource = EnumExtensions.UntypedGetValues(vl.Type.UnNullify()).ToObservableCollection();
         }
     }
 }
Beispiel #15
0
        static void TaskSetMaxLenth(FrameworkElement fe, string route, PropertyRoute context)
        {
            ValueLine vl = fe as ValueLine;
            if (vl != null && context.PropertyRouteType == PropertyRouteType.FieldOrProperty && context.Type == typeof(string))
            {
                var slv = Validator.TryGetPropertyValidator(context)?.Validators.OfType<StringLengthValidatorAttribute>().FirstOrDefault();
                if (slv != null && slv.Max != -1)
                    vl.MaxTextLength = slv.Max;

                //if (slv != null && slv.MultiLine)
                //    vl.ValueLineType = ValueLineType.TextArea;
            }
        }
 public static ValueLineModalProxy AsValueLineModal <T, V>(this IWebElement element, Expression <Func <T, V> > propertyRoute)
     where T : IRootEntity
 {
     return(new ValueLineModalProxy(element, PropertyRoute.Construct(propertyRoute)));
 }
Beispiel #17
0
        public static WikiLink LinkParser(string content)
        {
            Match m = HelpLogic.HelpLinkRegex.Match(content);

            if (m.Success)
            {
                string letter = m.Groups["letter"].ToString();
                string link   = m.Groups["link"].ToString();
                string text   = m.Groups["text"].ToString();

                switch (letter)
                {
                case WikiFormat.EntityLink:
                    Type t = TypeLogic.TryGetType(link);
                    return(new WikiLink(
                               HelpUrls.EntityUrl(t),
                               text.HasText() ? text : t.NiceName()));

                case WikiFormat.Hyperlink:
                    return(new WikiLink(link, text));

                case WikiFormat.OperationLink:
                    OperationSymbol operation = SymbolLogic <OperationSymbol> .TryToSymbol(link);

                    List <Type> types = OperationLogic.FindTypes(operation).Where(TypeLogic.TypeToEntity.ContainsKey).ToList();
                    if (types.Count == 1)
                    {
                        return(new WikiLink(
                                   HelpUrls.OperationUrl(types[0], operation),
                                   text.HasText() ? text : operation.NiceToString()));
                    }
                    else
                    {
                        return(new MultiWikiLink(operation.NiceToString())
                        {
                            Links = types.Select(currentType =>
                                                 new WikiLink(
                                                     HelpUrls.OperationUrl(currentType, operation),
                                                     currentType.NiceName(), operation.NiceToString())).ToList()
                        });
                    }

                case WikiFormat.PropertyLink:
                    PropertyRoute route = PropertyRoute.Parse(TypeLogic.TryGetType(link.Before('.')), link.After('.'));

                    while (route.PropertyRouteType == PropertyRouteType.LiteEntity ||
                           route.PropertyRouteType == PropertyRouteType.Mixin ||
                           route.PropertyRouteType == PropertyRouteType.MListItems)
                    {
                        route = route.Parent;
                    }

                    return(new WikiLink(HelpUrls.PropertyUrl(route), route.PropertyInfo.NiceName()));

                case WikiFormat.QueryLink:
                    object o = QueryLogic.TryToQueryName(link);
                    if (o as Enum != null)
                    {
                        Enum query = (Enum)o;
                        return(new WikiLink(
                                   HelpUrls.QueryUrl(query),
                                   text.HasText() ? text : QueryUtils.GetNiceName(query)));
                    }
                    else
                    {
                        Type query = (Type)o;
                        return(new WikiLink(
                                   HelpUrls.QueryUrl(query),
                                   text.HasText() ? text : QueryUtils.GetNiceName(query)));
                    }

                case WikiFormat.NamespaceLink:
                    NamespaceHelp nameSpace = HelpLogic.GetNamespaceHelp(link);
                    return(new WikiLink(
                               HelpUrls.NamespaceUrl(link),
                               text.HasText() ? text : link,
                               nameSpace != null ? "" : "unavailable"));

                case WikiFormat.AppendixLink:
                    AppendixHelp appendix = HelpLogic.GetAppendixHelp(link);
                    return(new WikiLink(
                               HelpUrls.AppendixUrl(link),
                               text.HasText() ? text : link,
                               appendix != null ? "" : "unavailable"));
                }
            }
            return(null);
        }
Beispiel #18
0
 public FieldTicks(PropertyRoute route)
     : base(route)
 {
 }
Beispiel #19
0
 public FieldMixin(PropertyRoute route, Table mainEntityTable)
     : base(route)
 {
     this.MainEntityTable = mainEntityTable;
 }
Beispiel #20
0
 public FieldMList(PropertyRoute route) : base(route)
 {
 }
Beispiel #21
0
 public LineContainer <S> As <S>() where S : T
 {
     return(new LineContainer <S>(this.Element, PropertyRoute.Root(typeof(S))));
 }
Beispiel #22
0
 public static PropertyAllowed GetPropertyAllowed(Lite <RoleEntity> role, PropertyRoute property)
 {
     return(cache.GetAllowed(role, property));
 }
Beispiel #23
0
 static int BulkInsertMListTablePropertyRoute <E, V>(List <E> entities, PropertyRoute route, SqlBulkCopyOptions copyOptions, int?timeout, string?message)
     where E : Entity
 {
     return(BulkInsertMListTable <E, V>(entities, route.GetLambdaExpression <E, MList <V> >(safeNullAccess: false), copyOptions, timeout, message));
 }
Beispiel #24
0
 public static void SetMaxAutomaticUpgrade(PropertyRoute property, PropertyAllowed allowed)
 {
     MaxAutomaticUpgrade.Add(property, allowed);
 }
        public override string IsAllowed()
        {
            PropertyRoute route = GetPropertyRoute();

            return(Parent.IsAllowed());
        }
Beispiel #26
0
 public LineLocator(WebElementLocator elementLocator, PropertyRoute route)
 {
     ElementLocator = elementLocator;
     Route          = route;
 }
Beispiel #27
0
 public EntityLine(Type type, object untypedValue, Context parent, string prefix, PropertyRoute propertyRoute)
     : base(type, untypedValue, parent, prefix, propertyRoute)
 {
     Autocomplete = true;
     Navigate = true;
 }
Beispiel #28
0
 public FieldPrimaryKey(PropertyRoute route, Table table)
     : base(route)
 {
     this.table = table;
 }
Beispiel #29
0
 public static AuthThumbnail?GetAllowedThumbnail(Lite <RoleEntity> role, Type entityType)
 {
     return(PropertyRoute.GenerateRoutes(entityType).Select(pr => cache.GetAllowed(role, pr)).Collapse());
 }
Beispiel #30
0
 public LineContainer(IWebElement element, PropertyRoute?route = null)
 {
     this.Element = element;
     this.Route   = route ?? PropertyRoute.Root(typeof(T));
 }
Beispiel #31
0
 public FieldImplementedByAll(PropertyRoute route) : base(route)
 {
 }
Beispiel #32
0
        public static void Start(SchemaBuilder sb)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                AuthLogic.AssertStarted(sb);
                PropertyRouteLogic.Start(sb);

                sb.Include <RulePropertyEntity>()
                .WithUniqueIndex(rt => new { rt.Resource, rt.Role });

                cache = new AuthCache <RulePropertyEntity, PropertyAllowedRule, PropertyRouteEntity, PropertyRoute, PropertyAllowed>(sb,
                                                                                                                                     toKey: PropertyRouteEntity.ToPropertyRouteFunc,
                                                                                                                                     toEntity: PropertyRouteLogic.ToPropertyRouteEntity,
                                                                                                                                     isEquals: (p1, p2) => p1 == p2,
                                                                                                                                     merger: new PropertyMerger(),
                                                                                                                                     invalidateWithTypes: true,
                                                                                                                                     coercer: PropertyCoercer.Instance);

                sb.Schema.EntityEvents <RoleEntity>().PreUnsafeDelete += query =>
                {
                    Database.Query <RulePropertyEntity>().Where(r => query.Contains(r.Role.Entity)).UnsafeDelete();
                    return(null);
                };

                PropertyRoute.SetIsAllowedCallback(pp => pp.GetAllowedFor(PropertyAllowed.Read));

                AuthLogic.ExportToXml += exportAll => cache.ExportXml("Properties", "Property", p => TypeLogic.GetCleanName(p.RootType) + "|" + p.PropertyString(), pa => pa.ToString(),
                                                                      exportAll ? TypeLogic.TypeToEntity.Keys.SelectMany(t => PropertyRoute.GenerateRoutes(t)).ToList() : null);
                AuthLogic.ImportFromXml += (x, roles, replacements) =>
                {
                    Dictionary <Type, Dictionary <string, PropertyRoute> > routesDicCache = new Dictionary <Type, Dictionary <string, PropertyRoute> >();

                    var groups = x.Element("Properties").Elements("Role").SelectMany(r => r.Elements("Property")).Select(p => new PropertyPair(p.Attribute("Resource").Value))
                                 .AgGroupToDictionary(a => a.Type, gr => gr.Select(pp => pp.Property).ToHashSet());

                    foreach (var item in groups)
                    {
                        Type?type = TypeLogic.NameToType.TryGetC(replacements.Apply(TypeAuthCache.typeReplacementKey, item.Key));

                        if (type == null)
                        {
                            continue;
                        }

                        var dic = PropertyRoute.GenerateRoutes(type).ToDictionary(a => a.PropertyString());

                        replacements.AskForReplacements(
                            item.Value,
                            dic.Keys.ToHashSet(),
                            AuthPropertiesReplacementKey(type));

                        routesDicCache[type] = dic;
                    }

                    var routes = Database.Query <PropertyRouteEntity>().ToDictionary(a => a.ToPropertyRoute());

                    return(cache.ImportXml(x, "Properties", "Property", roles, s =>
                    {
                        var pp = new PropertyPair(s);

                        Type?type = TypeLogic.NameToType.TryGetC(replacements.Apply(TypeAuthCache.typeReplacementKey, pp.Type));
                        if (type == null)
                        {
                            return null;
                        }

                        PropertyRoute?route = routesDicCache[type].TryGetC(replacements.Apply(AuthPropertiesReplacementKey(type), pp.Property));
                        if (route == null)
                        {
                            return null;
                        }

                        var property = routes.GetOrCreate(route, () => new PropertyRouteEntity
                        {
                            Route = route,
                            RootType = TypeLogic.TypeToEntity[route.RootType],
                            Path = route.PropertyString()
                        }.Save());

                        return property;
                    }, EnumExtensions.ToEnum <PropertyAllowed>));
                };

                sb.Schema.Table <PropertyRouteEntity>().PreDeleteSqlSync += new Func <Entity, SqlPreCommand>(AuthCache_PreDeleteSqlSync);
            }
        }
Beispiel #33
0
 public Field(PropertyRoute route, Type fieldType = null)
 {
     this.Route     = route;
     this.FieldType = fieldType ?? route.Type;
 }
Beispiel #34
0
        public static void TaskGridViewColumnSetLabelText(GridViewColumn col, string route, PropertyRoute context)
        {
            DependencyProperty labelText = GridViewColumn.HeaderProperty;

            if (labelText != null && col.NotSet(labelText))
            {
                string text = context.PropertyInfo.NiceName();

                col.SetValue(labelText, text);
            }
        }
Beispiel #35
0
 public FieldValue(PropertyRoute route, Type fieldType = null)
     : base(route, fieldType)
 {
 }
Beispiel #36
0
        public static void TaskSetTypeProperty(FrameworkElement fe, string route, PropertyRoute context)
        {
            DependencyProperty typeProperty = TypePropertySelector.TryGetValue(fe.GetType());

            if (typeProperty != null && fe.NotSet(typeProperty))
            {
                fe.SetValue(typeProperty, context.Type);
            }
        }
Beispiel #37
0
 public FieldEmbedded(PropertyRoute route)
     : base(route)
 {
 }
Beispiel #38
0
 static void TaskSetUnitText(FrameworkElement fe, string route, PropertyRoute context)
 {
     ValueLine vl = fe as ValueLine;
     if (vl != null && vl.NotSet(ValueLine.UnitTextProperty) && context.PropertyRouteType == PropertyRouteType.FieldOrProperty)
     {
         UnitAttribute ua = context.PropertyInfo.GetCustomAttribute<UnitAttribute>();
         if (ua != null)
             vl.UnitText = ua.UnitName;
     }
 }
Beispiel #39
0
 public ValueLineProxy(IWebElement element, PropertyRoute route)
     : base(element, route)
 {
 }
Beispiel #40
0
        public static void TaskSetIsReadonly(FrameworkElement fe, string route, PropertyRoute context)
        {
            bool isReadOnly = context.PropertyRouteType == PropertyRouteType.FieldOrProperty && context.PropertyInfo.IsReadOnly();

            if (isReadOnly && fe.NotSet(Common.IsReadOnlyProperty) && (fe is ValueLine || fe is EntityLine || fe is EntityCombo || fe is TextArea))
            {
                Common.SetIsReadOnly(fe, isReadOnly);
            }
        }
Beispiel #41
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            var pr = JsonSerializerExtensions.CurrentPropertyRoute;

            if (pr == null || typeof(IRootEntity).IsAssignableFrom(pr.Type))
            {
                pr = PropertyRoute.Root(value.GetType());
            }
            else if (pr.Type.ElementType() == value.GetType())
            {
                pr = pr.Add("Item");
            }

            ModifiableEntity mod = (ModifiableEntity)value;

            writer.WriteStartObject();

            var entity = mod as Entity;

            if (entity != null)
            {
                writer.WritePropertyName("Type");
                writer.WriteValue(TypeLogic.TryGetCleanName(mod.GetType()));

                writer.WritePropertyName("id");
                writer.WriteValue(entity.IdOrNull == null ? null : entity.Id.Object);

                if (entity.IsNew)
                {
                    writer.WritePropertyName("isNew");
                    writer.WriteValue(true);
                }

                if (Schema.Current.Table(entity.GetType()).Ticks != null)
                {
                    writer.WritePropertyName("ticks");
                    writer.WriteValue(entity.Ticks.ToString());
                }
            }
            else
            {
                writer.WritePropertyName("Type");
                writer.WriteValue(mod.GetType().Name);
            }

            if (!(mod is MixinEntity))
            {
                writer.WritePropertyName("toStr");
                writer.WriteValue(mod.ToString());
            }

            writer.WritePropertyName("modified");
            writer.WriteValue(mod.Modified == ModifiedState.Modified || mod.Modified == ModifiedState.SelfModified);

            foreach (var kvp in PropertyConverter.GetPropertyConverters(value.GetType()))
            {
                WriteJsonProperty(writer, serializer, mod, kvp.Key, kvp.Value, pr);
            }

            if (entity != null && entity.Mixins.Any())
            {
                writer.WritePropertyName("mixins");
                writer.WriteStartObject();

                foreach (var m in entity.Mixins)
                {
                    var prm = pr.Add(m.GetType());

                    using (JsonSerializerExtensions.SetCurrentPropertyRoute(prm))
                    {
                        writer.WritePropertyName(m.GetType().Name);
                        serializer.Serialize(writer, m);
                    }
                }

                writer.WriteEndObject();
            }

            writer.WriteEndObject();
        }
Beispiel #42
0
 public static void TaskSetMove(FrameworkElement fe, string route, PropertyRoute context)
 {
     EntityListBase eb = fe as EntityListBase;
     if (eb != null && eb.NotSet(EntityListBase.MoveProperty))
     {
         if (!eb.Move  && context.FieldInfo.HasAttribute<PreserveOrderAttribute>())
         {
             eb.Move = true;
         }
     }
 }
Beispiel #43
0
        public static void TaskSetValueProperty(FrameworkElement fe, string route, PropertyRoute context)
        {
            DependencyProperty valueProperty = ValuePropertySelector.GetValue(fe.GetType());

            bool isReadOnly = context.PropertyRouteType == PropertyRouteType.FieldOrProperty && context.PropertyInfo.IsReadOnly() || 
                context.PropertyRouteType == PropertyRouteType.Mixin;

            if (!BindingOperations.IsDataBound(fe, valueProperty))
            {
                Binding b = new Binding(route)
                {
                    Mode = isReadOnly ? BindingMode.OneWay : BindingMode.TwoWay,
                    NotifyOnValidationError = true,
                    ValidatesOnExceptions = true,
                    ValidatesOnDataErrors = true,
                };
                fe.SetBinding(valueProperty, b);
            }
        }
Beispiel #44
0
 public static void RegisterPropertyFormat <T>(Expression <Func <T, object> > property, Func <Binding, DataTemplate> formatter)
     where T : IRootEntity
 {
     PropertyFormatters.Add(PropertyRoute.Construct(property), formatter);
 }
Beispiel #45
0
        public static void TaskSetLabelText(FrameworkElement fe, string route, PropertyRoute context)
        {
            DependencyProperty labelText = LabelPropertySelector.TryGetValue(fe.GetType());

            if (labelText != null && fe.NotSet(labelText))
            {
                fe.SetValue(labelText, context.PropertyInfo.NiceName());
            }
        }
Beispiel #46
0
        public static void Start(SchemaBuilder sb)
        {
            if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
            {
                sb.Include <AlbumEntity>()
                .WithExpressionFrom((IAuthorEntity au) => au.Albums())
                .WithQuery(() => a => new
                {
                    Entity = a,
                    a.Id,
                    a.Name,
                    a.Author,
                    a.Label,
                    a.Year
                });
                AlbumGraph.Register();


                sb.Include <NoteWithDateEntity>()
                .WithSave(NoteWithDateOperation.Save)
                .WithQuery(() => a => new
                {
                    Entity = a,
                    a.Id,
                    a.Text,
                    a.Target,
                    a.CreationTime,
                });

                sb.Include <ConfigEntity>()
                .WithSave(ConfigOperation.Save);

                MinimumExtensions.IncludeFunction(sb.Schema.Assets);
                sb.Include <ArtistEntity>()
                .WithSave(ArtistOperation.Save)
                .WithVirtualMList(a => a.Nominations, n => (Lite <ArtistEntity>)n.Author)
                .WithQuery(() => a => new
                {
                    Entity = a,
                    a.Id,
                    a.Name,
                    a.IsMale,
                    a.Sex,
                    a.Dead,
                    a.LastAward,
                });

                new Graph <ArtistEntity> .Execute(ArtistOperation.AssignPersonalAward)
                {
                    CanExecute = a => a.LastAward != null ? "Artist already has an award" : null,
                    Execute    = (a, para) => a.LastAward = new PersonalAwardEntity()
                    {
                        Category = "Best Artist", Year = DateTime.Now.Year, Result = AwardResult.Won
                    }.Execute(AwardOperation.Save)
                }

                .Register();

                sb.Include <BandEntity>()
                .WithQuery(() => a => new
                {
                    Entity = a,
                    a.Id,
                    a.Name,
                    a.LastAward,
                });

                new Graph <BandEntity> .Execute(BandOperation.Save)
                {
                    CanBeNew      = true,
                    CanBeModified = true,
                    Execute       = (b, _) =>
                    {
                        using (OperationLogic.AllowSave <ArtistEntity>())
                        {
                            b.Save();
                        }
                    }
                }

                .Register();

                sb.Include <LabelEntity>()
                .WithSave(LabelOperation.Save)
                .WithQuery(() => a => new
                {
                    Entity = a,
                    a.Id,
                    a.Name,
                });


                sb.Include <FolderEntity>()
                .WithQuery(() => e => new
                {
                    Entity = e,
                    e.Id,
                    e.Name
                });

                RegisterAwards(sb);

                QueryLogic.Queries.Register(typeof(IAuthorEntity), () => DynamicQueryCore.Manual(async(request, description, cancellationToken) =>
                {
                    var one = await(from a in Database.Query <ArtistEntity>()
                                    select new
                    {
                        Entity = (IAuthorEntity)a,
                        a.Id,
                        Type = "Artist",
                        a.Name,
                        Lonely    = a.Lonely(),
                        LastAward = a.LastAward
                    })
                              .ToDQueryable(description)
                              .AllQueryOperationsAsync(request, cancellationToken);

                    var two = await(from a in Database.Query <BandEntity>()
                                    select new
                    {
                        Entity = (IAuthorEntity)a,
                        a.Id,
                        Type = "Band",
                        a.Name,
                        Lonely    = a.Lonely(),
                        LastAward = a.LastAward
                    })
                              .ToDQueryable(description)
                              .AllQueryOperationsAsync(request, cancellationToken);

                    return(one.Concat(two).OrderBy(request.Orders).TryPaginate(request.Pagination));
                })
                                            .Column(a => a.LastAward, cl => cl.Implementations = Implementations.ByAll)
                                            .ColumnProperyRoutes(a => a.Id, PropertyRoute.Construct((ArtistEntity a) => a.Id), PropertyRoute.Construct((BandEntity a) => a.Id)),
                                            entityImplementations: Implementations.By(typeof(ArtistEntity), typeof(BandEntity)));

                Validator.PropertyValidator((NoteWithDateEntity n) => n.Text)
                .IsApplicableValidator <NotNullValidatorAttribute>(n => Corruption.Strict);
            }
        }
Beispiel #47
0
 static void TaskSetFormatText(FrameworkElement fe, string route, PropertyRoute context)
 {
     ValueLine vl = fe as ValueLine;
     if (vl != null && vl.NotSet(ValueLine.FormatProperty) && context.PropertyRouteType == PropertyRouteType.FieldOrProperty)
     {
         string format = Reflector.FormatString(context);
         if (format != null)
             vl.Format = format;
     }
 }
Beispiel #48
0
 public EntityLineProxy(IWebElement element, PropertyRoute route)
     : base(element, route)
 {
 }
Beispiel #49
0
        public static void TaskSetImplementations(FrameworkElement fe, string route, PropertyRoute context)
        {
            EntityBase eb = fe as EntityBase;
            if (eb != null && eb.NotSet(EntityBase.ImplementationsProperty))
            {
                PropertyRoute entityContext = eb.GetEntityPropertyRoute();

                if (entityContext != null && entityContext.Type.CleanType().IsIEntity())
                {
                    eb.Implementations = entityContext.GetImplementations();
                }
            }
        }
Beispiel #50
0
 static PropertyRoute ToPropertyRouteImplementation(PropertyRouteEntity route)
 {
     return(PropertyRoute.Parse(TypeLogic.EntityToType.GetOrThrow(route.RootType), route.Path));
 }
Beispiel #51
0
 static void TaskSetCollaspeIfNull(FrameworkElement fe, string route, PropertyRoute context)
 {
     if (GetCollapseIfNull(fe) && fe.NotSet(UIElement.VisibilityProperty))
     {
         Binding b = new Binding(route)
         {
             Mode = BindingMode.OneWay,
             Converter = Converters.NullToVisibility,
         };
         
         fe.SetBinding(FrameworkElement.VisibilityProperty, b);
     }
 }
Beispiel #52
0
 public static bool IsPropertyRoute(this PropertyRouteEntity prdn, PropertyRoute pr)
 {
     return(IsPropertyRouteExpression.Evaluate(prdn, pr));
 }
Beispiel #53
0
 static void TaskSetNullValueEntityCombo(FrameworkElement fe, string route, PropertyRoute context)
 {
     EntityCombo ec = fe as EntityCombo;
     if (ec != null && ec.NotSet(EntityCombo.NullValueProperty) && context.PropertyRouteType == PropertyRouteType.FieldOrProperty)
     {
         if (Validator.TryGetPropertyValidator(context).Let(pv => pv != null && pv.Validators.OfType<NotNullValidatorAttribute>().Any()))
         {
             ec.NullValue = false;
         }
     }
 }
Beispiel #54
0
 public LineContainer(RemoteWebDriver selenium, string prefix = null, PropertyRoute route = null)
 {
     this.Selenium = selenium;
     this.Prefix   = prefix;
     this.Route    = route == null || route.IsImplementation(typeof(T)) ? PropertyRoute.Root(typeof(T)) : route;
 }
Beispiel #55
0
 static void TaskSetAutomationName(FrameworkElement fe, string route, PropertyRoute context)
 {
     if (fe.NotSet(AutomationProperties.NameProperty))
     {
         AutomationProperties.SetName(fe, context?.ToString() ?? "");
     }
 }
Beispiel #56
0
 public NormalPage(RemoteWebDriver selenium, string prefix = null)
 {
     this.Selenium = selenium;
     this.Prefix   = prefix;
     this.Route    = PropertyRoute.Root(typeof(T));
 }
Beispiel #57
0
 public EntityListDetail(Type type, object untypedValue, Context parent, string prefix, PropertyRoute propertyRoute)
     : base(type, untypedValue, parent, prefix, propertyRoute)
 {
     DetailDiv = this.Compose(EntityBaseKeys.Detail);
     Move = false;
 }
Beispiel #58
0
 public FieldReference(PropertyRoute route, Type fieldType = null) : base(route, fieldType)
 {
 }
 public static bool IsPropertyRoute(this PropertyRouteEntity prdn, PropertyRoute pr)
 {
     return IsPropertyRouteExpression.Evaluate(prdn, pr);
 }
Beispiel #60
0
 public FieldEnum(PropertyRoute route) : base(route)
 {
 }