/// <summary> /// Determines whether this instance can convert the specified object type. /// </summary> /// <param name="objectType">Type of the object.</param> /// <returns> /// <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>. /// </returns> public override bool CanConvert(Type objectType) { if (typeof(IEnumerable).IsAssignableFrom(objectType)) { return(false); } // all fsharp objects have CompilationMappingAttribute // get the fsharp assembly from the attribute and initialize latebound methods var attributes = objectType.GetCustomAttributes(true); var isFSharpType = false; foreach (var attribute in attributes) { var attributeType = attribute.GetType(); if (attributeType.FullName == "Microsoft.FSharp.Core.CompilationMappingAttribute") { FSharpUtils.EnsureInitialized(attributeType.Assembly()); isFSharpType = true; break; } } if (!isFSharpType) { return(false); } return((bool)FSharpUtils.IsUnion(null, objectType, null)); }
public override bool CanConvert(Type objectType) { if (typeof(IEnumerable).IsAssignableFrom(objectType)) { return(false); } bool flag = false; object[] customAttributes = objectType.GetCustomAttributes(true); for (int i = 0; i < customAttributes.Length; i++) { Type type = customAttributes[i].GetType(); if (type.FullName == "Microsoft.FSharp.Core.CompilationMappingAttribute") { FSharpUtils.EnsureInitialized(type.Assembly()); flag = true; break; } } if (!flag) { return(false); } object[] args = new object[2]; args[0] = objectType; return((bool)FSharpUtils.IsUnion(null, args)); }
/// <summary> /// Determines whether this instance can convert the specified object type. /// </summary> /// <param name="objectType">Type of the object.</param> /// <returns> /// <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>. /// </returns> public override bool CanConvert(Type objectType) { if (typeof(IEnumerable).IsAssignableFrom(objectType)) { return(false); } // all fsharp objects have CompilationMappingAttribute // get the fsharp assembly from the attribute and initialize latebound methods object[] attributes; #if !(NETFX_CORE || PORTABLE) attributes = objectType.GetCustomAttributes(true); #else attributes = objectType.GetTypeInfo().GetCustomAttributes(true).ToArray(); #endif bool isFSharpType = false; foreach (object attribute in attributes) { Type attributeType = attribute.GetType(); if (attributeType.Name == "CompilationMappingAttribute") { FSharpUtils.EnsureInitialized(attributeType.Assembly()); isFSharpType = true; break; } } if (!isFSharpType) { return(false); } return((bool)FSharpUtils.IsUnion(null, objectType, null)); }
public override bool CanConvert(Type objectType) { if (typeof(IEnumerable).IsAssignableFrom(objectType)) { return(false); } bool flag = false; object[] customAttributes = objectType.GetCustomAttributes(true); int num = 0; while (true) { if (num < (int)customAttributes.Length) { Type type = customAttributes[num].GetType(); if (type.FullName == "Microsoft.FSharp.Core.CompilationMappingAttribute") { FSharpUtils.EnsureInitialized(type.Assembly()); flag = true; break; } else { num++; } } else { break; } } if (!flag) { return(false); } return((bool)FSharpUtils.IsUnion(null, new object[] { objectType, null })); }