Some attempts at making this compile on WinRT. Much work remains.
git-svn-id: file:///srv/devel/repo-conversion/nusu@281 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
cc1b8d095a
commit
7d4a66e9f2
|
@ -21,6 +21,7 @@ License along with this library
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
|
@ -308,7 +309,11 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <param name="value">Value that will be checked for compatibility</param>
|
/// <param name="value">Value that will be checked for compatibility</param>
|
||||||
/// <returns>True if the value can be placed in the deque</returns>
|
/// <returns>True if the value can be placed in the deque</returns>
|
||||||
private static bool isCompatibleObject(object value) {
|
private static bool isCompatibleObject(object value) {
|
||||||
|
#if WINRT
|
||||||
|
return ((value is TItem) || ((value == null) && !typeof(TItem).GetTypeInfo().IsValueType));
|
||||||
|
#else
|
||||||
return ((value is TItem) || ((value == null) && !typeof(TItem).IsValueType));
|
return ((value is TItem) || ((value == null) && !typeof(TItem).IsValueType));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Verifies that the provided object matches the deque's type</summary>
|
/// <summary>Verifies that the provided object matches the deque's type</summary>
|
||||||
|
|
|
@ -31,7 +31,11 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <typeparam name="TValue">Type of values stored in the dictionary</typeparam>
|
/// <typeparam name="TValue">Type of values stored in the dictionary</typeparam>
|
||||||
public interface IMultiDictionary<TKey, TValue> :
|
public interface IMultiDictionary<TKey, TValue> :
|
||||||
IDictionary<TKey, ICollection<TValue>>,
|
IDictionary<TKey, ICollection<TValue>>,
|
||||||
|
#if WINRT
|
||||||
|
ICollection,
|
||||||
|
#else
|
||||||
IDictionary,
|
IDictionary,
|
||||||
|
#endif
|
||||||
ICollection<KeyValuePair<TKey, TValue>>,
|
ICollection<KeyValuePair<TKey, TValue>>,
|
||||||
IEnumerable<KeyValuePair<TKey, TValue>>,
|
IEnumerable<KeyValuePair<TKey, TValue>>,
|
||||||
IEnumerable {
|
IEnumerable {
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the item event argument container</summary>
|
/// <summary>Unit Test for the item event argument container</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ItemReplaceEventArgsTest {
|
internal class ItemReplaceEventArgsTest {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests whether an integer argument can be stored in the argument container
|
/// Tests whether an integer argument can be stored in the argument container
|
||||||
|
|
|
@ -38,6 +38,8 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
#region IDictionary implementation
|
#region IDictionary implementation
|
||||||
|
|
||||||
|
#if !WINRT
|
||||||
|
|
||||||
/// <summary>Adds an item into the dictionary</summary>
|
/// <summary>Adds an item into the dictionary</summary>
|
||||||
/// <param name="key">Key under which the item will be added</param>
|
/// <param name="key">Key under which the item will be added</param>
|
||||||
/// <param name="value">Item that will be added</param>
|
/// <param name="value">Item that will be added</param>
|
||||||
|
@ -52,12 +54,6 @@ namespace Nuclex.Support.Collections {
|
||||||
return this.objectDictionary.Contains(key);
|
return this.objectDictionary.Contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Returns a new entry enumerator for the dictionary</summary>
|
|
||||||
/// <returns>The new entry enumerator</returns>
|
|
||||||
IDictionaryEnumerator IDictionary.GetEnumerator() {
|
|
||||||
return new Enumerator(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Whether the size of the dictionary is fixed</summary>
|
/// <summary>Whether the size of the dictionary is fixed</summary>
|
||||||
bool IDictionary.IsFixedSize {
|
bool IDictionary.IsFixedSize {
|
||||||
get { return this.objectDictionary.IsFixedSize; }
|
get { return this.objectDictionary.IsFixedSize; }
|
||||||
|
@ -93,8 +89,24 @@ namespace Nuclex.Support.Collections {
|
||||||
set { this[(TKey)key] = (ICollection<TValue>)value; }
|
set { this[(TKey)key] = (ICollection<TValue>)value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // !WINRT
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IDictionaryEnumerator implementation
|
||||||
|
|
||||||
|
#if !WINRT
|
||||||
|
|
||||||
|
/// <summary>Returns a new entry enumerator for the dictionary</summary>
|
||||||
|
/// <returns>The new entry enumerator</returns>
|
||||||
|
IDictionaryEnumerator IDictionary.GetEnumerator() {
|
||||||
|
return new Enumerator(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !WINRT
|
||||||
|
|
||||||
|
#endregion // IDictionaryEnumerator implementation
|
||||||
|
|
||||||
#region ICollection<KeyValuePair<TKey, TValue>> implementation
|
#region ICollection<KeyValuePair<TKey, TValue>> implementation
|
||||||
|
|
||||||
/// <summary>Inserts an already prepared element into the dictionary</summary>
|
/// <summary>Inserts an already prepared element into the dictionary</summary>
|
||||||
|
|
|
@ -34,7 +34,10 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Enumerates the values stored in a multi dictionary</summary>
|
/// <summary>Enumerates the values stored in a multi dictionary</summary>
|
||||||
private class Enumerator :
|
private class Enumerator :
|
||||||
IEnumerator<KeyValuePair<TKey, TValue>>, IDictionaryEnumerator {
|
#if !WINRT
|
||||||
|
IDictionaryEnumerator,
|
||||||
|
#endif
|
||||||
|
IEnumerator<KeyValuePair<TKey, TValue>> {
|
||||||
|
|
||||||
/// <summary>Initializes a new multi dictionary enumerator</summary>
|
/// <summary>Initializes a new multi dictionary enumerator</summary>
|
||||||
/// <param name="dictionary">Dictionary that will be enumerated</param>
|
/// <param name="dictionary">Dictionary that will be enumerated</param>
|
||||||
|
@ -125,6 +128,8 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
#region IDictionaryEnumerator implementation
|
#region IDictionaryEnumerator implementation
|
||||||
|
|
||||||
|
#if !WINRT
|
||||||
|
|
||||||
/// <summary>The current entry the enumerator is pointing to</summary>
|
/// <summary>The current entry the enumerator is pointing to</summary>
|
||||||
DictionaryEntry IDictionaryEnumerator.Entry {
|
DictionaryEntry IDictionaryEnumerator.Entry {
|
||||||
get {
|
get {
|
||||||
|
@ -136,15 +141,6 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Throws an exception if the enumerator is not on a valid position
|
|
||||||
/// </summary>
|
|
||||||
private void enforceEnumeratorOnValidPosition() {
|
|
||||||
if(this.currentValue == null) {
|
|
||||||
throw new InvalidOperationException("Enumerator is not on a valid position");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>The current dictionary key</summary>
|
/// <summary>The current dictionary key</summary>
|
||||||
object IDictionaryEnumerator.Key {
|
object IDictionaryEnumerator.Key {
|
||||||
get {
|
get {
|
||||||
|
@ -161,8 +157,19 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // !WINRT
|
||||||
|
|
||||||
#endregion // IDictionaryEnumerator implementation
|
#endregion // IDictionaryEnumerator implementation
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Throws an exception if the enumerator is not on a valid position
|
||||||
|
/// </summary>
|
||||||
|
private void enforceEnumeratorOnValidPosition() {
|
||||||
|
if(this.currentValue == null) {
|
||||||
|
throw new InvalidOperationException("Enumerator is not on a valid position");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Dictionary over whose entries the enumerator is enumerating</summary>
|
/// <summary>Dictionary over whose entries the enumerator is enumerating</summary>
|
||||||
private IDictionary<TKey, ICollection<TValue>> dictionary;
|
private IDictionary<TKey, ICollection<TValue>> dictionary;
|
||||||
/// <summary>Current key the enumerator is at</summary>
|
/// <summary>Current key the enumerator is at</summary>
|
||||||
|
@ -220,7 +227,9 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <param name="dictionary">Dictionary the multi dictionary will be based on</param>
|
/// <param name="dictionary">Dictionary the multi dictionary will be based on</param>
|
||||||
internal MultiDictionary(IDictionary<TKey, ICollection<TValue>> dictionary) {
|
internal MultiDictionary(IDictionary<TKey, ICollection<TValue>> dictionary) {
|
||||||
this.typedDictionary = dictionary;
|
this.typedDictionary = dictionary;
|
||||||
|
#if !WINRT
|
||||||
this.objectDictionary = (this.typedDictionary as IDictionary);
|
this.objectDictionary = (this.typedDictionary as IDictionary);
|
||||||
|
#endif
|
||||||
|
|
||||||
foreach(ICollection<TValue> values in dictionary.Values) {
|
foreach(ICollection<TValue> values in dictionary.Values) {
|
||||||
this.count += values.Count;
|
this.count += values.Count;
|
||||||
|
@ -402,8 +411,10 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>The wrapped Dictionary under its type-safe interface</summary>
|
/// <summary>The wrapped Dictionary under its type-safe interface</summary>
|
||||||
private IDictionary<TKey, ICollection<TValue>> typedDictionary;
|
private IDictionary<TKey, ICollection<TValue>> typedDictionary;
|
||||||
|
#if !WINRT
|
||||||
/// <summary>The wrapped Dictionary under its object interface</summary>
|
/// <summary>The wrapped Dictionary under its object interface</summary>
|
||||||
private IDictionary objectDictionary;
|
private IDictionary objectDictionary;
|
||||||
|
#endif
|
||||||
/// <summary>The number of items currently in the multi dictionary</summary>
|
/// <summary>The number of items currently in the multi dictionary</summary>
|
||||||
private int count;
|
private int count;
|
||||||
/// <summary>Provides the values stores in the dictionary in sequence</summary>
|
/// <summary>Provides the values stores in the dictionary in sequence</summary>
|
||||||
|
|
|
@ -40,7 +40,11 @@ namespace Nuclex.Support.Collections {
|
||||||
IDeserializationCallback,
|
IDeserializationCallback,
|
||||||
#endif
|
#endif
|
||||||
IDictionary<TKey, TValue>,
|
IDictionary<TKey, TValue>,
|
||||||
|
#if WINRT
|
||||||
|
ICollection,
|
||||||
|
#else
|
||||||
IDictionary,
|
IDictionary,
|
||||||
|
#endif
|
||||||
#if !NO_SPECIALIZED_COLLECTIONS
|
#if !NO_SPECIALIZED_COLLECTIONS
|
||||||
INotifyCollectionChanged,
|
INotifyCollectionChanged,
|
||||||
#endif
|
#endif
|
||||||
|
@ -329,6 +333,8 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
#region IDictionary implementation
|
#region IDictionary implementation
|
||||||
|
|
||||||
|
#if !WINRT
|
||||||
|
|
||||||
/// <summary>Adds an item into the Dictionary</summary>
|
/// <summary>Adds an item into the Dictionary</summary>
|
||||||
/// <param name="key">Key under which the item will be added</param>
|
/// <param name="key">Key under which the item will be added</param>
|
||||||
/// <param name="value">Item that will be added</param>
|
/// <param name="value">Item that will be added</param>
|
||||||
|
@ -344,12 +350,6 @@ namespace Nuclex.Support.Collections {
|
||||||
return this.objectDictionary.Contains(key);
|
return this.objectDictionary.Contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Returns a new entry enumerator for the dictionary</summary>
|
|
||||||
/// <returns>The new entry enumerator</returns>
|
|
||||||
IDictionaryEnumerator IDictionary.GetEnumerator() {
|
|
||||||
return this.objectDictionary.GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Whether the size of the Dictionary is fixed</summary>
|
/// <summary>Whether the size of the Dictionary is fixed</summary>
|
||||||
bool IDictionary.IsFixedSize {
|
bool IDictionary.IsFixedSize {
|
||||||
get { return this.objectDictionary.IsFixedSize; }
|
get { return this.objectDictionary.IsFixedSize; }
|
||||||
|
@ -395,7 +395,23 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endif // !WINRT
|
||||||
|
|
||||||
|
#endregion // IDictionary implementation
|
||||||
|
|
||||||
|
#region IDictionaryEnumerator implementation
|
||||||
|
|
||||||
|
#if !WINRT
|
||||||
|
|
||||||
|
/// <summary>Returns a new entry enumerator for the dictionary</summary>
|
||||||
|
/// <returns>The new entry enumerator</returns>
|
||||||
|
IDictionaryEnumerator IDictionary.GetEnumerator() {
|
||||||
|
return this.objectDictionary.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !WINRT
|
||||||
|
|
||||||
|
#endregion // IDictionaryEnumerator implementation
|
||||||
|
|
||||||
#region ICollection<> implementation
|
#region ICollection<> implementation
|
||||||
|
|
||||||
|
@ -477,8 +493,10 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>The wrapped Dictionary under its type-safe interface</summary>
|
/// <summary>The wrapped Dictionary under its type-safe interface</summary>
|
||||||
private IDictionary<TKey, TValue> typedDictionary;
|
private IDictionary<TKey, TValue> typedDictionary;
|
||||||
|
#if !WINRT
|
||||||
/// <summary>The wrapped Dictionary under its object interface</summary>
|
/// <summary>The wrapped Dictionary under its object interface</summary>
|
||||||
private IDictionary objectDictionary;
|
private IDictionary objectDictionary;
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,12 @@ namespace Nuclex.Support.Collections {
|
||||||
ISerializable,
|
ISerializable,
|
||||||
IDeserializationCallback,
|
IDeserializationCallback,
|
||||||
#endif
|
#endif
|
||||||
IDictionary<KeyType, ValueType>,
|
#if WINRT
|
||||||
IDictionary {
|
ICollection,
|
||||||
|
#else
|
||||||
|
IDictionary,
|
||||||
|
#endif
|
||||||
|
IDictionary<KeyType, ValueType> {
|
||||||
|
|
||||||
#if !NO_SERIALIZATION
|
#if !NO_SERIALIZATION
|
||||||
|
|
||||||
|
@ -233,6 +237,8 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
#region IDictionary implementation
|
#region IDictionary implementation
|
||||||
|
|
||||||
|
#if !WINRT
|
||||||
|
|
||||||
/// <summary>Removes all items from the Dictionary</summary>
|
/// <summary>Removes all items from the Dictionary</summary>
|
||||||
void IDictionary.Clear() {
|
void IDictionary.Clear() {
|
||||||
throw new NotSupportedException(
|
throw new NotSupportedException(
|
||||||
|
@ -256,12 +262,6 @@ namespace Nuclex.Support.Collections {
|
||||||
return this.objectDictionary.Contains(key);
|
return this.objectDictionary.Contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Returns a new entry enumerator for the dictionary</summary>
|
|
||||||
/// <returns>The new entry enumerator</returns>
|
|
||||||
IDictionaryEnumerator IDictionary.GetEnumerator() {
|
|
||||||
return this.objectDictionary.GetEnumerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>Whether the size of the Dictionary is fixed</summary>
|
/// <summary>Whether the size of the Dictionary is fixed</summary>
|
||||||
bool IDictionary.IsFixedSize {
|
bool IDictionary.IsFixedSize {
|
||||||
get { return this.objectDictionary.IsFixedSize; }
|
get { return this.objectDictionary.IsFixedSize; }
|
||||||
|
@ -313,7 +313,23 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endif // !WINRT
|
||||||
|
|
||||||
|
#endregion // IDictionary implementation
|
||||||
|
|
||||||
|
#region IDictionaryEnumerator implementation
|
||||||
|
|
||||||
|
#if !WINRT
|
||||||
|
|
||||||
|
/// <summary>Returns a new entry enumerator for the dictionary</summary>
|
||||||
|
/// <returns>The new entry enumerator</returns>
|
||||||
|
IDictionaryEnumerator IDictionary.GetEnumerator() {
|
||||||
|
return this.objectDictionary.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !WINRT
|
||||||
|
|
||||||
|
#endregion // IDictionaryEnumerator implementation
|
||||||
|
|
||||||
#region ICollection<> implementation
|
#region ICollection<> implementation
|
||||||
|
|
||||||
|
@ -394,8 +410,10 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>The wrapped Dictionary under its type-safe interface</summary>
|
/// <summary>The wrapped Dictionary under its type-safe interface</summary>
|
||||||
private IDictionary<KeyType, ValueType> typedDictionary;
|
private IDictionary<KeyType, ValueType> typedDictionary;
|
||||||
|
#if !WINRT
|
||||||
/// <summary>The wrapped Dictionary under its object interface</summary>
|
/// <summary>The wrapped Dictionary under its object interface</summary>
|
||||||
private IDictionary objectDictionary;
|
private IDictionary objectDictionary;
|
||||||
|
#endif
|
||||||
/// <summary>ReadOnly wrapper for the keys collection of the Dictionary</summary>
|
/// <summary>ReadOnly wrapper for the keys collection of the Dictionary</summary>
|
||||||
private ReadOnlyCollection<KeyType> readonlyKeyCollection;
|
private ReadOnlyCollection<KeyType> readonlyKeyCollection;
|
||||||
/// <summary>ReadOnly wrapper for the values collection of the Dictionary</summary>
|
/// <summary>ReadOnly wrapper for the values collection of the Dictionary</summary>
|
||||||
|
|
|
@ -58,7 +58,33 @@ namespace Nuclex.Support {
|
||||||
|
|
||||||
#endregion // class MemberInfoComparer
|
#endregion // class MemberInfoComparer
|
||||||
|
|
||||||
#if !(XBOX360 || WINDOWS_PHONE)
|
#if WINRT
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns all the fields of a type, including those defined in the type's base classes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type">Type whose fields will be returned</param>
|
||||||
|
/// <param name="bindingFlags">Binding flags to use when querying the fields</param>
|
||||||
|
/// <returns>All of the type's fields, including its base types</returns>
|
||||||
|
public static FieldInfo[] GetFieldInfosIncludingBaseClasses(this Type type) {
|
||||||
|
var fieldInfoSet = new HashSet<FieldInfo>(fieldInfos, FieldInfoComparer.Default);
|
||||||
|
|
||||||
|
while(type != typeof(object)) {
|
||||||
|
TypeInfo typeInfo = type.GetTypeInfo();
|
||||||
|
|
||||||
|
foreach(FieldInfo fieldInfo in typeInfo.DeclaredFields) {
|
||||||
|
fieldInfoSet.Add(fieldInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
type = typeInfo.BaseType;
|
||||||
|
}
|
||||||
|
|
||||||
|
FieldInfo[] fieldInfos = new FieldInfo[fieldInfoSet.Count];
|
||||||
|
fieldInfoSet.CopyTo(fieldInfos, 0);
|
||||||
|
return fieldInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif !(XBOX360 || WINDOWS_PHONE)
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns all the fields of a type, including those defined in the type's base classes
|
/// Returns all the fields of a type, including those defined in the type's base classes
|
||||||
|
@ -140,6 +166,23 @@ namespace Nuclex.Support {
|
||||||
|
|
||||||
#endif // !(XBOX360 || WINDOWS_PHONE)
|
#endif // !(XBOX360 || WINDOWS_PHONE)
|
||||||
|
|
||||||
|
#if WINRT
|
||||||
|
|
||||||
|
/// <summary>Determines whether the given type has a default constructor</summary>
|
||||||
|
/// <param name="type">Type which is to be checked</param>
|
||||||
|
/// <returns>True if the type has a default constructor</returns>
|
||||||
|
public static bool HasDefaultConstructor(this Type type) {
|
||||||
|
foreach(ConstructorInfo constructorInfo in type.GetTypeInfo().DeclaredConstructors) {
|
||||||
|
if(constructorInfo.IsPublic && (constructorInfo.GetParameters().Length == 0)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
/// <summary>Determines whether the given type has a default constructor</summary>
|
/// <summary>Determines whether the given type has a default constructor</summary>
|
||||||
/// <param name="type">Type which is to be checked</param>
|
/// <param name="type">Type which is to be checked</param>
|
||||||
/// <returns>True if the type has a default constructor</returns>
|
/// <returns>True if the type has a default constructor</returns>
|
||||||
|
@ -156,6 +199,8 @@ namespace Nuclex.Support {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/// <summary>Determines whether the type has the specified attribute</summary>
|
/// <summary>Determines whether the type has the specified attribute</summary>
|
||||||
/// <typeparam name="TAttribute">Attribute the type will be checked for</typeparam>
|
/// <typeparam name="TAttribute">Attribute the type will be checked for</typeparam>
|
||||||
/// <param name="type">
|
/// <param name="type">
|
||||||
|
@ -166,6 +211,20 @@ namespace Nuclex.Support {
|
||||||
return type.HasAttribute(typeof(TAttribute));
|
return type.HasAttribute(typeof(TAttribute));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WINRT
|
||||||
|
|
||||||
|
/// <summary>Determines whether the type has the specified attribute</summary>
|
||||||
|
/// <param name="type">
|
||||||
|
/// Type that will be checked for presence of the specified attribute
|
||||||
|
/// </param>
|
||||||
|
/// <param name="attributeType">Attribute the type will be checked for</typeparam>
|
||||||
|
/// <returns>True if the type has the specified attribute, otherwise false</returns>
|
||||||
|
public static bool HasAttribute(this Type type, Type attributeType) {
|
||||||
|
return (type.GetTypeInfo().GetCustomAttribute(attributeType) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
/// <summary>Determines whether the type has the specified attribute</summary>
|
/// <summary>Determines whether the type has the specified attribute</summary>
|
||||||
/// <param name="type">
|
/// <param name="type">
|
||||||
/// Type that will be checked for presence of the specified attribute
|
/// Type that will be checked for presence of the specified attribute
|
||||||
|
@ -177,6 +236,8 @@ namespace Nuclex.Support {
|
||||||
return (attributes != null) && (attributes.Length > 0);
|
return (attributes != null) && (attributes.Length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Nuclex.Support
|
} // namespace Nuclex.Support
|
||||||
|
|
Loading…
Reference in New Issue
Block a user