예제 #1
0
        protected internal virtual ExtensionToken CreateToken(QueryToken parent)
        {
            var info = metas.GetOrAdd(parent, qt =>
            {
                Expression e = MetadataVisitor.JustVisit(Lambda, MetaExpression.FromToken(qt, SourceType));

                MetaExpression?me;

                if (this.IsProjection)
                {
                    var mpe = e as MetaProjectorExpression;

                    if (mpe == null)
                    {
                        mpe = MetadataVisitor.AsProjection(e);
                    }

                    me = mpe == null ? null : mpe.Projector as MetaExpression;
                }
                else
                {
                    me = e as MetaExpression;
                }

                var result = new ExtensionRouteInfo();

                if (me != null && me.Meta is CleanMeta cleanMeta && cleanMeta.PropertyRoutes.Any())
                {
                    result.PropertyRoute   = cleanMeta.PropertyRoutes.Only();
                    result.Implementations = me.Meta.Implementations;
                    result.Format          = ColumnDescriptionFactory.GetFormat(cleanMeta.PropertyRoutes);
                    result.Unit            = ColumnDescriptionFactory.GetUnit(cleanMeta.PropertyRoutes);
                }
예제 #2
0
    public IEnumerable <QueryToken> GetAllTokens(QueryToken parent)
    {
        var info = metas.GetOrAdd(parent, qt =>
        {
            Expression <Func <T, V> > lambda = t => ValueSelector.Evaluate(CollectionSelector.Evaluate(t).SingleOrDefaultEx() !);

            Expression e = MetadataVisitor.JustVisit(lambda, MetaExpression.FromToken(qt, typeof(T)));

            var result = new ExtensionRouteInfo();

            if (e is MetaExpression me && me.Meta is CleanMeta cm && cm.PropertyRoutes.Any())
            {
                var cleanType = me !.Type.CleanType();

                result.PropertyRoute   = cm.PropertyRoutes.Only();
                result.Implementations = me.Meta.Implementations;
                result.Format          = ColumnDescriptionFactory.GetFormat(cm.PropertyRoutes);
                result.Unit            = ColumnDescriptionFactory.GetUnit(cm.PropertyRoutes);
            }

            return(result);
        });
예제 #3
0
        protected internal virtual ExtensionToken CreateToken(QueryToken parent)
        {
            var info = metas.GetOrAdd(parent, qt =>
            {
                Expression e = MetadataVisitor.JustVisit(Lambda, MetaExpression.FromToken(qt, SourceType));

                MetaExpression me;

                if (this.IsProjection)
                {
                    var mpe = e as MetaProjectorExpression;

                    if (mpe == null)
                    {
                        mpe = MetadataVisitor.AsProjection(e);
                    }

                    me = mpe == null ? null : mpe.Projector as MetaExpression;
                }
                else
                {
                    me = e as MetaExpression;
                }

                var result = new ExtensionRouteInfo();

                if (me?.Meta is CleanMeta cm && cm.PropertyRoutes.Any())
                {
                    var cleanType = me.Type.CleanType();

                    result.PropertyRoute   = cm.PropertyRoutes.Only();
                    result.Implementations = me.Meta.Implementations;
                    result.Format          = ColumnDescriptionFactory.GetFormat(cm.PropertyRoutes);
                    result.Unit            = ColumnDescriptionFactory.GetUnit(cm.PropertyRoutes);
                }

                result.IsAllowed = () => (me == null || me.Meta == null) ? null : me.Meta.IsAllowed();

                if (ForcePropertyRoute != null)
                {
                    result.PropertyRoute = ForcePropertyRoute;
                }

                if (ForceImplementations != null)
                {
                    result.Implementations = ForceImplementations;
                }

                if (ForceFormat != null)
                {
                    result.Format = ForceFormat;
                }

                if (ForceUnit != null)
                {
                    result.Unit = ForceUnit;
                }

                if (ForceIsAllowed != null)
                {
                    result.IsAllowed = ForceIsAllowed;
                }

                return(result);
            });