Exemplo n.º 1
0
 public Convention()
 {
     Classes = new ClassFilter().Where(type => !type.IsSubclassOf(typeof(Convention)));
     Cases = new MethodFilter().Where(m => !m.IsDispose());
     CaseExecution = new CaseBehaviorBuilder();
     InstanceExecution = new InstanceBehaviorBuilder();
     ClassExecution = new TypeBehaviorBuilder().CreateInstancePerCase();
 }
Exemplo n.º 2
0
        public Convention()
        {
            Classes = new ClassFilter().Where(type => !type.IsSubclassOf(typeof(Convention)));
            Methods = new MethodFilter().Where(m => !m.IsDispose());
            CaseExecution = new CaseBehaviorBuilder();
            InstanceExecution = new InstanceBehaviorBuilder();
            ClassExecution = new TypeBehaviorBuilder().CreateInstancePerCase();

            methodCallParameterBuilder = method => new object[][] { };
        }
Exemplo n.º 3
0
 public virtual void AppendFilter(StringBuilder builder, DataAspect aspect, ClassFilter filter)
 {
     if (filter is ClassFilterTerm)
         AppendFilterTerm(builder, aspect, (ClassFilterTerm)filter);
     else if (filter is ClassFilterNode)
         AppendFilterNodes(builder, aspect, (ClassFilterNode)filter);
     else if (filter is ClassFilterExpression)
         AppendFilterExpression(builder, aspect, (ClassFilterExpression)filter);
     else
         throw new ArgumentException("Unknown filter type: " + filter.GetType(), "filter");
 }
Exemplo n.º 4
0
        public override DatabaseCommand CreateSelect(DataAspect aspect, ClassFilter filter, ClassSort sort, int pageSize, int pageOrdinal)
        {
            StringBuilder builder = new StringBuilder(255);
            int count = aspect.Count;

            builder.Append("SELECT ");
            if (pageSize > 0 && pageOrdinal >= 0)
            {
                builder.Append("TOP ");
                builder.Append((pageOrdinal + 1) * pageSize);
                builder.Append(' ');
            }

            AppendName(builder, aspect[0].StoredName);
            for (int i = 1; i < count; i++)
            {
                builder.Append(", ");
                AppendName(builder, aspect[i].StoredName);
            }
            builder.Append(" FROM ");
            AppendName(builder, aspect.StoredName);
            if (filter != null)
            {
                builder.Append(" WHERE ");
                AppendFilter(builder, aspect, filter);
            }
            if (sort != null)
            {
                builder.Append(" ORDER BY ");
                AppendSort(builder, aspect, sort);
            }
            return new DatabaseCommand(
                CommandType.Text,
                builder.ToString(),
                null);
        }
Exemplo n.º 5
0
        public virtual DatabaseCommand CreateUpdate(DataAspect aspect, IEnumerable<AspectMemberValue> values, ClassFilter filter)
        {
            StringBuilder builder = new StringBuilder(512);
            builder.Append("UPDATE ");
            AppendName(builder, aspect.StoredName);
            builder.Append(" SET ");
            bool prependComma = false;
            foreach (AspectMemberValue value in values)
            {
                if (!value.Member.HasAttribute<NonUpdateable>(false))
                {
                    if (prependComma)
                        builder.Append(", ");
                    else
                        prependComma = true;

                    AppendName(builder, aspect[value.Ordinal].StoredName);
                    builder.Append(" = ");
                    AppendValue(builder, value.Value);
                }
            }
            if (filter != null)
            {
                builder.Append(" WHERE ");
                AppendFilter(builder, aspect, filter);
            }
            return new DatabaseCommand(
                CommandType.Text,
                builder.ToString(),
                null);
        }
Exemplo n.º 6
0
        public virtual DatabaseCommand CreateSelectMember(DataAspect aspect, int ordinal, ClassFilter filter, ClassSort sort, int pageSize, int pageOrdinal)
        {
            StringBuilder builder = new StringBuilder(255);
            int count = aspect.Count;

            builder.Append("SELECT ");
            AppendName(builder, aspect[ordinal].StoredName);
            builder.Append(" FROM ");
            AppendName(builder, aspect.StoredName);
            if (filter != null)
            {
                builder.Append(" WHERE ");
                AppendFilter(builder, aspect, filter);
            }
            if (sort != null)
            {
                builder.Append(" ORDER BY ");
                AppendSort(builder, aspect, sort);
            }
            return new DatabaseCommand(
                CommandType.Text,
                builder.ToString(),
                null);
        }
Exemplo n.º 7
0
        public virtual DatabaseCommand CreateSelectExists(DataAspect aspect, ClassFilter filter)
        {
            StringBuilder builder = new StringBuilder(255);
            int count = aspect.Count;

            builder.Append("SELECT 1 WHERE EXISTS (SELECT * FROM ");
            AppendName(builder, aspect.StoredName);
            if (filter != null)
            {
                builder.Append(" WHERE ");
                AppendFilter(builder, aspect, filter);
            }
            builder.Append(")");
            return new DatabaseCommand(
                CommandType.Text,
                builder.ToString(),
                null);
        }
Exemplo n.º 8
0
 public virtual DatabaseCommand CreateDelete(DataAspect aspect, ClassFilter filter)
 {
     StringBuilder builder = new StringBuilder(255);
     builder.Append("DELETE FROM ");
     AppendName(builder, aspect.StoredName);
     if (filter != null)
     {
         builder.Append(" WHERE ");
         AppendFilter(builder, aspect, filter);
     }
     return new DatabaseCommand(
         CommandType.Text,
         builder.ToString(),
         null);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Appends a filter with an OR operation.
 /// </summary>
 /// <param name="filter">The filter to append.</param>
 /// <returns>The T.</returns>
 public ClassUpdate Or(ClassFilter filter)
 {
     this._WhereLast = this._WhereLast.SetNext(FilterOperation.Or, filter);
     return(this);
 }