Example #1
0
        public static string Serialize(VCard vcard)
        {
            var builder = new StringBuilder();

            builder.Append(VersionProcessor.Serialize(vcard));
            builder.Append(FormattedNameProcessor.Serialize(vcard));
            builder.Append(NameProcessor.Serialize(vcard));
            builder.Append(BirthDayProcessor.Serialize(vcard));
            builder.Append(MailerProcessor.Serialize(vcard));
            builder.Append(TitleProcessor.Serialize(vcard));
            builder.Append(RoleProcessor.Serialize(vcard));
            builder.Append(TimeZoneInfoProcessor.Serialize(vcard));

            builder.Append(LogoProcessor.Serialize(vcard));
            builder.Append(PhotoProcessor.Serialize(vcard));

            builder.Append(NoteProcessor.Serialize(vcard));
            builder.Append(LastRevisionProcessor.Serialize(vcard));
            builder.Append(UrlProcessor.Serialize(vcard));
            builder.Append(UidProcessor.Serialize(vcard));
            builder.Append(OrganizationProcessor.Serialize(vcard));
            builder.Append(GeographyProcessor.Serialize(vcard));

            builder.Append(AddressesProcessor.Serialize(vcard));
            builder.Append(DeliveryAddressProcessor.Serialize(vcard));
            builder.Append(TelephonesProcessor.Serialize(vcard));
            builder.Append(EmailsProcessor.Serialize(vcard));
            builder.Append(ExtensionsProcessor.Serialize(vcard));

            return(builder.ToString());
        }
        public void Simple(string name, string winner, string loser)
        {
            int winnerScore = NameProcessor.GetScore(name, winner);
            int loserScore  = NameProcessor.GetScore(name, loser);

            Assert.Greater(winnerScore, loserScore);
        }
        public void WorksCorrectly()
        {
            var nameProcessor = new NameProcessor();

            nameProcessor.Add("bob");
            nameProcessor.Add("Alice");
            nameProcessor.Add("Bobby");
            nameProcessor.Add("alina");
            var bobs     = nameProcessor.GetNamesStartingWith("Bob");
            var alis     = nameProcessor.GetNamesStartingWith("Ali");
            var charlies = nameProcessor.GetNamesStartingWith("Charlie");

            Assert.Equal(2, bobs.Count);
            Assert.Equal(2, alis.Count);
            Assert.Empty(charlies);
            var bob1 = bobs[0];
            var bob2 = bobs[1];
            var ali1 = alis[0];
            var ali2 = alis[1];

            Assert.Equal("Bob", bob1);
            Assert.Equal("Bobby", bob2);
            Assert.Equal("Alice", ali1);
            Assert.Equal("Alina", ali2);
        }
Example #4
0
        public static List <Object> GetAll(Type t, string targetName)
        {
            List <string> paths = AssetDatabase.FindAssets("t:" + t.Name)
                                  .Select(AssetDatabase.GUIDToAssetPath)
                                  .ToList();

            NameProcessor.CutLowQualityPaths(paths, targetName);

            return(paths
                   .Select(path => AssetDatabase.LoadAssetAtPath(path, t))
                   .ToList());
        }
        public void SwitchesCase()
        {
            var nameProcessor = new NameProcessor();

            nameProcessor.Add("bob");
            nameProcessor.Add("Alice");
            nameProcessor.Add("Bobby");
            nameProcessor.Add("alina");

            var bobs     = nameProcessor.GetNamesStartingWith("Bob");
            var alis     = nameProcessor.GetNamesStartingWith("Ali");
            var charlies = nameProcessor.GetNamesStartingWith("Charlie");
        }
Example #6
0
        public static Component GetOne(Type t, string targetName)
        {
            ValidateCache();

            List <string> paths = PrefabCache.Instance.GetPrefabs(t);

            if (paths == null)
            {
                return(null);
            }

            (string bestPath, _) = NameProcessor.GetMatching(paths, targetName);

            return(AssetDatabase.LoadAssetAtPath <GameObject>(bestPath).GetComponent(t));
        }
Example #7
0
        public static Object GetOne(Type t, string targetName)
        {
            List <string> paths = AssetDatabase.FindAssets("t:" + t.Name)
                                  .Select(AssetDatabase.GUIDToAssetPath)
                                  .ToList();

            if (paths.Count == 0)
            {
                return(null);
            }

            (string bestPath, _) = NameProcessor.GetMatching(paths, targetName);

            return(AssetDatabase.LoadAssetAtPath(bestPath, t));
        }
        public void TestValidNameProcess(string[] unsortedNames, string[] expectedResultArray)
        {
            // Quick check to make sure that the test is valid (unsorted and expected result are same length)
            Assert.Equal(unsortedNames.Length, expectedResultArray.Length);

            // Arrange
            var expectedResult = String.Join("\r\n", expectedResultArray);
            var nameParser     = new NameParser(givenNameRegexPattern, surnameRegexPattern);
            var nameSorter     = new NameSorter();
            var nameProcessor  = new NameProcessor(nameSorter, nameParser);

            // Act
            var sortedNames = nameProcessor.ProcessFile(unsortedNames, nameConcat, stringComparer);

            // Assert
            Assert.Equal(expectedResult, sortedNames);
        }
