예제 #1
0
        /// <summary>
        /// Registers persistence <c>plugin</c>.
        /// </summary>
        /// <param name="plugin">Persistence <c>plugin</c>.</param>
        internal void RegisterPlugin(PersistencePluginBase <TPersistence, TUnitOfWork> plugin)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }

            Critical.Assert(!_isInitialized, "You cannot register plugin after persistence become initialized.");

            _plugins.Add(plugin);
        }
예제 #2
0
        public object GetPluginEntry(PersistencePluginBase <TPersistence, TUnitOfWork> plugin)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }

            if (!ReferenceEquals(plugin.Persistence, Persistence))
            {
                throw new ArgumentException("Plugin and UoW should belongs to the same persistence.", nameof(plugin));
            }

            object data;

            _pluginEntries.TryGetValue(plugin, out data);

            return(data);
        }
예제 #3
0
        /// <summary>
        /// Sets <c>plugin</c> <c>entry</c> to <c>this</c> UoW.
        /// </summary>
        /// <param name="plugin">Plugin to which associate specified <c>entry</c>.</param>
        /// <param name="entry">
        /// Entry associated with the specified <c>plugin</c>. Use <see langword="null"/> to delete
        /// <c>entry</c>.
        /// </param>
        public void SetPluginEntry(PersistencePluginBase <TPersistence, TUnitOfWork> plugin, [CanBeNull] object entry)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }

            if (!ReferenceEquals(plugin.Persistence, Persistence))
            {
                throw new ArgumentException("Plugin and UoW should belongs to the same persistence.", nameof(plugin));
            }

            if (entry == null)
            {
                _pluginEntries.Remove(plugin);
            }
            else
            {
                _pluginEntries[plugin] = entry;
            }
        }