public void ThenNoRoutesFollowTheRoutesFromTheController(string controllerName)
        {
            var count = 0;
            var indexOfLastRouteForController = 0;
            var routes = RouteTable.Routes.Cast<Route>();

            foreach (var route in routes.ToList())
            {
                var routeControllerName = route.Defaults["controller"].ToString();
                var skipControllerNames = new[]
                {
                    "RoutePrecedenceAmongTheSitesRoutes",
                    "RoutePrecedenceViaRouteProperties"
                };

                if (skipControllerNames.Any(routeControllerName.EndsWith))
                {
                    // Skip the controllers that will come after controllers registered through the config object
                    // due to have actions that specify a SitePrecedence property.
                    continue;
                }

                if (routeControllerName == controllerName)
                    indexOfLastRouteForController = count;

                count++;
            }

            Assert.That(indexOfLastRouteForController, Is.EqualTo(count - 1));
        }
		private static bool IfEitherIsEmptyReturnTheOtherOrEmpty(QueryContainer leftContainer, QueryContainer rightContainer, out QueryContainer queryContainer)
		{
			var combined = new[] {leftContainer, rightContainer};
			var any = combined.Any(bf => bf == null || bf.IsConditionless);
			queryContainer = any ? combined.FirstOrDefault(bf => bf != null && !bf.IsConditionless) : null;
			return any;
		}
 static bool IsTextFileType(string name)
 {
     var imageFileTypes = new[]
     {
         ".txt"
     };
     return imageFileTypes.Any(name.EndsWith);
 }
 static bool IsImageFileType(string name)
 {
     var imageFileTypes = new[]
     {
         ".png",
         ".jpg"
     };
     return imageFileTypes.Any(name.EndsWith);
 }
        // 比較していない場合はOK
        public static object OK1()
        {
            var test = new[] { "a", "b", }.Where(s => s.StartsWith("a"));
            if (test.Any())
            {
                return test;
            }

            return null;
        }
        public void ContactFormEntryCreating(ContactFormCreatingContext context)
        {
            var text = context.ContactFormEntry.As<BodyPart>().Text;
            var spamTerms = new[] { "viagra", "opportunity", "win!" };

            if (!spamTerms.Any(text.Contains))
                return;

            context.Cancel = true;
            _notifier.Warning(T("Your message is rated as spam and therefore not delivered."));
        }
예제 #7
0
        public void Import_RestFiles_into_S3()
        {
            var fs = new FileSystemVirtualPathProvider(appHost, "~/restfiles".MapHostAbsolutePath());
            var skipDirs = new[] { "restfiles/files" };

            foreach (var file in fs.GetAllFiles())
            {
                if (skipDirs.Any(x => file.VirtualPath.StartsWith(x))) continue;
                s3.WriteFile(file, "restfiles/files".CombineWith(file.VirtualPath));
            }
        }
예제 #8
0
        // ReSharper disable UnusedParameter.Local
        /// <summary>
        /// Checks if script makes insert into version history table
        /// </summary>
        public static bool IsVersionInsertPresent(DbVersion dbVersion, string script)
        {
            var versionInsertRegexes =
            new[] {
              string.Format("insert\\s+(into)?\\s+\\[?version(history)?\\]?(.+?){0}\\.{1}{2}{3}", dbVersion.Major, dbVersion.Minor, RevisionRegex(dbVersion), BuildRegex(dbVersion)),
              string.Format("insert\\s+into\\s+#temp(.+?)VALUES(.*?){0}\\.{1}{2}{3}", dbVersion.Major, dbVersion.Minor, RevisionRegex(dbVersion), BuildRegex(dbVersion)),
            }
              .Select(pattern => new Regex(pattern, RegexOptions.IgnoreCase));

              return versionInsertRegexes.Any(r => r.IsMatch(script));
        }
