init
This commit is contained in:
29
Common/DTS.Common/Attributes/DescriptionAttributeEx.cs
Normal file
29
Common/DTS.Common/Attributes/DescriptionAttributeEx.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Common.Attributes
|
||||
{
|
||||
/// <summary>
|
||||
/// this class overloads the description attribute to allow us to use an enum
|
||||
/// to set the description and to lookup the description in the string resources
|
||||
/// to be translated the property should have a string resource in the form of PropertyName_Description
|
||||
/// otherwise ##DescriptionNotFound## will be returned as the translated string
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Interface | AttributeTargets.Delegate | AttributeTargets.Property)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S3376:Attribute, EventArgs, and Exception type names should end with the type being extended", Justification = "extebded")]
|
||||
public class DescriptionAttributeEx : DescriptionAttribute
|
||||
{
|
||||
private readonly string _propertyIdString = null;
|
||||
|
||||
public DescriptionAttributeEx(string propertyId)
|
||||
{
|
||||
_propertyIdString = propertyId;
|
||||
}
|
||||
public override string Description
|
||||
{
|
||||
get => StringResources.ResourceManager.GetString(_propertyIdString + "_Description") ?? @"##DescriptionNotFound##" + _propertyIdString;
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Common/DTS.Common/Attributes/DisplayAttributeEx.cs
Normal file
28
Common/DTS.Common/Attributes/DisplayAttributeEx.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using DTS.Common.SharedResource.Strings;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace DTS.Common.Attributes
|
||||
{
|
||||
/// <summary>
|
||||
/// this class overrides the DisplayNameAttribute to provide a translated string name, and also
|
||||
/// to allow us to use an enum to create the attribute
|
||||
/// to be translated a string resource should exist in the form of PropertyName_DisplayName
|
||||
/// otherwise ##DisplayNameNotFound## will be returned
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Interface | AttributeTargets.Delegate | AttributeTargets.Property)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Minor Code Smell", "S3376:Attribute, EventArgs, and Exception type names should end with the type being extended", Justification = "extebded")]
|
||||
public class DisplayAttributeEx : DisplayNameAttribute
|
||||
{
|
||||
private readonly string _propertyIdString = null;
|
||||
public DisplayAttributeEx(string propertyId)
|
||||
{
|
||||
_propertyIdString = propertyId;
|
||||
}
|
||||
public override string DisplayName
|
||||
{
|
||||
get =>StringResources.ResourceManager.GetString(_propertyIdString + "_DisplayName") ?? @"##DisplayNameNotFound##" + _propertyIdString;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.Common.Attributes
|
||||
{
|
||||
public class ProgrammableTriggersAttribute : Attribute
|
||||
{
|
||||
public bool PreTrigger { get; set; }
|
||||
public bool PostTrigger { get; set; }
|
||||
|
||||
public ProgrammableTriggersAttribute(bool preTrigger, bool postTrigger)
|
||||
{
|
||||
PreTrigger = preTrigger;
|
||||
PostTrigger = postTrigger;
|
||||
}
|
||||
public static bool IsPreTriggerProgrammable(Enum value)
|
||||
{
|
||||
var fi = value.GetType().GetField(value.ToString());
|
||||
var attributes = fi.GetCustomAttributes(typeof(ProgrammableTriggersAttribute), false);
|
||||
|
||||
if (attributes.Length > 0)
|
||||
{
|
||||
if (attributes[0] is ProgrammableTriggersAttribute attr)
|
||||
{
|
||||
return attr.PreTrigger;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public static bool IsPostTriggerProgrammable(Enum value)
|
||||
{
|
||||
var fi = value.GetType().GetField(value.ToString());
|
||||
var attributes = fi.GetCustomAttributes(typeof(ProgrammableTriggersAttribute), false);
|
||||
|
||||
if (attributes.Length > 0)
|
||||
{
|
||||
if (attributes[0] is ProgrammableTriggersAttribute attr)
|
||||
{
|
||||
return attr.PostTrigger;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Common/DTS.Common/Attributes/VersionAttribute.cs
Normal file
15
Common/DTS.Common/Attributes/VersionAttribute.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace DTS.Common.Attributes
|
||||
{
|
||||
public class VersionAttribute : Attribute
|
||||
{
|
||||
public int Version { get; private set; }
|
||||
|
||||
public VersionAttribute(int version)
|
||||
{
|
||||
Version = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user