/// <summary> /// Registers a method replacement /// </summary> /// <param name="signature">The source method that is deprecated. For example: t3lib_div::readLLXMLfile</param> /// <param name="targetVersion">The version since this method is deprecated. For example: <see cref="Typo3Version.TYPO3_4_6_0"/></param> /// <param name="replacement">The method that should be used instead. For example: t3lib_l10n_parser_Llxml::getParsedData</param> /// <returns>Always returns <see langword="null"/></returns> public static Object Register( string signature, Typo3Version targetVersion, string replacement ) { if( null == Replacements ) { Replacements = new Dictionary<string, List<KeyValuePair<Typo3Version, string>>>(); } if( !Replacements.ContainsKey( signature ) ) { Replacements[ signature ] = new List<KeyValuePair<Typo3Version, string>>(); } Replacements[ signature ].Add( new KeyValuePair<Typo3Version, string>( targetVersion, replacement ) ); return null; }
/// <summary> /// Retrieve a replacement method signature for a given method signature. /// </summary> /// <param name="signature">The signature to look up.</param> /// <param name="targetVersion">The target TYPO3 version we want to use.</param> /// <returns></returns> public static string Get( string signature, Typo3Version targetVersion ) { if( !Is( signature ) ) { return signature; } if( !Replacements[ signature ].Any( r => r.Key.Version <= targetVersion.Version ) ) { return signature; } // In case the given replacement is again already deprecated, run it through the system again. return Get( Replacements[ signature ].OrderBy( r => r.Key.Version ).Last( r => r.Key.Version <= targetVersion.Version ).Value, targetVersion ); }