Example #9
0
        public static GameObject GetOne(string targetName)
        {
            ValidateCache();

            (Type bestType, int typeScore)   = NameProcessor.GetMatching(PrefabCache.Instance.AllTypes, targetName);
            (string bestPath, int pathScore) = NameProcessor.GetMatching(PrefabCache.Instance.AllPaths, targetName);

            if (typeScore > pathScore)
            {
                List <string> paths = PrefabCache.Instance.GetPrefabs(bestType);

                if (paths != null)
                {
                    (bestPath, _) = NameProcessor.GetMatching(paths, targetName);
                }
            }

            return(AssetDatabase.LoadAssetAtPath <GameObject>(bestPath));
        }
        protected async Task <Game> TryGetClosestMatchAsync(GameInfo gameInfo)
        {
            Logger.Debug("TheGamesDb: Searching for '{0}', {1}", gameInfo.GameName, gameInfo.Platform);
            GameResult result = await _gamesDbApi.SearchGameByNameAsync(gameInfo.GameName, GetPlatformId(gameInfo.Platform)).ConfigureAwait(false);

            if (!IsValid(result))
            {
                return(null);
            }

            Game game = result.Data.Games.FirstOrDefault(g => NameProcessor.AreStringsEqual(g.GameTitle, gameInfo.GameName, MAX_SEARCH_DISTANCE) ||
                                                         (g.Alternates != null && g.Alternates.Any(a => NameProcessor.AreStringsEqual(a, gameInfo.GameName, MAX_SEARCH_DISTANCE))));

            if (game != null)
            {
                Logger.Debug("TheGamesDb: Matched '{0}' to '{1}'", gameInfo.GameName, game.GameTitle);
                _gamesDbApi.CacheGame(game.Id, result);
                return(game);
            }

            Logger.Debug("TheGamesDb: No match found for: '{0}'", gameInfo.GameName);
            return(null);
        }
Example #11
0
        public async Task <bool> FindAndUpdateGameAsync(GameInfo gameInfo)
        {
            if (!await InitAsync().ConfigureAwait(false))
            {
                return(false);
            }

            MobyGamesResult result;

            if (TryGetFromStorage(gameInfo.GameName, gameInfo.Platform, out result))
            {
                Logger.Debug("MobyGames: Retrieved from cache: '{0}' - '{1}'", gameInfo.GameName, gameInfo.Platform);
                UpdateGameInfo(gameInfo, result);
                return(true);
            }

            List <SearchResult> results;

            if (!Search(gameInfo.GameName, gameInfo.Platform, out results))
            {
                Logger.Debug("MobyGames: No results found for '{0}' - '{1}'", gameInfo.GameName, gameInfo.Platform);
                return(false);
            }

            Logger.Debug("MobyGames: Found {0} search results for '{1}' - '{2}'", results.Count, gameInfo.GameName, gameInfo.Platform);
            results = results.FindAll(r => r.Title == gameInfo.GameName || NameProcessor.GetLevenshteinDistance(r.Title, gameInfo.GameName) <= MAX_SEARCH_DISTANCE);
            if (results.Count == 0 || !Get(results[0].Id, out result))
            {
                Logger.Debug("MobyGames: No close match found for: '{0}' - '{1}'", gameInfo.GameName, gameInfo.Platform);
                return(false);
            }

            Logger.Debug("MobyGames: Matched '{0}' to '{1}' - '{2}'", results[0].Title, gameInfo.GameName, gameInfo.Platform);
            AddToStorage(gameInfo.GameName, gameInfo.Platform, result.Id);
            UpdateGameInfo(gameInfo, result);
            return(true);
        }
Example #12
0
        public static List <Component> GetAll(Type t, string targetName)
        {
            ValidateCache();

            List <string> paths = PrefabCache.Instance.GetPrefabs(t);

            if (paths == null)
            {
                return(null);
            }

            NameProcessor.CutLowQualityPaths(paths, targetName);

            List <GameObject> all = paths
                                    .Select(AssetDatabase.LoadAssetAtPath <GameObject>)
                                    .Where(asset => asset != null)
                                    .ToList();

            var prefabs = new List <Component>();

            foreach (GameObject o in all)
            {
                PrefabAssetType type = PrefabUtility.GetPrefabAssetType(o);
                if (type == PrefabAssetType.MissingAsset || type == PrefabAssetType.NotAPrefab)
                {
                    continue;
                }
                Component c = o.GetComponent(t);
                if (c != null)
                {
                    prefabs.Add(c);
                }
            }

            return(prefabs);
        }
 public void SplitPascalCase(string name, string expected)
 {
     Assert.AreEqual(expected, NameProcessor.SplitPascalCase(name));
 }
Example #14
0
 public Task <bool> FindAndUpdateGameAsync(GameInfo gameInfo)
 {
     TheGamesDbWrapperV2.TryGetTGDBId(gameInfo);
     NameProcessor.CleanupTitle(gameInfo);
     return(_onlineMatcher.FindAndUpdateGameAsync(gameInfo));
 }