public void Test() { foreach (Type typeFrom in types) { foreach (Type typeTo in types) { //AdvancedConverter<typeFrom, typeTo>(); Type providerType = provider.GetType(); MethodInfo getConverterMethod = providerType.GetMethod("GetConverter", ArrayUtils <Type> .EmptyArray).GetGenericMethodDefinition().MakeGenericMethod(new Type[] { typeFrom, typeTo }); object converter = null; try { converter = getConverterMethod.Invoke(provider, null); } catch { TestLog.Info("Conversion from {0} to {1} is not supported", typeFrom.GetShortName(), typeTo.GetShortName()); } if (converter != null) { Type maskInterface = typeof(IAdvancedConverter <,>).MakeGenericType(new Type[] { typeFrom, typeTo }); Type[] foundInterfaces = converter.GetType().FindInterfaces( delegate(Type typeObj, Object criteriaObj) { return(typeObj == maskInterface); }, null); foreach (Type type in foundInterfaces) { PropertyInfo propertyInfo = type.GetProperty("IsRough"); bool isRough = (bool)propertyInfo.GetValue(converter, null); TestLog.Info("Conversion from {0} to {1} is {2}", typeFrom.GetShortName(), typeTo.GetShortName(), isRough ? "Rough" : "Strict"); } } } } }
/// <summary> /// Performs post-deserialization actions. /// </summary> /// <param name="sender"></param> public virtual void OnDeserialization(object sender) { if (provider == null || provider.GetType() == typeof(AdvancedConverterProvider)) { provider = AdvancedConverterProvider.Default; } }