/// <summary>
        /// Initializing object frmComponents.
        /// </summary>
        public frmComponents()
        {
            string isDebug = string.Empty;

            if (AppVersionHelper.IsDebug())
            {
                isDebug = " DEBUG";
            }

            InitializeComponent();

            this.Text = String.Format(GetLocalizedText("captionText"), CurrentAssembly.Title) + isDebug;

            textBoxDescription.Font = new Font(FontFamily.GenericMonospace, textBoxDescription.Font.Size);

            textBoxDescription.Text = BuildDescripionFieldText();
        }
예제 #2
0
        /// <summary>
        /// Load queries from Xml-file
        /// </summary>
        /// <param name="fileName">Xml-file name</param>
        /// <param name="cryptoProcessor">Encoder</param>
        /// <param name="isExternal">Is opened from user file template</param>
        /// <returns>List of queries</returns>
        public static List <QueryInfo> LoadFromXml(string fileName, CryptoProcessor cryptoProcessor, bool isExternal)
        {
            if (AppVersionHelper.IsDebug() || isExternal)
            {
                if (cryptoProcessor == null)
                {
                    return(LoadFromXml(fileName));
                }
            }

            try
            {
                XmlDocument doc = new XmlDocument();
                doc.PreserveWhitespace = true;
                doc.Load(fileName);

                if (AppVersionHelper.IsRelease() || (AppVersionHelper.IsNotRelease() && cryptoProcessor != null))
                {
                    cryptoProcessor.DecryptXmlDocument(doc);
                }

                byte[] bytes = Encoding.UTF8.GetBytes(doc.OuterXml);

                XmlSerializer s = new XmlSerializer(typeof(LoaderRootWrapper));

                using (var includingReader = new MemoryStream(bytes))
                {
                    using (var xmlReader = XmlReader.Create(includingReader, XmlUtils.GetXmlReaderSettings()))
                    {
                        return(GetQueries(((LoaderRootWrapper)s.Deserialize(xmlReader))));
                    }
                }
            }
            catch (Exception exception)
            {
                log.Error(exception);

                if (AppVersionHelper.IsDebug() || isExternal)
                {
                    return(LoadFromXml(fileName));
                }

                throw;
            }
        }