Ejemplo n.º 1
0
        /// <summary>
        /// 文中に含まれるパーティメンバの名前を設定した形式に置換する
        /// </summary>
        /// <param name="text">置換対象のテキスト</param>
        /// <returns>
        /// 置換後のテキスト</returns>
        public string ReplacePartyMemberName(
            string text,
            NameStyles style)
        {
            var r = text;

            var party = this.GetPartyList();

            foreach (var pc in party)
            {
                if (string.IsNullOrEmpty(pc.Name) ||
                    string.IsNullOrEmpty(pc.NameFI) ||
                    string.IsNullOrEmpty(pc.NameIF) ||
                    string.IsNullOrEmpty(pc.NameII))
                {
                    continue;
                }

                switch (style)
                {
                case NameStyles.FullName:
                    r = r.Replace(pc.NameFI, pc.Name);
                    r = r.Replace(pc.NameIF, pc.Name);
                    r = r.Replace(pc.NameII, pc.Name);
                    break;

                case NameStyles.FullInitial:
                    r = r.Replace(pc.Name, pc.NameFI);
                    break;

                case NameStyles.InitialFull:
                    r = r.Replace(pc.Name, pc.NameIF);
                    break;

                case NameStyles.InitialInitial:
                    r = r.Replace(pc.Name, pc.NameII);
                    break;
                }
            }

            return(r);
        }
Ejemplo n.º 2
0
        public string GetName(
            NameStyles style)
        {
            switch (style)
            {
            case NameStyles.FullName:
                return(this.Name);

            case NameStyles.FullInitial:
                return(!string.IsNullOrEmpty(this.NameFI) ? this.NameFI : this.Name);

            case NameStyles.InitialFull:
                return(!string.IsNullOrEmpty(this.NameIF) ? this.NameIF : this.Name);

            case NameStyles.InitialInitial:
                return(!string.IsNullOrEmpty(this.NameII) ? this.NameII : this.Name);

            default:
                return(this.Name);
            }
        }
Ejemplo n.º 3
0
        public static string NameToInitial(
            string name,
            NameStyles style)
        {
            if (string.IsNullOrEmpty(name) ||
                name == UnknownName)
            {
                return(UnknownName);
            }

            var blocks = name.Split(' ');

            if (blocks.Length < 2)
            {
                return(name);
            }

            switch (style)
            {
            case NameStyles.FullName:
                name = $"{ToCamelCase(blocks[0])} {ToCamelCase(blocks[1])}";
                break;

            case NameStyles.FullInitial:
                name = $"{ToCamelCase(blocks[0])} {blocks[1].Substring(0, 1)}.";
                break;

            case NameStyles.InitialFull:
                name = $"{blocks[0].Substring(0, 1)}. {ToCamelCase(blocks[1])}";
                break;

            case NameStyles.InitialInitial:
                name = $"{blocks[0].Substring(0, 1)}. {blocks[1].Substring(0, 1)}.";
                break;
            }

            return(name);
        }