コード例 #1
0
ファイル: CharacterProfilerData.cs プロジェクト: say1981/Rawr
        public CharacterProfilerData(string sFileName)
        {
            SavedVariablesDictionary savedVariables = SavedVariablesParser.parse(sFileName);

            if (!savedVariables.ContainsKey("myProfile"))
            {
                throw new InvalidDataException("Expected myProfile variable in file.");
            }

            SavedVariablesDictionary realms = (SavedVariablesDictionary)savedVariables["myProfile"];

            foreach (string sRealm in realms.Keys)
            {
                bool bHaveCharacters = false;

                CharacterProfilerRealm realm = new CharacterProfilerRealm(sRealm);

                SavedVariablesDictionary characterContainer = (SavedVariablesDictionary)realms[sRealm];
                SavedVariablesDictionary characters         = (SavedVariablesDictionary)characterContainer["Character"];

                foreach (string sCharacter in characters.Keys)
                {
                    SavedVariablesDictionary   characterInfo = (SavedVariablesDictionary)characters[sCharacter];
                    CharacterProfilerCharacter character     = new CharacterProfilerCharacter(sCharacter, sRealm, characterInfo);
                    realm.Characters.Add(character);
                    bHaveCharacters = true;
                }

                if (bHaveCharacters)
                {
                    m_realms.Add(realm);
                }
            }
        }
コード例 #2
0
        public CharacterProfilerData(string sFileName)
        {
            SavedVariablesDictionary savedVariables = SavedVariablesParser.parse(sFileName);

            // TODO: check the version

            if (!savedVariables.ContainsKey("myProfile"))
            {
                throw new InvalidDataException("Expected myProfile variable in file.");
            }

            SavedVariablesDictionary realms = (SavedVariablesDictionary)savedVariables["myProfile"];

            foreach (string sRealm in realms.Keys)
            {
                bool bHaveCharacters = false;

                CharacterProfilerRealm realm = new CharacterProfilerRealm(sRealm);

                SavedVariablesDictionary characterContainer = (SavedVariablesDictionary)realms[sRealm];
                SavedVariablesDictionary characters = (SavedVariablesDictionary)characterContainer["Character"];

                foreach (string sCharacter in characters.Keys)
                {
                    try {
                        SavedVariablesDictionary characterInfo = (SavedVariablesDictionary)characters[sCharacter];
                        CharacterProfilerCharacter character = new CharacterProfilerCharacter(sCharacter, sRealm, characterInfo);
                        realm.Characters.Add(character);
                        bHaveCharacters = true;
                    } catch (Exception error) {
                        m_errors.Add(new CharacterProfilerFailedImport(sRealm, sCharacter, error.ToString()));
                    }
                }

                if (bHaveCharacters) { m_realms.Add(realm); }
            }
        }