Ejemplo n.º 1
0
        public override void ProcessFile(string filePath, Dictionary <string, LocalizableEntity> map)
        {
            Logger.LogFormat("Processing file {0}", filePath);
            XmlTextReader xr           = new XmlTextReader(filePath);
            string        propertyPath = string.Empty;

            try
            {
                if (xr.ReadToDescendant("localization"))
                {
                    if (xr.ReadToDescendant("type"))
                    {
                        do
                        {
                            var className = xr.GetAttribute("name");
                            if (xr.ReadToDescendant("field"))
                            {
                                do
                                {
                                    switch (xr.NodeType)
                                    {
                                    case XmlNodeType.Element:
                                        if (xr.Name == "field")
                                        {
                                            String            fieldName  = xr.GetAttribute("name");
                                            String            fieldValue = xr.ReadElementContentAsString();
                                            LocalizableEntity property   = GetLocalizableProperty(filePath, className, fieldName, fieldValue);
                                            propertyPath = property.FullEntityPath;
                                            map.Add(propertyPath, property);
                                        }
                                        break;
                                    }
                                } while (xr.ReadToNextSibling("field"));
                            }
                        } while (xr.ReadToNextSibling("type"));
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogFormat("Error ({0})", filePath);
                throw new ExtractorException("Error: '{0}'. Property path: '{1}'", ex.Message, propertyPath);
            }
            finally
            {
                xr.Close();
            }
        }
Ejemplo n.º 2
0
        public override void ProcessFile(String filePath, Dictionary <String, LocalizableEntity> map)
        {
            ClasslikeEntity jsObject = null;

            System.IO.TextReader reader = new System.IO.StreamReader(filePath, Encoding.UTF8);
            //Logger.LogFormat("Processing file {0}", filePath);
            try
            {
                while (reader.Peek() > 0)
                {
                    String          line = reader.ReadLine();
                    ClasslikeEntity o    = ProcessEntityDefinitionLine(filePath, line);
                    if (o != null)
                    {
                        jsObject = o;
                    }

                    else if (jsObject != null)
                    {
                        LocalizableEntity prop = ProcessPropertyLine(jsObject, line);
                        if (prop != null && !map.ContainsKey(prop.FullEntityPath))
                        {
                            map.Add(prop.FullEntityPath, prop);
                        }
                    }
                }
                Logger.LogFormat("Processing file {0} - Success", filePath);
            }
            catch (Exception ex)
            {
                Logger.LogFormat("Processing file {0} - Error", filePath);
                throw ex;
            }
            finally
            {
                reader.Close();
            }
        }