示例#1
0
        public void SetParameter(DescTable desc)
        {
            desc = Factory <DescTable> .Veritifate(desc);

            Id   = desc.Id;
            Text = desc.Text;
        }
示例#2
0
        //アイテム情報を取得する
        static IEnumerable <DescTable> GetDescTable(string filePath)
        {
            IEnumerable <DescTable> list;

            if (File.Exists(filePath))
            {
                //ファイルを読み込み、表示修飾に用いるテキストを削除
                var readFile = File.ReadLines(filePath, Encoding.GetEncoding("shift-jis"))
                               .Select(val => Regex.Replace(val, @"\^\S{6}", ""))
                               .Select(val => Regex.Replace(val, @"\s?_\s*", ""));

                var fileText = string.Join(Environment.NewLine, readFile);


                //一致した正規表現からDescTableを生成する。
                var descPattern = $@"(\d+)#\s*([\S\s]+?)\s*#";
                var descRegex   = new Regex(descPattern);

                Func <Match, DescTable> CreateDescTable = val =>
                {
                    var id   = val.Groups[1].Value;
                    var text = val.Groups[2].Value;

                    return(new DescTable(id, text));
                };

                //一致した正規表現からIEnumerable<Property>を作成する。
                var propertyPattern = @"(\S*?)\s+?[::]\s+?(.+?)($|\s{2,})";

                var propertyRegex = new Regex(propertyPattern);

                Func <DescTable, IEnumerable <ItemProperty> > CreateProperties = val =>
                {
                    return(propertyRegex.Matches(val.Text)
                           .Cast <Match>()
                           .Select(match =>
                    {
                        var name = match.Groups[1].Value;
                        var text = match.Groups[2].Value;

                        return new ItemProperty {
                            Name = name, Text = text
                        };
                    }));
                };


                list = descRegex.Matches(fileText).Cast <Match>()
                       .Select(CreateDescTable)
                       .Select(val => val.SetProperty(CreateProperties(val)))
                       .ToArray();
            }
            else
            {
                list = new DescTable[0];
            }

            return(list);
        }
示例#3
0
        public Item(DescTable desc, string name)
        {
            desc = Factory <DescTable> .Veritifate(desc);

            SetParameter(desc);

            Name = name;
        }
示例#4
0
 public Item(DescTable desc, string name) : base(desc.Id, desc.Text)
 {
     Name = name;
 }