Beispiel #1
0
        /// <summary>
        /// read object async
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="package"></param>
        /// <returns></returns>
        public Task <T> ReadPackageAsync <T>(XmlPackage package)
        {
            var _task = Task <T> .Factory.StartNew(() =>
            {
                return(ReadPackage <T>(package));
            });

            return(_task);
        }
Beispiel #2
0
        /// <summary>
        /// read object
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="package"></param>
        /// <returns></returns>
        public T ReadPackage <T>(XmlPackage package)
        {
            var _xml_value = (string)package.Value;
            var _cryptoKey = package.CryptoKey;

            if (package.Packings != MKindOfPacking.All)
            {
                if (package.Packings.HasFlag(MKindOfPacking.Compressed) == true)
                {
                    _xml_value = DecompressText(_xml_value);
                }

                if (package.Packings.HasFlag(MKindOfPacking.Encrypted) == true)
                {
                    _xml_value = CryptHelper.SNG.ChiperTextToPlain(_xml_value, false, _cryptoKey);
                }
            }
            else
            {
                _xml_value = CryptHelper.SNG.ChiperTextToPlain(_xml_value, true, _cryptoKey);
            }

            return(StringToObject <T>(_xml_value));
        }