private static XElement GetDefInjectableFieldNode(string suggestedPath, DefInjectionPackage.DefInjection existingInjection)
        {
            if (existingInjection == null || existingInjection.isPlaceholder)
            {
                return(new XElement(suggestedPath, new XText("TODO")));
            }
            if (existingInjection.IsFullListInjection)
            {
                return(TranslationFilesCleaner.ListToXElement(existingInjection.fullListInjection, suggestedPath, existingInjection.fullListInjectionComments));
            }
            XElement xElement = new XElement(suggestedPath);

            if (!existingInjection.injection.NullOrEmpty())
            {
                xElement.Add(new XText(existingInjection.injection.Replace("\n", "\\n")));
            }
            return(xElement);
        }
Ejemplo n.º 2
0
        private void TryAddFullListInjection(FileInfo file, string key, List <string> translation, List <Pair <int, string> > comments)
        {
            string text = key;

            key = this.BackCompatibleKey(key);
            if (this.CheckErrors(file, key, text, true))
            {
                return;
            }
            if (translation == null)
            {
                translation = new List <string>();
            }
            DefInjectionPackage.DefInjection defInjection = new DefInjectionPackage.DefInjection();
            defInjection.path = key;
            defInjection.fullListInjection         = translation;
            defInjection.fullListInjectionComments = comments;
            defInjection.fileSource            = file.Name;
            defInjection.nonBackCompatiblePath = text;
            this.injections.Add(key, defInjection);
        }
Ejemplo n.º 3
0
        private void TryAddInjection(FileInfo file, string key, string translation)
        {
            string text = key;

            key = this.BackCompatibleKey(key);
            if (this.CheckErrors(file, key, text, false))
            {
                return;
            }
            DefInjectionPackage.DefInjection defInjection = new DefInjectionPackage.DefInjection();
            if (translation == "TODO")
            {
                defInjection.isPlaceholder = true;
                translation = string.Empty;
            }
            defInjection.path                  = key;
            defInjection.injection             = translation;
            defInjection.fileSource            = file.Name;
            defInjection.nonBackCompatiblePath = text;
            this.injections.Add(key, defInjection);
        }
        private static XElement GetDefInjectableFieldNode(string suggestedPath, DefInjectionPackage.DefInjection existingInjection)
        {
            if (existingInjection == null || existingInjection.isPlaceholder)
            {
                return(new XElement(suggestedPath, new XText("TODO")));
            }
            if (existingInjection.IsFullListInjection)
            {
                return(ListToXElement(existingInjection.fullListInjection, suggestedPath, existingInjection.fullListInjectionComments));
            }
            XElement xElement;

            if (!existingInjection.injection.NullOrEmpty())
            {
                if (existingInjection.suggestedPath.EndsWith(".slateRef") && ConvertHelper.IsXml(existingInjection.injection))
                {
                    try
                    {
                        return(XElement.Parse("<" + suggestedPath + ">" + existingInjection.injection + "</" + suggestedPath + ">"));
                    }
                    catch (Exception ex)
                    {
                        Log.Warning("Could not parse XML: " + existingInjection.injection + ". Exception: " + ex);
                        xElement = new XElement(suggestedPath);
                        xElement.Add(existingInjection.injection);
                        return(xElement);
                    }
                }
                xElement = new XElement(suggestedPath);
                xElement.Add(new XText(existingInjection.injection.Replace("\n", "\\n")));
            }
            else
            {
                xElement = new XElement(suggestedPath);
            }
            return(xElement);
        }