-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Source Imported CodeSmith.Data for now
- Loading branch information
Showing
204 changed files
with
27,824 additions
and
0 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
Templates/Frameworks/PLINQO-EF/Source/CodeSmith.Data/Attributes/GuidAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using CodeSmith.Data.Rules; | ||
using CodeSmith.Data.Rules.Assign; | ||
|
||
namespace CodeSmith.Data.Attributes | ||
{ | ||
/// <summary> | ||
/// Assigns a new GUID to the property for the specified entity states. | ||
/// </summary> | ||
/// <example> | ||
/// <para>Add rule using the Metadata class and attribute.</para> | ||
/// <code><![CDATA[ | ||
/// private class Metadata | ||
/// { | ||
/// // fragment of the metadata class | ||
/// | ||
/// [Guid(EntityState.New)] | ||
/// public Guid UserId { get; set; } | ||
/// } | ||
/// ]]></code> | ||
/// </example> | ||
/// <seealso cref="T:CodeSmith.Data.Rules.Assign.GuidRule"/> | ||
public class GuidAttribute : RuleAttributeBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="GuidAttribute"/> class. | ||
/// </summary> | ||
public GuidAttribute() | ||
{} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="GuidAttribute"/> class. | ||
/// </summary> | ||
/// <param name="state">State of the object that can be assigned.</param> | ||
public GuidAttribute(EntityState state) | ||
{ | ||
State = state; | ||
} | ||
|
||
/// <summary> | ||
/// Creates the rule. | ||
/// </summary> | ||
/// <param name="property">The property name this rule applies to.</param> | ||
/// <returns>A new instance of the rule.</returns> | ||
public override IRule CreateRule(string property) | ||
{ | ||
return new GuidRule(property, State); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether the specified value of the object is valid. | ||
/// </summary> | ||
/// <param name="value">The value of the specified validation object on which the <see cref="T:System.ComponentModel.DataAnnotations.ValidationAttribute"/> is declared.</param> | ||
/// <returns> | ||
/// true if the specified value is valid; otherwise, false. | ||
/// </returns> | ||
public override bool IsValid(object value) | ||
{ | ||
return true; | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
Templates/Frameworks/PLINQO-EF/Source/CodeSmith.Data/Attributes/IpAddressAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using CodeSmith.Data.Rules; | ||
using CodeSmith.Data.Rules.Assign; | ||
|
||
namespace CodeSmith.Data.Attributes | ||
{ | ||
/// <summary> | ||
/// Assigns the current user's IP address to the property for the specified entity states. | ||
/// </summary> | ||
/// <example> | ||
/// <para>Add rule using the Metadata class and attribute.</para> | ||
/// <code><![CDATA[ | ||
/// private class Metadata | ||
/// { | ||
/// // fragment of the metadata class | ||
/// | ||
/// [IpAddress(EntityState.Dirty)] | ||
/// public string IpAddress { get; set; } | ||
/// } | ||
/// ]]></code> | ||
/// </example> | ||
/// <seealso cref="T:CodeSmith.Data.Rules.Assign.IpAddressRule"/> | ||
public class IpAddressAttribute : RuleAttributeBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="IpAddressAttribute"/> class. | ||
/// </summary> | ||
public IpAddressAttribute() | ||
{} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="IpAddressAttribute"/> class. | ||
/// </summary> | ||
/// <param name="state">State of the object that can be assigned.</param> | ||
public IpAddressAttribute(EntityState state) | ||
{ | ||
State = state; | ||
} | ||
|
||
/// <summary> | ||
/// Creates the rule. | ||
/// </summary> | ||
/// <param name="property">The property name this rule applies to.</param> | ||
/// <returns>A new instance of the rule.</returns> | ||
public override IRule CreateRule(string property) | ||
{ | ||
return new IpAddressRule(property, State); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether the specified value of the object is valid. | ||
/// </summary> | ||
/// <param name="value">The value of the specified validation object on which the <see cref="T:System.ComponentModel.DataAnnotations.ValidationAttribute"/> is declared.</param> | ||
/// <returns> | ||
/// true if the specified value is valid; otherwise, false. | ||
/// </returns> | ||
public override bool IsValid(object value) | ||
{ | ||
return true; | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Templates/Frameworks/PLINQO-EF/Source/CodeSmith.Data/Attributes/NotNullAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using CodeSmith.Data.Rules; | ||
using CodeSmith.Data.Rules.Validation; | ||
|
||
namespace CodeSmith.Data.Attributes | ||
{ | ||
public class NotNullAttribute : RuleAttributeBase | ||
{ | ||
public NotNullAttribute() | ||
: this(EntityState.Dirty) | ||
{ } | ||
|
||
public NotNullAttribute(EntityState state) | ||
{ | ||
State = state; | ||
} | ||
|
||
public override bool IsValid(object value) | ||
{ | ||
return value != null; | ||
} | ||
|
||
public override IRule CreateRule(string property) | ||
{ | ||
return new NotNullRule(property); | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
Templates/Frameworks/PLINQO-EF/Source/CodeSmith.Data/Attributes/NowAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using CodeSmith.Data.Rules; | ||
using CodeSmith.Data.Rules.Assign; | ||
|
||
namespace CodeSmith.Data.Attributes | ||
{ | ||
/// <summary> | ||
/// Assigns the current date / time to the property for the specified entity states. | ||
/// </summary> | ||
/// <example> | ||
/// <para>Add rule using the Metadata class and attribute.</para> | ||
/// <code><![CDATA[ | ||
/// private class Metadata | ||
/// { | ||
/// // fragment of the metadata class | ||
/// | ||
/// [Now(EntityState.New)] | ||
/// public DateTime CreatedDate { get; set; } | ||
/// | ||
/// [Now(EntityState.Dirty)] | ||
/// public DateTime ModifiedDate { get; set; } | ||
/// } | ||
/// ]]></code> | ||
/// </example> | ||
/// <seealso cref="T:CodeSmith.Data.Rules.Assign.NowRule"/> | ||
public class NowAttribute : RuleAttributeBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NowAttribute"/> class. | ||
/// </summary> | ||
public NowAttribute() | ||
: this(EntityState.Dirty, NowTimeZone.Local) | ||
{ } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NowAttribute"/> class. | ||
/// </summary> | ||
/// <param name="state">State of the object that can be assigned.</param> | ||
public NowAttribute(EntityState state) | ||
: this(state, NowTimeZone.Local) | ||
{ } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="NowAttribute"/> class. | ||
/// </summary> | ||
/// <param name="state">State of the object that can be assigned.</param> | ||
/// <param name="timeZone">The time zone.</param> | ||
public NowAttribute(EntityState state, NowTimeZone timeZone) | ||
{ | ||
State = state; | ||
TimeZone = timeZone; | ||
} | ||
|
||
|
||
public NowTimeZone TimeZone { get; set; } | ||
|
||
/// <summary> | ||
/// Creates the rule. | ||
/// </summary> | ||
/// <param name="property">The property name this rule applies to.</param> | ||
/// <returns>A new instance of the rule.</returns> | ||
public override IRule CreateRule(string property) | ||
{ | ||
return new NowRule(property, State, TimeZone); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether the specified value of the object is valid. | ||
/// </summary> | ||
/// <param name="value">The value of the specified validation object on which the <see cref="T:System.ComponentModel.DataAnnotations.ValidationAttribute"/> is declared.</param> | ||
/// <returns> | ||
/// true if the specified value is valid; otherwise, false. | ||
/// </returns> | ||
public override bool IsValid(object value) | ||
{ | ||
return true; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Templates/Frameworks/PLINQO-EF/Source/CodeSmith.Data/Attributes/RuleAttributeBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using CodeSmith.Data.Rules; | ||
|
||
namespace CodeSmith.Data.Attributes | ||
{ | ||
/// <summary> | ||
/// A base class for rule attributes. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] | ||
public abstract class RuleAttributeBase : ValidationAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RuleAttributeBase"/> class. | ||
/// </summary> | ||
protected RuleAttributeBase() | ||
{ | ||
State = EntityState.Dirty; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the state. | ||
/// </summary> | ||
/// <value>The state of the object that the rule can run on.</value> | ||
public EntityState State { get; protected set; } | ||
|
||
/// <summary> | ||
/// Creates the rule. | ||
/// </summary> | ||
/// <param name="property">The property name this rule applies to.</param> | ||
/// <returns>A new instance of the rule.</returns> | ||
public abstract IRule CreateRule(string property); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
Templates/Frameworks/PLINQO-EF/Source/CodeSmith.Data/Attributes/UserNameAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using CodeSmith.Data.Rules; | ||
using CodeSmith.Data.Rules.Assign; | ||
|
||
namespace CodeSmith.Data.Attributes | ||
{ | ||
/// <summary> | ||
/// Assigns the current users name to the property for the specified entity states. | ||
/// </summary> | ||
/// <example> | ||
/// <para>Add rule using the Metadata class and attribute.</para> | ||
/// <code><![CDATA[ | ||
/// private class Metadata | ||
/// { | ||
/// // fragment of the metadata class | ||
/// | ||
/// [UserName(EntityState.New)] | ||
/// public string CreatedBy { get; set; } | ||
/// | ||
/// [UserName(EntityState.Dirty)] | ||
/// public string ModifiedBy { get; set; } | ||
/// } | ||
/// ]]></code> | ||
/// </example> | ||
/// <seealso cref="T:CodeSmith.Data.Rules.Assign.UserNameRule"/> | ||
public class UserNameAttribute : RuleAttributeBase | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="UserNameAttribute"/> class. | ||
/// </summary> | ||
public UserNameAttribute() | ||
{} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="UserNameAttribute"/> class. | ||
/// </summary> | ||
/// <param name="state">State of the object that can be assigned.</param> | ||
public UserNameAttribute(EntityState state) | ||
{ | ||
State = state; | ||
} | ||
|
||
/// <summary> | ||
/// Creates the rule. | ||
/// </summary> | ||
/// <param name="property">The property name this rule applies to.</param> | ||
/// <returns>A new instance of the rule.</returns> | ||
public override IRule CreateRule(string property) | ||
{ | ||
return new UserNameRule(property, State); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether the specified value of the object is valid. | ||
/// </summary> | ||
/// <param name="value">The value of the specified validation object on which the <see cref="T:System.ComponentModel.DataAnnotations.ValidationAttribute"/> is declared.</param> | ||
/// <returns> | ||
/// true if the specified value is valid; otherwise, false. | ||
/// </returns> | ||
public override bool IsValid(object value) | ||
{ | ||
return true; | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Templates/Frameworks/PLINQO-EF/Source/CodeSmith.Data/Audit/AlwaysAuditAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace CodeSmith.Data.Audit | ||
{ | ||
/// <summary> | ||
/// Indicates that a field in an audited class should always be included in the audit data even if it hasn't been changed. | ||
/// </summary> | ||
/// <seealso cref="AuditAttribute"/> | ||
/// <seealso cref="NotAuditedAttribute"/> | ||
/// <seealso cref="AuditManager"/> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] | ||
public class AlwaysAuditAttribute : Attribute | ||
{ } | ||
} |
Oops, something went wrong.