Esempio n. 1
0
        static void Main()
        {
            /// RotorEnigma Ia = RotorEnigma.I;
            /// Ia.InitialPosition = Ia.OperatingAlphabet[5];
            /// Hexa h = new Hexa(byte.MaxValue);
            ///
            /// Enigma enigma1 = new Enigma(Reflector.B, Ia, RotorEnigma.II, RotorEnigma.VIII);
            /// enigma1.ToString();
            /// string test = enigma1.Process("HELLO WORLD !");
            /// enigma1.Reset();
            /// string rslt0 = enigma1.Process(test);
            ///
            /// Enigma enigma3 = enigma1.Clone(true);
            /// string rslt3 = enigma3.Process(test);



            string[] tbl = new string[] {
                HashKey.DigestFile(HashAlgorithmEnum.MD5, "XLIFF_2.xlf"),
                HashKey.DigestFile(HashAlgorithmEnum.SHA1, "XLIFF_2.xlf"),
                HashKey.DigestFile(HashAlgorithmEnum.SHA256, "XLIFF_2.xlf"),
                HashKey.DigestFile(HashAlgorithmEnum.SHA384, "XLIFF_2.xlf"),
                HashKey.DigestFile(HashAlgorithmEnum.SHA512, "XLIFF_2.xlf"),
                HashKey.DigestFile(HashAlgorithmEnum.KeyedHashAlgorithm, "XLIFF_2.xlf"),
                HashKey.DigestFile(HashAlgorithmEnum.RIPEMD160, "XLIFF_2.xlf"),
            };

            Chromatik.Unicode.Unicode.Load("en");

            tbl.ForEach(Incremente);

            //System.Globalization.Localization.QtTranslation trs = System.Globalization.Localization.QtTranslation.LoadTranslation(@"for_translation_sigil_sigil_fr.ts.xml");
            //trs.Save("test.ts.xml");


            ;
            Xliff xliff = Xliff.LoadXliff("XLIFF_2.xlf");

            string    fI = xliff.IDs[1];
            XliffFile fS = xliff.Identifieds[1];


            xliff[0].ID = "f3";
            xliff[0].ID = "f2";

            XmlDocument xml = XmlDocumentCreate.DocumentXML("<xml><span>kkkkkkk</span> <span de=\"\">yyyy</span><i> 65246541 </i><span>sdfwsfd</span></xml>");

            XmlDocumentWriter.Document("test.0.xml", xml, DocumentType.HTML5);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
        private void SaveSettings(Settings settings)
        {
            try
            {
                var doc        = new XmlDocumentWriter();
                var rootWriter = doc.CreateRootWriter(RootElementName);

                settings.Save(rootWriter);

                FileHelper.EnsureFolderExists(Constants.SettingsFilePath);
                doc.Save(Constants.SettingsFilePath);
            }
            catch (Exception)
            {
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Get a minified svg picture
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="indent"></param>
        static public void File(string filePath, bool indent)
        {
            if (System.IO.File.Exists(filePath))
            {
                XmlDocument load = XmlDocumentCreate.Document(filePath);

                if (load != null && load.FirstElement("svg") != null)
                {
                    string svg_minifed = Path.GetDirectoryName(filePath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(filePath) + "-minifed.svg";

                    XmlDocumentWriter.Document(svg_minifed, Document(load), WriterSetting(indent));

                    string text = System.IO.File.ReadAllText(svg_minifed).ReplaceLoop(" />", "/>");
                    if (!indent)
                    {
                        text = text.Regex("(\r|\n)", "");
                    }
                    System.IO.File.WriteAllText(svg_minifed, text, Encoding.UTF8);
                }
            }
        }
Esempio n. 4
0
 public void Save(string filePath, XmlWriterSettings settings)
 {
     XmlDocumentWriter.Document(filePath, GetXmlDocument(), settings, DocumentType);
 }
Esempio n. 5
0
        /// <summary>
        /// Interpreta os dados recebidos do cliente.
        /// </summary>
        /// <param name="context">O contexto HTTP.</param>
        /// <param name="spec"></param>
        /// <returns>O dado interpretado; Nulo se nenhum dado foi recebido.</returns>
        private async Task <Parameter> ParseInputAsync(HttpContext context, Spec spec)
        {
            if (context.Request.Method != "POST" && context.Request.Method != "PUT")
            {
                return(null);
            }

            var parameter = (
                from p in spec.Callee.GetParameters()
                where !p.Name.EqualsAnyIgnoreCase(spec.AllTargets) &&
                p.ParameterType != typeof(HttpContext)
                select p
                ).FirstOrDefault();

            if (parameter == null)
            {
                return(null);
            }

            if (parameter.ParameterType == typeof(Stream))
            {
                return(new Parameter
                {
                    Info = parameter,
                    Value = context.Request.Body
                });
            }

            if (parameter.ParameterType == typeof(string) ||
                parameter.ParameterType == typeof(object))
            {
                var text = await new StreamReader(context.Request.Body).ReadToEndAsync();
                return(new Parameter
                {
                    Info = parameter,
                    Value = text
                });
            }

            XDocument xml;

            var reader = SupportedDocumentTextReader.Create(context.Request.Body);

            if (reader.DocumentFormat == SupportedDocumentTextReader.JsonFormat)
            {
                var writer = new StringWriter();

                var jsonReader = new JsonReader(reader);
                var xmlWriter  = new XmlDocumentWriter(writer);
                jsonReader.CopyTo(xmlWriter);

                var content = writer.ToString();
                xml = XDocument.Parse(content);
            }
            else
            {
                xml = XDocument.Load(XmlReader.Create(reader));
            }

            if (parameter.ParameterType == typeof(XElement))
            {
                return(new Parameter
                {
                    Info = parameter,
                    Value = xml.Root
                });
            }
            else if (typeof(XNode).IsAssignableFrom(parameter.ParameterType))
            {
                return(new Parameter
                {
                    Info = parameter,
                    Value = xml
                });
            }
            else
            {
                var graph = xml.ToXmlObject(parameter.ParameterType);
                return(new Parameter
                {
                    Info = parameter,
                    Value = graph
                });
            }
        }