Skip to content
This repository has been archived by the owner on Dec 23, 2017. It is now read-only.

Commit

Permalink
Various small tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovan Crone committed Jun 19, 2014
1 parent 71c30a6 commit 983f68e
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/Susanoo/ColumnBindingException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ColumnBindingException(string message, int errorCode)
/// </summary>
/// <param name="info">The object that holds the serialized object data.</param>
/// <param name="context">The contextual information about the source or destination.</param>
public ColumnBindingException(SerializationInfo info, StreamingContext context)
protected ColumnBindingException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
}
}
12 changes: 6 additions & 6 deletions src/Susanoo/CommandExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;

namespace Susanoo
{
Expand All @@ -17,12 +16,14 @@ public class CommandExpression<TFilter, TResult>
where TResult : new()
{
private readonly IDictionary<string, Action<IDbDataParameter>> parameterInclusions = new Dictionary<string, Action<IDbDataParameter>>();
private readonly List<IDbDataParameter> explicitParameters = new List<IDbDataParameter>();
private readonly List<IDbDataParameter> constantParameters = new List<IDbDataParameter>();

/// <summary>
/// Initializes a new instance of the <see cref="CommandExpression{TFilter, TResult}"/> class.
/// Initializes a new instance of the <see cref="CommandExpression{TFilter, TResult}" /> class.
/// </summary>
/// <param name="databaseManager">The database manager.</param>
/// <param name="commandText">The command text.</param>
/// <param name="commandType">Type of the command.</param>
public CommandExpression(IDatabaseManager databaseManager, string commandText, CommandType commandType)
{
this.DatabaseManager = databaseManager;
Expand Down Expand Up @@ -58,7 +59,6 @@ public virtual ICommandExpression<TFilter, TResult> IncludeProperty(Expression<F
return IncludeProperty(propertyExpression, null);
}


/// <summary>
/// Includes a property of the filter or modifies its inclusion.
/// </summary>
Expand Down Expand Up @@ -101,7 +101,7 @@ public virtual ICommandExpression<TFilter, TResult> IncludeProperty(string prope
/// <returns>ICommandExpression&lt;T&gt;.</returns>
public virtual ICommandExpression<TFilter, TResult> AddConstantParameters(params IDbDataParameter[] parameters)
{
this.explicitParameters.AddRange(parameters);
this.constantParameters.AddRange(parameters);

return this;
}
Expand Down Expand Up @@ -148,7 +148,7 @@ public virtual IEnumerable<IDbDataParameter> BuildParameters(TFilter filter, par
{
List<IDbDataParameter> parameters = BuildPropertyParameters(filter).ToList();

parameters.AddRange(this.explicitParameters);
parameters.AddRange(this.constantParameters);
parameters.AddRange(explicitParameters);

return parameters;
Expand Down
4 changes: 0 additions & 4 deletions src/Susanoo/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ public AssemblyBuilder ExpressionAssembly
{
return _expressionAssembly;
}
private set
{
_expressionAssembly = value;
}
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion src/Susanoo/CommandProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Globalization;

namespace Susanoo
{
Expand Down Expand Up @@ -60,6 +60,7 @@ public CommandProcessor(CommandResultMappingExpression<TFilter, TResult> mapping
/// Assembles a data command for an ADO.NET provider, executes the command and uses pre-compiled mappings to assign the resultant data to the result object type.
/// </summary>
/// <param name="filter">The filter.</param>
/// <param name="explicitParameters">The explicit parameters.</param>
/// <returns>IEnumerable&lt;TResult&gt;.</returns>
public virtual IEnumerable<TResult> Execute(TFilter filter, params IDbDataParameter[] explicitParameters)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Susanoo/CommandResultMappingExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
using System.Threading;

namespace Susanoo
{
Expand Down Expand Up @@ -48,7 +47,7 @@ public virtual ICommandResultMappingExpression<TFilter, TResult> ClearMappings()
/// <summary>
/// Mapping options for a property in the result model.
/// </summary>
/// <param name="property">The property.</param>
/// <param name="propertyExpression">The property expression.</param>
/// <param name="options">The options.</param>
/// <returns>ICommandResultMappingExpression&lt;TFilter, TResult&gt;.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
Expand Down
23 changes: 14 additions & 9 deletions src/Susanoo/ComponentModelMetadataExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public class ComponentModelMetadataExtractor : IPropertyMetadataExtractor
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]
public Dictionary<PropertyInfo, PropertyMap> FindAllowedProperties(
Type objectType,
Susanoo.DescriptorActions actions = Susanoo.DescriptorActions.Read
| Susanoo.DescriptorActions.Update
Susanoo.DescriptorActions actions = Susanoo.DescriptorActions.Read
| Susanoo.DescriptorActions.Update
| Susanoo.DescriptorActions.Insert,
string[] whitelist = null,
string[] blacklist = null)
{
if (objectType == null)
throw new ArgumentNullException("filterType");
throw new ArgumentNullException("objectType");

Contract.EndContractBlock();

Expand All @@ -56,9 +56,14 @@ public Dictionary<PropertyInfo, PropertyMap> FindAllowedProperties(
/// <returns>System.String.</returns>
public virtual string ResolveAlias(PropertyInfo propertyInfo, object[] customAttributes)
{
ColumnAttribute column = customAttributes
if (propertyInfo == null)
throw new ArgumentNullException("propertyInfo");

Contract.EndContractBlock();

ColumnAttribute column = customAttributes != null ? customAttributes
.OfType<ColumnAttribute>()
.FirstOrDefault();
.FirstOrDefault() : null;

return column != null && !string.IsNullOrWhiteSpace(column.Name) ? column.Name : propertyInfo.Name;
}
Expand Down Expand Up @@ -114,8 +119,8 @@ public bool IsBlacklisted(PropertyInfo propertyInfo, string[] blacklist)
public virtual bool IsActionableProperty(
PropertyInfo propertyInfo,
object[] customAttributes,
Susanoo.DescriptorActions actions = Susanoo.DescriptorActions.Read
| Susanoo.DescriptorActions.Update
Susanoo.DescriptorActions actions = Susanoo.DescriptorActions.Read
| Susanoo.DescriptorActions.Update
| Susanoo.DescriptorActions.Insert,
string[] whitelist = null,
string[] blacklist = null)
Expand Down Expand Up @@ -148,8 +153,8 @@ public virtual bool IsActionableProperty(
public virtual bool IsAllowedByAttribute(
PropertyInfo propertyInfo,
AllowedActionsAttribute attribute,
Susanoo.DescriptorActions actions = Susanoo.DescriptorActions.Read
| Susanoo.DescriptorActions.Update
Susanoo.DescriptorActions actions = Susanoo.DescriptorActions.Read
| Susanoo.DescriptorActions.Update
| Susanoo.DescriptorActions.Insert)
{
return attribute == null || attribute.Actions == actions;
Expand Down
Binary file added src/Susanoo/GlobalSuppressions.cs
Binary file not shown.
16 changes: 1 addition & 15 deletions src/Susanoo/IDatabaseManager.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
// ***********************************************************************
// Assembly : Susanoo.Core
// Author : Donovan Crone
// Created : 05-15-2014
//
// Last Modified By : Donovan Crone
// Last Modified On : 05-15-2014
// ***********************************************************************
// <copyright file="IDatabaseManager.cs" company="Psibernetic Solutions, LLC">
// Copyright (c) Psibernetic Solutions, LLC. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Data;
using System.Data;

namespace Susanoo
{
Expand Down
4 changes: 2 additions & 2 deletions src/Susanoo/IPropertyMappingConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public interface IPropertyMappingConfiguration<TRecord>
/// <summary>
/// Assembles the mapping expression.
/// </summary>
/// <param name="property">The property.</param>
/// <param name="propertyExpression">The property.</param>
/// <returns>Expression&lt;Action&lt;IDataRecord&gt;&gt;.</returns>
Expression<Action<IDataRecord>> AssembleMappingExpression(MemberExpression property);
Expression<Action<IDataRecord>> AssembleMappingExpression(MemberExpression propertyExpression);
}
}
1 change: 1 addition & 0 deletions src/Susanoo/Susanoo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<Compile Include="CommandResultMappingExpression.cs" />
<Compile Include="DatabaseManager.cs" />
<Compile Include="ExpressionExtensions.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Properties\GlobalSuppressions.cs" />
<Compile Include="ICommandResultMappingExpression.cs" />
<Compile Include="ICommandExpression.cs" />
Expand Down

0 comments on commit 983f68e

Please sign in to comment.