예제 #9
0
        public void BonusMultiplierIsCalledCorrectNumberOfTimes()
        {
            _scorer.Register(new Strike());
            _scorer.Register(new Spare());
            _scorer.Register(new NormalRoll());

            var rollTypes = new[] {RollTypes.Strike, RollTypes.Spare, RollTypes.Normal};

            var _ = _bonusMultiplier.Received(3).Current;
            _bonusMultiplier.Received(3).Register(Arg.Is<RollTypes>(t => rollTypes.Any(t_ => t_ == t)));
            _bonusMultiplier.DidNotReceive().Register(RollTypes.Bonus);
        }
        public void ContactFormEntryCreating(ContactFormCreatingContext context)
        {
            var text = context.ContactFormEntry.As<BodyPart>().Text;
            var spamTerms = new[] { "viagra", "opportunity", "win!", "win", "$$$", "Lose weight", "Extra income", "Money making", "Earn $", "Save $" };

            if (!spamTerms.Any(text.Contains))
            {
                _notifier.Information(T("Bericht geaccepteerd"));
                return;
            }

            context.Cancel = true;
            _notifier.Warning(T("Uw bericht is als spam beoordeeld en is daarom niet verstuurd."));
        }
예제 #11
0
        public void Execute()
        {
            var numbers = new[] {1, 2, 3};

            //
            // Any拡張メソッドは、一つでも条件に当てはまるものが存在するか否かを判別するメソッドである。
            // この拡張メソッドは、引数無しのバージョンと引数にpredicateを渡すバージョンの2つが存在する。
            //
            // 引数を渡さずAny拡張メソッドを呼んだ場合、Any拡張メソッドは
            // 該当シーケンスに要素が存在するか否かのみで判断する。
            // つまり、要素が一つでも存在する場合は、Trueとなる。
            //
            // 引数にpredicateを指定するバージョンは、シーケンスの各要素に対してpredicateを適用し
            // 一つでも条件に合致するものが存在した時点で、Trueとなる。
            //
            Output.WriteLine("=========== 引数無しでAny拡張メソッドを利用 ===========");
            Output.WriteLine("要素有り? = {0}", numbers.Any());
            Output.WriteLine("================================================");

            Output.WriteLine("=========== predicateを指定してAny拡張メソッドを利用 ===========");
            Output.WriteLine("要素有り? = {0}", numbers.Any(item => item >= 5));
            Output.WriteLine("要素有り? = {0}", numbers.Any(item => item <= 5));
            Output.WriteLine("================================================================");
        }
        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            //these would usually come from a database, or cache.
            var categories = new[] { "restaurants", "cafes", "bistros" };

            if (values[parameterName] == null)
                return false;

            //get the category passed in to the route
            var category = values[parameterName].ToString();

            //now we check our categories, and see if it exists
            return categories.Any(x => x == category.ToLower());

            // url such as /category1/whatever will match
            // url such as /category4/whatever will not
        }
예제 #13
0
        public static string ConvertTextForSEOURL(string inputText)
        {
            if (string.IsNullOrEmpty(inputText))
            {
                return string.Empty;
            }

            var charsForRepl = new [] { 'á', 'č', 'ď', 'é', 'ě', 'í', 'ň', 'ó', 'ř', 'š', 'ť', 'ú', 'ů', 'ý', 'ž', ' ' };
            var charsToRepl = new [] { 'a', 'c', 'd', 'e', 'e', 'i', 'n', 'o', 'r', 's', 't', 'u', 'u', 'y', 'z', '-' };
            var charsNotAllowed = new [] { '"', '~', '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '=', '+', '[', ']', '{', '}', '|', '<', '>', ',', '.', '/', '?', '\'', '\\', ':', '\r', '\n' };

            inputText = inputText.ToLower();

            var retText = "";

            for (var i = 0; i < inputText.Length; i++)
            {
                bool wasReplace = false;
                bool doSkip = charsNotAllowed.Any(c => inputText[i] == c);

                for (var j = 0; j < charsForRepl.Length; j++)
                {
                    if (inputText[i] == charsForRepl[j])
                    {
                        retText = retText + charsToRepl[j];
                        wasReplace = true;
                        break;
                    }
                }

                if (!doSkip && !wasReplace)
                {
                    retText = retText + inputText[i];
                }
            }

            return retText;
        }
        // 一部のパスでインスタンスがある場合は、OK
        public static bool OK3(bool flg)
        {
            var sequence = new[] { "1", "2", "3", }.Where(e => e is string);
            if (flg)
            {
                sequence = new[] { "1", "2", "3", }.ToList();
            }

            if (sequence != null)
            {
                return sequence.Any();
            }

            return false;
        }
