mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
added marr.datamapper source code for easy debugging.
This commit is contained in:
parent
58a05fcef8
commit
3cdff3bb71
96 changed files with 9198 additions and 363 deletions
85
Marr.Data/Mapping/Strategies/PropertyMapStrategy.cs
Normal file
85
Marr.Data/Mapping/Strategies/PropertyMapStrategy.cs
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* Copyright (C) 2008 - 2011 Jordan Marr
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Marr.Data.Mapping.Strategies
|
||||
{
|
||||
/// <summary>
|
||||
/// Maps all public properties to DB columns.
|
||||
/// </summary>
|
||||
public class PropertyMapStrategy : AttributeMapStrategy
|
||||
{
|
||||
public PropertyMapStrategy(bool publicOnly)
|
||||
: base(publicOnly)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Maps properties to DB columns if a ColumnAttribute is not present.
|
||||
/// <param name="entityType">The entity that is being mapped.</param>
|
||||
/// <param name="member">The current member that is being inspected.</param>
|
||||
/// <param name="columnAtt">A ColumnAttribute (is null of one does not exist).</param>
|
||||
/// <param name="columnMaps">A list of ColumnMaps.</param>
|
||||
/// </summary>
|
||||
protected override void CreateColumnMap(Type entityType, MemberInfo member, ColumnAttribute columnAtt, ColumnMapCollection columnMaps)
|
||||
{
|
||||
if (columnAtt != null)
|
||||
{
|
||||
// Add columns with ColumnAttribute
|
||||
base.CreateColumnMap(entityType, member, columnAtt, columnMaps);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (member.MemberType == MemberTypes.Property)
|
||||
{
|
||||
// Map public property to DB column
|
||||
columnMaps.Add(new ColumnMap(member));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps a relationship if a RelationshipAttribute is present.
|
||||
/// </summary>
|
||||
/// <param name="entityType">The entity that is being mapped.</param>
|
||||
/// <param name="member">The current member that is being inspected.</param>
|
||||
/// <param name="relationshipAtt">A RelationshipAttribute (is null if one does not exist).</param>
|
||||
/// <param name="relationships">A list of Relationships.</param>
|
||||
protected override void CreateRelationship(Type entityType, MemberInfo member, RelationshipAttribute relationshipAtt, RelationshipCollection relationships)
|
||||
{
|
||||
if (relationshipAtt != null)
|
||||
{
|
||||
// Add relationships by RelationshipAttribute
|
||||
base.CreateRelationship(entityType, member, relationshipAtt, relationships);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (member.MemberType == MemberTypes.Property)
|
||||
{
|
||||
PropertyInfo propertyInfo = member as PropertyInfo;
|
||||
if (typeof(System.Collections.ICollection).IsAssignableFrom(propertyInfo.PropertyType))
|
||||
{
|
||||
Relationship relationship = new Relationship(member);
|
||||
relationships.Add(relationship);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue