private IPlayFabPlugin GetPluginInternal(PluginContract contract, string instanceName)
        {
            var key = new PluginContractKey {
                _pluginContract = contract, _pluginName = instanceName
            };
            IPlayFabPlugin plugin;

            if (!this.plugins.TryGetValue(key, out plugin))
            {
                // Requested plugin is not in the cache, create the default one
                switch (contract)
                {
                case PluginContract.PlayFab_Serializer:
                    plugin = this.CreatePlugin <SimpleJsonInstance>();
                    break;

                case PluginContract.PlayFab_Transport:
                    plugin = this.CreatePlayFabTransportPlugin();
                    break;

                default:
                    throw new ArgumentException("This contract is not supported", "contract");
                }

                this.plugins[key] = plugin;
            }

            return(plugin);
        }
        private IPlayFabPlugin GetPluginInternal(PluginContract contract, string instanceName)
        {
            var key = new KeyValuePair <PluginContract, string>(contract, instanceName);

            if (!this.plugins.ContainsKey(key))
            {
                // Requested plugin is not in the cache, create the default one
                IPlayFabPlugin plugin;
                switch (contract)
                {
                case PluginContract.PlayFab_Serializer:
                    plugin = this.CreatePlugin <SimpleJsonInstance>();
                    break;

                case PluginContract.PlayFab_Transport:
                    plugin = this.CreatePlayFabTransportPlugin();
                    break;

                default:
                    throw new ArgumentException("This contract is not supported", "contract");
                }

                this.plugins[key] = plugin;
            }

            return(this.plugins[key]);
        }
        private void SetPluginInternal(IPlayFabPlugin plugin, PluginContract contract, string instanceName)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin), "Plugin instance cannot be null");
            }

            var key = new Tuple <PluginContract, string>(contract, instanceName);

            this.plugins[key] = plugin;
        }
        private void SetPluginInternal(IPlayFabPlugin plugin, PluginContract contract, string instanceName)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException("plugin", "Plugin instance cannot be null");
            }

            var key = new PluginContractKey {
                _pluginContract = contract, _pluginName = instanceName
            };

            this.plugins[key] = plugin;
        }
 /// <summary>
 /// Sets a custom plugin.
 /// If a plugin with specified contract and optional instance name already exists, it will be replaced with specified instance.
 /// </summary>
 /// <param name="plugin">The plugin instance.</param>
 /// <param name="contract">The app contract of plugin.</param>
 /// <param name="instanceName">The optional plugin instance name. Instance names allow to have mulptiple plugins with the same contract.</param>
 public static void SetPlugin(IPlayFabPlugin plugin, PluginContract contract, string instanceName = "")
 {
     Instance.SetPluginInternal(plugin, contract, instanceName);
 }
 /// <summary>
 /// Gets a plugin.
 /// If a plugin with specified contract and optional instance name does not exist, it will create a new one.
 /// </summary>
 /// <param name="contract">The plugin contract.</param>
 /// <param name="instanceName">The optional plugin instance name. Instance names allow to have mulptiple plugins with the same contract.</param>
 /// <returns>The plugin instance.</returns>
 public static T GetPlugin <T>(PluginContract contract, string instanceName = "") where T : IPlayFabPlugin
 {
     return((T)Instance.GetPluginInternal(contract, instanceName));
 }