예제 #1
0
        public IEnumerable <string> GetAuthors()
        {
            if (string.IsNullOrWhiteSpace(RawText))
            {
                return(null);
            }

            var withoutTitle = RawText.Split('\t').First();

            var differentAuthors = withoutTitle.Split(" en ").Select(name => name.Trim());

            return(differentAuthors);
        }
예제 #2
0
        public List <Dictionary <string, string> > Parse()
        {
            List <Dictionary <string, string> > parsedResult = new List <Dictionary <string, string> >();

            string[] records = RawText.Split(this.LineDelimiter);

            int           startingRow = 0;
            List <string> fieldList   = new List <string>();

            if (this.HasHeaderRow)
            {
                startingRow = 1;
                fieldList   = LoadFieldNamesFromHeaderRow();
            }

            for (int i = startingRow; i < records.Length; i++)
            {
                string record = records[i];

                string[] fields = record.Split(this.Delimiter);
                Dictionary <string, string> recordItem = new Dictionary <string, string>();

                int fieldIncrementer = 0;


                foreach (var field in fields)
                {
                    string key = fieldIncrementer.ToString();

                    if (this.HasHeaderRow)
                    {
                        if (fields.Length == fieldList.Count)
                        {
                            key = fieldList[fieldIncrementer];
                        }
                    }

                    recordItem.Add(key, field);
                    fieldIncrementer++;
                }

                parsedResult.Add(recordItem);
            }

            return(parsedResult);
        }
예제 #3
0
        public string GetTitle()
        {
            if (string.IsNullOrWhiteSpace(RawText))
            {
                return(null);
            }

            var split = RawText.Split('\t', 2);

            if (split.Length != 2)
            {
                return(null);
            }

            var withoutAuthors = split[1];

            return(withoutAuthors.Trim());
        }
예제 #4
0
        /// <summary>
        /// Turn the lines of a Storyboard Data Asset into a dictionary of individual Storyboard Data objects.
        /// </summary>
        /// <param name="lines">A queue of text lines from the asset file.</param>
        /// <returns>A dictionary of storyboard data objects keyed by their name.</returns>
        public Dictionary <string, StoryboardData> Process()
        {
            var storyboards = new Dictionary <string, StoryboardData>();
            var lines       = Preprocess(RawText.Split('\n'));

            while (lines.Count > 0)
            {
                var next     = lines.Dequeue();
                var trimLine = next.Text.TrimStart();
                if (trimLine.StartsWith(Symbol.LabelLine))
                {
                    var name = ParseBoardname(trimLine);
                    if (!storyboards.ContainsKey(name))
                    {
                        storyboards[name] = ProcessStoryboard(lines, name);
                    }
                    else
                    {
                        WarnTooManyInitialStoryboards(next);
                    }
                }
            }
            return(storyboards);
        }
예제 #5
0
        public List <Dictionary <string, string> > Parse()
        {
            List <Dictionary <string, string> > parsedResult = new List <Dictionary <string, string> >();

            string[] records = RawText.Split(this.LineDelimiter);


            int           startingRow = 0;
            List <string> fieldList   = new List <string>();


            if (this.HasHeaderRow)
            {
                startingRow = 1;
                fieldList   = LoadFieldNamesFromHeaderRow();
            }

            for (int i = startingRow; i < records.Length; i++)
            {
                string record = records[i];

                string[] fields = record.Split(this.Delimiter);
                Dictionary <string, string> recordItem = new Dictionary <string, string>();

                int fieldIncrementer = 0;


                foreach (var field in fields)
                {
                    string key = fieldIncrementer.ToString();

                    if (this.HasHeaderRow)
                    {
                        if (fields.Length == fieldList.Count)
                        {
                            key = fieldList[fieldIncrementer];
                        }
                    }

                    recordItem.Add(key, field);
                    fieldIncrementer++;
                }

                parsedResult.Add(recordItem);

                //if (lineArray.Count == fieldList.Count)
                //{
                //    var j = 0;
                //    var rowDictionary = new Dictionary<string, string>();

                //    // Easy one to one mapping
                //    foreach (var fieldName in fieldList)
                //    {
                //        rowDictionary.Add(fieldName, lineArray[j]);
                //        j++;
                //    }

                //    return rowDictionary;
                //}
                //else
                //{
                //    // TODO: handle this
                //    return null;
                //}


                //var lineDictionary = ParseLineIntoDictionary(fieldList, line);

                //if (lineDictionary != null)
                //{
                //    valueList.Add(lineDictionary);
                //}
            }



            //foreach (var record in records)
            //{


            //    var fields = record.Split(this.Delimiter);
            //    var recordItem = new Dictionary<string, string>();
            //    var i = 0;

            //    foreach (var field in fields)
            //    {
            //        recordItem.Add(i.ToString(), field);
            //        i++;
            //    }

            //    parsedResult.Add(recordItem);
            //}
            return(parsedResult);
        }
        public void Format(ScriptFile scriptFile)
        {
            StringBuilder sb = new StringBuilder();

            bool open = true;

            string[] lines = RawText.Split('\n');
            foreach (string line in lines)
            {
                if (line.StartsWith("#MESSAGE:"))
                {
                    sb.Append(line + "\n");
                    continue;
                }
                for (int i = 0; i < line.Length; i++)
                {
                    char character = line[i];
                    if (character == '%')
                    {
                        open = false;
                    }

                    if (open)
                    {
                        bool   pair         = false;
                        bool   found        = false;
                        string neededSymbol = line[i].ToString();

                        if (i + 1 < line.Length)
                        {
                            if (scriptFile.IsValidChar(line[i + 1]))
                            {
                                neededSymbol += line[i + 1];
                                pair          = true;
                            }
                            else
                            {
                                neededSymbol += " ";
                            }
                        }

                        foreach (FontCharacter fontCharacter in scriptFile.GeneratedFont)
                        {
                            if (fontCharacter.Symbol == neededSymbol)
                            {
                                byte[] bytes = BitConverter.GetBytes(fontCharacter.Index);
                                sb.Append(_shiftJis.GetString(bytes));
                                found = true;
                                if (pair)
                                {
                                    i++;
                                }
                                break;
                            }
                        }

                        if (!found)
                        {
                            //Console.WriteLine("PANIC");
                        }
                    }
                    else
                    {
                        sb.Append(character);
                    }

                    if (character == ':' && open == false)
                    {
                        open = true;
                    }
                }
                sb.Append("\n");
            }
            RawText      = sb.ToString();
            NewLineCount = RawText.Split('\n').Length;
        }