예제 #15
0
		private static void Generate35(string srcPath, string destFile, params string[] references)
		{
			var database = XDocument.Load(srcPath);
			foreach (var element in database.Root.Descendants(xmlns + "DefineConstants").ToArray())
			{
				if (element.Value.EndsWith(";") == false)
					element.Value += ";";
				element.Value += "NET35";
			}

			foreach (var element in database.Root.Descendants(xmlns + "ProjectReference").ToArray())
			{
				if (references.Contains(element.Element(xmlns + "Name").Value) == false)
					continue;
				element.Attribute("Include").Value = element.Attribute("Include").Value.Replace(".csproj", ".g.3.5.csproj");
				{
					element.Element(xmlns + "Project").Value = "{4C18FC25-0B1E-42E3-A423-3A99F1AC57EE}";
					element.Element(xmlns + "Name").Value += "-3.5";
				}
			}

			foreach (var element in database.Root.Descendants(xmlns + "Reference").ToArray())
			{
				if (element.Attribute("Include").Value == "Microsoft.CSharp")
					element.Remove();
				if (element.Attribute("Include").Value == "AsyncCtpLibrary")
					element.Remove();
				if (element.Attribute("Include").Value == "System.ComponentModel.Composition")
					element.Remove();

				var nugetPakcages = new[] {"Newtonsoft.Json", "NLog"};
				if (nugetPakcages.Any(x => element.Attribute("Include").Value.StartsWith(x)))
				{
					element.Element(xmlns + "HintPath").Value = element.Element(xmlns + "HintPath").Value.Replace("net40", "net35");
				}
			}

			foreach (var element in database.Root.Descendants(xmlns + "DocumentationFile").ToArray())
			{
				element.Value = element.Value.Replace(".XML", "-3.5.XML");
			}
			foreach (var element in database.Root.Descendants(xmlns + "TargetFrameworkVersion"))
			{
				element.Value = "v3.5";
			}
			foreach (var element in database.Root.Descendants(xmlns + "TargetFrameworkProfile"))
			{
				element.Value = "Client";
			}
			foreach (var element in database.Root.Descendants(xmlns + "AssemblyName"))
			{
				element.Value += "-3.5";
			}
			using (var xmlWriter = XmlWriter.Create(destFile,
													new XmlWriterSettings
													{
														Indent = true
													}))
			{
				database.WriteTo(xmlWriter);
				xmlWriter.Flush();
			}
		}
예제 #16
0
		private static bool IfEitherIsEmptyReturnTheOtherOrEmpty(FilterContainer leftContainer, FilterContainer rightContainer,
			out FilterContainer filterContainer)
		{
			var combined = new[] {leftContainer, rightContainer};
			filterContainer = !combined.Any(bf => bf == null || bf.IsConditionless)
				? null
				: combined.FirstOrDefault(bf => bf != null && !bf.IsConditionless) ?? CreateEmptyContainer();
			return filterContainer != null;
		}
예제 #17
0
        private bool IsGrounded()
        {
            var size = .3f;
            var halfHeight = .45f;
            var castDistance = .15f;

            var rays = new[]
            {
                new Vector3(0, halfHeight, 0),

                new Vector3(size, halfHeight, size),
                new Vector3(-size, halfHeight, -size),
                new Vector3(-size, halfHeight, size),
                new Vector3(size, halfHeight, -size),
                new Vector3(0, halfHeight, size),
                new Vector3(0, halfHeight, -size),
                new Vector3(-size, halfHeight, 0),
                new Vector3(size, halfHeight, 0),

                new Vector3(size/2, halfHeight, size/2),
                new Vector3(-size/2, halfHeight, -size/2),
                new Vector3(-size/2, halfHeight, size/2),
                new Vector3(size/2, halfHeight, -size/2),
                new Vector3(0, halfHeight, size/2),
                new Vector3(0, halfHeight, -size/2),
                new Vector3(-size/2, halfHeight, 0),
                new Vector3(size/2, halfHeight, 0),

                new Vector3(size/3, halfHeight, size/3),
                new Vector3(-size/3, halfHeight, -size/3),
                new Vector3(-size/3, halfHeight, size/3),
                new Vector3(size/3, halfHeight, -size/3),
                new Vector3(0, halfHeight, size/3),
                new Vector3(0, halfHeight, -size/3),
                new Vector3(-size/3, halfHeight, 0),
                new Vector3(size/3, halfHeight, 0),
            };

            foreach (var ray in rays)
            {
                Debug.DrawLine(transform.position - ray, transform.position - ray - (Vector3.down * castDistance));
            }

            return rays.Any(ray => Physics.Raycast(transform.position - ray, Vector3.down, castDistance));
        }