Exemple #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);
            }
        }
Exemple #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;
        }
Exemple #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);
        }
Exemple #4
0
		public void SetUp()
		{
			radar = new TargetingRadar(new DetectorBase[] { new Always(), new Never() });
			context = radar.BuildTargetingContext(new Fakes.FakeHttpContext());
		}
Exemple #5
0
		public override bool IsTarget(TargetingContext context)
		{
			return isTarget;
		}
Exemple #6
0
 public abstract bool IsTarget(TargetingContext context);