示例#1
0
        public Hashtable Read(string data)
        {
            //Hashtable result = Johny.HashtablePool.Claim();
            // convert to unix line feeds
            //data = data.Replace("\r\n", "\n");
            List <StringView> array   = null;
            List <StringView> idParts = null;

            using (ZString.Block())
            {
                ZString zStr = data;
                ZString str  = zStr.Replace("\r\n", "\n");

                StringView view = new StringView(str, 0, str.Length);
                array = view.Split2List('\n');
            }

            foreach (StringView line in array)
            {
                if (line.Length > 0 && line[0] == '#')
                {
                    continue;
                }

                //StringView line = v.SubString(0, v.Length-1);
                int comma = line.IndexOf(',');
                if (comma > 0)
                {
                    StringView id = line.Substring(0, comma);

                    if (id.StartsWith(EB.Symbols.LocIdPrefix))
                    {
                        idParts = id.Split2List('|');
                        id      = idParts[0];
                        string idText = id.ToString();

                        if (idParts.Count > 1)
                        {
                            StringView type = idParts[1];
                            if (type.Equals("SOURCE") || type.Equals("Source"))
                            {
                                _status[idText] = LocStatus.Source;
                            }
                            else if (type.Equals("PLACEHOLDER") || type.Equals("Placeholder"))
                            {
                                _status[idText] = LocStatus.Placeholder;
                            }
                            else if (type.Equals("For_Translation") || type.Equals("FOR_TRANSLATION"))
                            {
                                _status[idText] = LocStatus.For_Translation;
                            }
                            else if (type.Equals("Translated") || type.Equals("TRANSLATED"))
                            {
                                _status[idText] = LocStatus.Translated;
                            }
                            else
                            {
                                _status[idText] = LocStatus.Missing;
                            }
                        }
                        else
                        {
                            _status[idText] = LocStatus.Source;
                        }

                        string value = line.Substring(comma + 1).ToString();
                        // convert line feeds
                        value = value.Replace("\\n", "\n").Replace("\\t", "\t");

                        Add(idText, value);
                        //result[id] = value;
                    }
                }
            }
            array   = null;
            idParts = null;

            return(null);
        }