Example #1
0
        public static IEnumerable <string> GetTargetedPaths(this TargetingContext context, string templateUrl)
        {
            if (string.IsNullOrEmpty(templateUrl))
            {
                yield break;
            }

            var extension = Url.GetExtension(templateUrl);

            if (string.IsNullOrEmpty(extension))
            {
                if (templateUrl[templateUrl.Length - 1] != '/')
                {
                    yield break;
                }

                foreach (var target in context.TargetedBy)
                {
                    yield return(templateUrl + target.Name + "/");
                }
                yield break;
            }

            var templateUrlWithoutExtension = templateUrl.Substring(0, templateUrl.Length - extension.Length);

            foreach (var target in context.TargetedBy)
            {
                yield return(templateUrlWithoutExtension + "_" + target.Name + extension);
            }
        }
Example #2
0
        public virtual TargetingContext BuildTargetingContext(HttpContextBase context)
        {
            var ctx = new TargetingContext(context);

            foreach (var detector in Detectors)
                if (detector.IsTarget(ctx))
                    ctx.TargetedBy.Add(detector);

            return ctx;
        }
Example #3
0
        public virtual TargetingContext BuildTargetingContext(HttpContextBase context)
        {
            var ctx = new TargetingContext(context);

            foreach (var detector in Detectors)
            {
                if (detector.IsTarget(ctx))
                {
                    ctx.TargetedBy.Add(detector);
                }
            }

            return(ctx);
        }
Example #4
0
		public void SetUp()
		{
			radar = new TargetingRadar(new DetectorBase[] { new Always(), new Never() });
			context = radar.BuildTargetingContext(new Fakes.FakeHttpContext());
		}
Example #5
0
		public override bool IsTarget(TargetingContext context)
		{
			return isTarget;
		}
Example #6
0
 public abstract bool IsTarget(TargetingContext context);