using System; using System.Collections.Generic; namespace Xamarin.Forms { /// /// Helper that handles storing and lookup of platform specifics implementations /// /// The Element type internal class PlatformConfigurationRegistry : IElementConfiguration where TElement : Element { readonly TElement _element; readonly Dictionary _platformSpecifics = new Dictionary(); internal PlatformConfigurationRegistry(TElement element) { _element = element; } public IPlatformElementConfiguration On() where T : IConfigPlatform { if (_platformSpecifics.ContainsKey(typeof(T))) { return (IPlatformElementConfiguration)_platformSpecifics[typeof(T)]; } var emptyConfig = Configuration.Create(_element); _platformSpecifics.Add(typeof(T), emptyConfig); return emptyConfig; } } }