Skip to content

Commit

Permalink
check for Windows Runtime type in WeakEventHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
tibel committed May 14, 2014
1 parent edccdfe commit fa78c27
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build/Weakly.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<metadata>
<id>Weakly</id>
<title>Weakly</title>
<version>2.1.2</version>
<version>2.1.3</version>
<authors>Thomas Ibel</authors>
<description>Weakly is a collection of some useful weak-reference types available as portable class library for net45+win8+wp8+wpa81.</description>
<language>en-US</language>
<licenseUrl>https://raw.github.com/tibel/Weakly/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/tibel/Weakly</projectUrl>
<iconUrl>https://raw.github.com/tibel/Weakly/master/build/weakly_icon.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>Add DynamicProperty.SetterFrom()</releaseNotes>
<releaseNotes>Add check for Windows Runtime type.</releaseNotes>
<copyright>Copyright Thomas Ibel 2013-2014</copyright>
<tags>
Weakly WeakReference WeakAction WeakFunc WeakDelegate WeakCollection WeakValueDictionary WeakEventHandler WeakEventSource DynamicDelegate
Expand Down
2 changes: 1 addition & 1 deletion src/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
[assembly: CLSCompliant(true)]

[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.2.0")]
[assembly: AssemblyFileVersion("2.1.3.0")]
3 changes: 3 additions & 0 deletions src/Weakly/Events/WeakEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public static IDisposable Register<TEventArgs>(object eventSource, EventInfo eve
if (handler.Target == null)
throw new ArgumentException("Handler delegate must point to instance method.", "handler");

if (eventInfo.EventHandlerType.IsWindowsRuntimeType())
throw new ArgumentException("Windows Runtime events are not supported.", "eventInfo");

var isStatic = eventInfo.AddMethod.IsStatic;
if (!isStatic && eventSource == null)
throw new ArgumentNullException("eventSource");
Expand Down
3 changes: 1 addition & 2 deletions src/Weakly/Reflection/ReflectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public static bool IsAsync(this MethodInfo methodInfo)
/// <returns>True, if the type is a Windows Runtime Type; otherwise false.</returns>
public static bool IsWindowsRuntimeType(this Type type)
{
return type != null &&
type.AssemblyQualifiedName.EndsWith("ContentType=WindowsRuntime", StringComparison.Ordinal);
return type.AssemblyQualifiedName.EndsWith("ContentType=WindowsRuntime", StringComparison.Ordinal);
}
}
}

0 comments on commit fa78c27

Please sign in to comment.