/// <summary>
        /// Call <see cref="ICacheInvalidator.OnFieldChange"/> or
        /// <see cref="ICacheInvalidator.OnRelationshipChange"/> for any <see cref="FieldType"/>
        /// or <see cref="Relationship"/> saved or deleted directly.
        /// </summary>
        /// <param name="entities">
        /// The entities to check. This cannot be null or contain null.
        /// </param>
        /// <param name="cacheInvalidator">
        /// The <see cref="ICacheInvalidator"/> to notify. This cannot be null.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// No argument can be null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="entities"/> cannot contain null.
        /// </exception>
        protected internal static void InvalidateFieldOrRelationshipIfEntityIsFieldOrRelationship(
            IList <IEntity> entities, ICacheInvalidator cacheInvalidator)
        {
            if (entities == null)
            {
                throw new ArgumentNullException("entities");
            }
            if (entities.Contains(null))
            {
                throw new ArgumentException("Cannot contain null", "entities");
            }
            if (cacheInvalidator == null)
            {
                throw new ArgumentNullException("cacheInvalidator");
            }

            if (entities.Any(e => e.Is <Relationship>()))
            {
                cacheInvalidator.OnRelationshipChange(
                    entities.Where(e => e.Is <Relationship>()).Select(e => new EntityRef(e)).ToList());
            }
            if (entities.Any(e => e.Is <FieldType>()))
            {
                cacheInvalidator.OnFieldChange(
                    entities.Where(e => e.Is <FieldType>()).Select(e => e.Id).ToList());
            }
        }
Exemplo n.º 2
0
 public HostsController(IApiSettingsData apiSettings,
                        IApiChaosConfigurationSettingsData chaosConfigurationSettings,
                        ICacheInvalidator cacheInvalidator)
 {
     _apiSettings = apiSettings;
     _chaosConfigurationSettings = chaosConfigurationSettings;
     _cacheInvalidator           = cacheInvalidator;
 }
 public ConfigurationController(ICacheInvalidator cacheInvalidator, IApiSettingsData apiSettingsData,
                                IApiChaosConfigurationSettingsData chaosConfigurationSettings,
                                IChaosProxyHostSettings chaosProxyHostSettings)
 {
     _cacheInvalidator           = cacheInvalidator;
     _apiSettingsData            = apiSettingsData;
     _chaosConfigurationSettings = chaosConfigurationSettings;
     _chaosProxyHostSettings     = chaosProxyHostSettings;
 }
        public ConfigurationController(ICacheInvalidator cacheInvalidator, IApiSettingsData apiSettingsData, IApiChaosConfigurationSettingsData chaosConfigurationSettings, IChaosProxyHostSettings chaosProxyHostSettings)
        {
            this.cacheInvalidator = cacheInvalidator;
            this.apiSettingsData = apiSettingsData;
            this.chaosConfigurationSettings = chaosConfigurationSettings;
            this.chaosProxyHostSettings = chaosProxyHostSettings;

            var mapperConfiguration = new MapperConfiguration(cfg => cfg.CreateMap<ApiConfiguration, ClientProxyApiConfiguration>());
            mapper = mapperConfiguration.CreateMapper();
        }
 /// <summary>
 /// Registers a cache invalidator so that it can be notified to invalidate any content
 /// that is changed.
 /// </summary>
 /// <param name="invalidator">
 /// The invalidator to notify when changes occur.
 /// </param>
 /// <remarks>
 /// For example, if the "Home > About" content node changes, the invalidator will be notified
 /// based on the content type alias of the "Home > About" node.
 /// </remarks>
 public static void RegisterContentInvalidatorForAliases(ICacheInvalidator invalidator,
                                                         IEnumerable <string> aliases)
 {
     if (invalidator != null)
     {
         lock (InvalidatorsForAliasesLock)
         {
             var weakReference = new WeakReference <ICacheInvalidator>(invalidator);
             InvalidatorsForAliases.Add(weakReference);
         }
     }
 }
        public CacheInvalidatorCallback(ICacheInvalidator cacheInvalidator)
        {
            _invalidator = cacheInvalidator;
            _callback = new GenericCallback((out int return_type, out jvalue return_value, IntPtr input) =>
            {
                try
                {
                    string key = (string)JavaClass.GetTypedInstance(typeof(string), jvalue.From(input).l);
                    _invalidator.Invalidate(key);

                    return_value = new jvalue();
                    return_type = 0;
                }
                catch (Exception exception)
                {
                    return_value = jvalue.CreateCBRetVal(exception);
                    return_type = 1;
                }

                return 0;
            });

            base.JObject = _constructor.construct(0, _callback);
        }
Exemplo n.º 7
0
 public static Task Refresh(this ICacheInvalidator inv, string name, Func <Task <IDocument> > doc, Func <Task <Stream> > result) =>
 inv.Refresh(name, doc, async() => {
     IDocument d = await doc();
     return(await d.OpenReadAsync(CancellationToken.None));
 });
Exemplo n.º 8
0
 public static Task Allocated(this ICacheInvalidator inv, string name, Func <Task <IDocument> > doc) =>
 inv.Allocated(name, doc, async() => {
     IDocument d = await doc();
     return(await d.OpenReadAsync(CancellationToken.None));
 });
Exemplo n.º 9
0
 public FileCountAllocator(int fileCount, ICacheInvalidator cacheInvalidator = null)
 {
     MaxAllocatedFiles = fileCount;
     CacheInvalidator  = cacheInvalidator;
 }
Exemplo n.º 10
0
 public MetadataCache(ICache <Tuple <int, TKey>, TValue> innerCache, IUserRuleSetProvider ruleSetProvider, ICacheInvalidator invalidator) : base(innerCache, ruleSetProvider)
 {
     _invalidator = invalidator;
 }
 public ChaosProxyHostSettings(ICacheInvalidator cacheInvalidator, IChaosTableClient tableClient)
 {
     this.tableClient = tableClient;
     cacheInvalidator.HostConfigurationChanged += OnHostConfigurationChanged;
 }
 public CacheInvalidationInterceptor(ICacheInvalidator cacheInvalidator)
 {
     _cacheInvalidator = cacheInvalidator;
 }
 public ChaosHttpClientFactory(ICacheInvalidator cacheInvalidator)
 {
     cacheInvalidator.HostConfigurationChanged += OnHostConfigurationChanged;
 }