Ejemplo n.º 1
0
 void IClassifyObjectProcessor.BeforeSerialize()
 {
     // This is a bit hacky, but let’s set License to its default value (which happens to be Restricted) to make the serializer omit that field.
     // AfterDeserialize() will set it back to OpenSource if SourceUrl != null.
     if (License == KtaneModuleLicense.OpenSource && SourceUrl != null)
     {
         License = KtaneModuleLicense.Restricted;
     }
 }
Ejemplo n.º 2
0
        void IClassifyObjectProcessor.AfterDeserialize()
        {
            if (SortKey == null || SortKey == "")
            {
                SortKey = Regex.Replace(Name, @"^The |[^a-zA-Z0-9]", "", RegexOptions.IgnoreCase).ToUpperInvariant();
            }

            if (Type == KtaneModuleType.Regular || Type == KtaneModuleType.Needy || Type == KtaneModuleType.Holdable)
            {
                DefuserDifficulty ??= KtaneModuleDifficulty.Easy;
                ExpertDifficulty ??= KtaneModuleDifficulty.Easy;
            }
            else
            {
                DefuserDifficulty = null;
                ExpertDifficulty  = null;
                RuleSeedSupport   = KtaneSupport.NotSupported;
            }

            if (TutorialVideos != null && TutorialVideos.Length == 0)
            {
                TutorialVideos = null;
            }

            if (Type != KtaneModuleType.Regular)
            {
                Souvenir = new KtaneSouvenirInfo {
                    Status = KtaneModuleSouvenir.NotACandidate
                }
            }
            ;
            else if (Souvenir != null && Souvenir.Status == KtaneModuleSouvenir.Unexamined)
            {
                Souvenir = null;
            }
            else if (Souvenir != null && Souvenir.Status != KtaneModuleSouvenir.Considered)
            {
                Souvenir.Explanation = null;
            }

            if (Ignore != null && Ignore.Length == 0)
            {
                Ignore = null;
            }

            if (Symbol != null && Symbol.Length > 0)
            {
                Symbol = Symbol.Substring(0, 1).ToUpperInvariant() + Symbol.Substring(1).ToLowerInvariant();
            }

            if (SourceUrl != null)
            {
                License = KtaneModuleLicense.OpenSource;
            }
        }
Ejemplo n.º 3
0
        void IClassifyObjectProcessor.AfterDeserialize()
        {
            if (SortKey == null || SortKey == "")
            {
                SortKey = Regex.Replace(Name, @"^The |[^a-zA-Z0-9]", "", RegexOptions.IgnoreCase).ToUpperInvariant();
            }

            if (Type == KtaneModuleType.Regular || Type == KtaneModuleType.Needy)
            {
                DefuserDifficulty = DefuserDifficulty ?? KtaneModuleDifficulty.Easy;
                ExpertDifficulty  = ExpertDifficulty ?? KtaneModuleDifficulty.Easy;
            }
            else
            {
                DefuserDifficulty = null;
                ExpertDifficulty  = null;
                TwitchPlays       = null;
                RuleSeedSupport   = KtaneSupport.NotSupported;
            }

            if (TutorialVideoUrl == "")
            {
                TutorialVideoUrl = null;
            }

            if (Souvenir != null && Souvenir.Status == KtaneModuleSouvenir.Unexamined)
            {
                Souvenir = null;
            }
            else if (Souvenir != null && Souvenir.Status != KtaneModuleSouvenir.Considered)
            {
                Souvenir.Explanation = null;
            }

            if (TwitchPlays != null)
            {
                TwitchPlays.NeedyScoring = Type == KtaneModuleType.Needy ? (TwitchPlays.NeedyScoring ?? KtaneTwitchPlaysNeedyScoring.Solves).Nullable() : null;
            }

            if (Ignore != null && Ignore.Length == 0)
            {
                Ignore = null;
            }

            if (Symbol != null && Symbol.Length > 0)
            {
                Symbol = Symbol.Substring(0, 1).ToUpperInvariant() + Symbol.Substring(1).ToLowerInvariant();
            }

            if (SourceUrl != null)
            {
                License = KtaneModuleLicense.OpenSource;
            }
        }