Beispiel #1
0
 /// <summary>
 /// This will reset entirely to the base state, as if no calls to Convert, Create or GetConverter had been made
 /// </summary>
 public static void Reset()
 {
     lock (_lock)
     {
         _converter = new ConverterWrapper(
             ByPropertySettingNullSourceBehaviourOptions.UseDestDefaultIfSourceIsNull,
             EnumerableSetNullHandlingOptions.ReturnNullSetForNullInput
             );
     }
 }
        /// <summary>
        /// This will reset entirely to the base state, as if no calls to Convert, Create or GetConverter had been made
        /// </summary>
        public static void Reset()
        {
            lock (_lock)
            {
                // The CreateEmptyInstanceWithDefaultPropertyValues and AssumeNonNullInput configuration options are to deal with generating project
                // expressions for Entity Framework IQueryable sets. The first is because it's not allowable to look at an input and generate a null
                // reference from it (an "Unable to create a null constant value of type '{whatever}'. Only entity types, enumeration types or primitive
                // types are supported in this context" will will be thrown). Instead we generate an interim type which is never null but which has an
                // is-initialised flag, this will be set to false if the source value should result in a null destination instance. The AssumeNonNullInput
                // option for EnumerableSetNullHandlingOptions is required for a similar reason - if an input is an enumerable set then it may not be
                // translated to null in some cases (like if the input set is null) and to a non-null list in other cases (if it's not null) (another
                // NotSupportedException will be thrown with message "Unable to create a null constant value of type '{whatever}'. Only entity types,
                // enumeration types or primitive types are supported in this context").
                _converter = new ConverterWrapper(
                    ByPropertySettingNullSourceBehaviourOptions.CreateEmptyInstanceWithDefaultPropertyValues,
                    EnumerableSetNullHandlingOptions.AssumeNonNullInput
                    );
                _projectionDataTypeCache.Clear();

                // Note: There's no point resetting the interimTypeCache since the cached results don't change based upon any configuration, the same
                // type should always be used when there same set of properties are required on it.
            }
        }