-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved annotations and linq expressions projects to the utilities solu…
…tion. (#45)
- Loading branch information
Showing
58 changed files
with
2,818 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
40 changes: 40 additions & 0 deletions
40
src/Fluxera.ComponentModel.Annotations/CompositeIndexAttribute.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,40 @@ | ||
namespace Fluxera.ComponentModel.Annotations | ||
{ | ||
using System; | ||
using JetBrains.Annotations; | ||
|
||
/// <summary> | ||
/// An attribute to provide the composite indices of an entity. <br /> | ||
/// To create the actual indices consult the underlying stores documentation. | ||
/// </summary> | ||
/// <seealso cref="Attribute" /> | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] | ||
public sealed class CompositeIndexAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of the <see cref="CompositeIndexAttribute" /> type. | ||
/// </summary> | ||
/// <param name="propertyNames"></param> | ||
public CompositeIndexAttribute(params string[] propertyNames) | ||
{ | ||
this.PropertyNames = propertyNames; | ||
this.IsUnique = false; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the property names for the index. | ||
/// </summary> | ||
public string[] PropertyNames { get; } | ||
|
||
/// <summary> | ||
/// Flag, indicating if the index is unique. | ||
/// </summary> | ||
public bool IsUnique { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the ordering for the index. | ||
/// </summary> | ||
public IndexOrder Order { get; set; } = IndexOrder.Ascending; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/Fluxera.ComponentModel.Annotations/ContainsAttribute.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,44 @@ | ||
namespace Fluxera.ComponentModel.Annotations | ||
{ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using Fluxera.Guards; | ||
using JetBrains.Annotations; | ||
|
||
/// <summary> | ||
/// A validation that checks if the annotated property contains the given check value. | ||
/// </summary> | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] | ||
public sealed class ContainsAttribute : ValidationAttribute | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of the <see cref="ContainsAttribute" /> type. | ||
/// </summary> | ||
/// <param name="part"></param> | ||
public ContainsAttribute(string part) | ||
{ | ||
Guard.Against.NullOrEmpty(part, nameof(part)); | ||
|
||
this.Part = part; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the string that should be contained in the property value. | ||
/// </summary> | ||
public string Part { get; } | ||
|
||
|
||
/// <inheritdoc /> | ||
public override bool IsValid(object value) | ||
{ | ||
if(value is string stringValue) | ||
{ | ||
bool contains = !string.IsNullOrWhiteSpace(stringValue) && stringValue.Contains(this.Part); | ||
return contains; | ||
} | ||
|
||
throw new InvalidOperationException("The attribute can only be used with string properties."); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/Fluxera.ComponentModel.Annotations/CurrencyAttribute.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,19 @@ | ||
// ReSharper disable once CheckNamespace | ||
|
||
namespace System.ComponentModel.DataAnnotations | ||
{ | ||
using JetBrains.Annotations; | ||
|
||
/// <summary> | ||
/// A data-type attribute for currency values. | ||
/// </summary> | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)] | ||
public sealed class CurrencyAttribute : DataTypeAttribute | ||
{ | ||
/// <inheritdoc /> | ||
public CurrencyAttribute() : base(DataType.Currency) | ||
{ | ||
} | ||
} | ||
} |
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,19 @@ | ||
// ReSharper disable once CheckNamespace | ||
|
||
namespace System.ComponentModel.DataAnnotations | ||
{ | ||
using JetBrains.Annotations; | ||
|
||
/// <summary> | ||
/// A data-type attribute for date values. | ||
/// </summary> | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)] | ||
public sealed class DateAttribute : DataTypeAttribute | ||
{ | ||
/// <inheritdoc /> | ||
public DateAttribute() : base(DataType.Date) | ||
{ | ||
} | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
src/Fluxera.ComponentModel.Annotations/DatePrecisionAttribute.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,27 @@ | ||
namespace Fluxera.ComponentModel.Annotations | ||
{ | ||
using System; | ||
using JetBrains.Annotations; | ||
|
||
/// <summary> | ||
/// An attribute to provide the date precision to potential data stores. | ||
/// </summary> | ||
[PublicAPI] | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] | ||
public sealed class DatePrecisionAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of the <see cref="DatePrecisionAttribute" /> type. | ||
/// </summary> | ||
/// <param name="precision"></param> | ||
public DatePrecisionAttribute(byte precision) | ||
{ | ||
this.Precision = precision; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the precision. | ||
/// </summary> | ||
public byte Precision { get; } | ||
} | ||
} |
Oops, something went wrong.