Exemple #1
0
        public override void Bind(PropertyInfo property, IBindingContext context)
        {
            var chain    = context.Service <ICurrentChain>();
            var resource = ResourceHash.For(new VaryByResource(chain));

            property.SetValue(context.Object, resource, null);
        }
Exemple #2
0
        public void resource_hash_is_predictable()
        {
            var vary1 = new SimpleVaryBy().With("a", "1").With("b", "2");
            var vary2 = new SimpleVaryBy().With("a", "1").With("b", "2");
            var vary3 = new SimpleVaryBy().With("c", "3").With("d", "4");
            var vary4 = new SimpleVaryBy().With("c", "3").With("d", "4");
            var vary5 = new SimpleVaryBy().With("e", "5").With("f", "6");

            ResourceHash.For(vary1).ShouldEqual(ResourceHash.For(vary2));
            ResourceHash.For(vary1, vary3).ShouldEqual(ResourceHash.For(vary2, vary4));

            ResourceHash.For(vary1, vary3).ShouldNotEqual(ResourceHash.For(vary1, vary5));
        }
Exemple #3
0
        public void SetUp()
        {
            var theHttpRequest = new CurrentChain(new BehaviorChain(), new Dictionary <string, object>());

            theExpectedHash = ResourceHash.For(theHttpRequest);

            FubuApplication.SetupNamingStrategyForHttpHeaders();

            theEtagRequest = BindingScenario <ETaggedRequest> .Build(x =>
            {
                x.Service <ICurrentChain>(theHttpRequest);
                x.Data("If-None-Match", "12345");
            });
        }
        public void Configure(BehaviorGraph graph)
        {
            if (Latched)
            {
                return;
            }

            // TODO -- Hokum.  Needs to be pluggable.
            var headerCache = graph.Services.DefaultServiceFor <IHeadersCache>().Value.As <IHeadersCache>();
            var chain       = createAssetContentChain(graph);

            chain.AddFilter(new EtagInvocationFilter(headerCache, args =>
            {
                var currentChain = args.Get <ICurrentChain>();
                return(ResourceHash.For(currentChain));
            }));


            addCaching(chain);
            addWritingAction(chain);
        }