Ejemplo n.º 1
0
        /// <summary>
        /// Attempts to load a new dataset and replaces the old one if load was successful
        /// </summary>
        /// <param name="arguments">The arguments for the update event.</param>
        protected virtual void UpdateLoadedDataSet(ResourceUpdatedEventArgs arguments)
        {
            RunExclusiveAction action = AllowMultipleThreadsLoadingDataSet ? m_action : s_action;

            action.Do(() =>
            {
                if (arguments.IsInitialLoad)
                {
                    ULSLogging.LogTraceTag(0x23821004 /* tag_967ae */, Categories.ConfigurationDataSet, Levels.Verbose,
                                           "Adding data set type '{0}' to cache.", typeof(T).Name);

                    if (Cache.GetOrAdd(typeof(IConfigurationDataSetLoader <T>),
                                       () => CreateCachedConfigurationDataSet(new CachedConfigurationDataSet <T>(DataSetOverride), arguments),
                                       out bool wasAdded) is CachedConfigurationDataSet <T> result && wasAdded)
                    {
                        OnLoad(result.LoadDetails);
                    }
                }
                else
                {
                    ULSLogging.LogTraceTag(0x23850399 /* tag_97qoz */, Categories.ConfigurationDataSet, Levels.Verbose,
                                           "Updating data set type '{0}' in cache.", typeof(T).Name);
                    CachedConfigurationDataSet <T> dataSets             = DataSets;
                    IList <ConfigurationDataSetLoadDetails> loadDetails = dataSets.LoadDetails;

                    if (Cache.AddOrUpdate(typeof(IConfigurationDataSetLoader <T>),
                                          () => CreateCachedConfigurationDataSet(dataSets, arguments),
                                          out bool wasUpdated) is CachedConfigurationDataSet <T> result && wasUpdated)
                    {
                        OnReload(loadDetails, result.LoadDetails);
                    }
                }
            });
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates the cached configuration data set.
 /// </summary>
 /// <param name="initialValue">The initial data set value.</param>
 /// <param name="arguments">The arguments for the update event.</param>
 /// <returns>The cached configuration data set.</returns>
 private CachedConfigurationDataSet <T> CreateCachedConfigurationDataSet(CachedConfigurationDataSet <T> initialValue,
                                                                         ResourceUpdatedEventArgs arguments)
 {
     initialValue.UpdateLoadedDataSet(arguments);
     return(initialValue);
 }