support for .NET framework 3.5
Still have bugs
This commit is contained in:
1 parent
5878039e21
commit
7d6b491f25
704 files changed
+48273
-33
No files matched your search
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
|
||||
namespace HandyControl.Interactivity
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class, AllowMultiple = true)]
|
||||
public sealed class DefaultTriggerAttribute : Attribute
|
||||
{
|
||||
private readonly object[] _parameters;
|
||||
|
||||
public DefaultTriggerAttribute(Type targetType, Type triggerType, object parameter) : this(targetType,
|
||||
triggerType, new[] {parameter})
|
||||
{
|
||||
}
|
||||
|
||||
public DefaultTriggerAttribute(Type targetType, Type triggerType, params object[] parameters)
|
||||
{
|
||||
if (!typeof(TriggerBase).IsAssignableFrom(triggerType))
|
||||
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
|
||||
ExceptionStringTable.DefaultTriggerAttributeInvalidTriggerTypeSpecifiedExceptionMessage,
|
||||
new object[] {triggerType.Name}));
|
||||
TargetType = targetType;
|
||||
TriggerType = triggerType;
|
||||
_parameters = parameters;
|
||||
}
|
||||
|
||||
public IEnumerable Parameters =>
|
||||
_parameters;
|
||||
|
||||
public Type TargetType { get; }
|
||||
|
||||
public Type TriggerType { get; }
|
||||
|
||||
public TriggerBase Instantiate()
|
||||
{
|
||||
object obj2 = null;
|
||||
try
|
||||
{
|
||||
obj2 = Activator.CreateInstance(TriggerType, _parameters);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
return (TriggerBase) obj2;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user