/// <summary> /// 构造器 指定classNameDllName(DecompressProviderName) 默认Pub.Class.SharpZip.Decompress,Pub.Class.SharpZip /// </summary> /// <param name="classNameAndAssembly">命名空间.类名,程序集名称</param> public Decompress(string classNameAndAssembly) { if (decompress.IsNull()) { decompress = (IDecompress)classNameAndAssembly.IfNullOrEmpty("Pub.Class.SharpZip.Decompress,Pub.Class.SharpZip").LoadClass(); } }
/// <summary> /// 构造器 从Web.config中读DecompressProviderName 默认Pub.Class.SharpZip.Decompress,Pub.Class.SharpZip /// </summary> public Decompress() { if (decompress.IsNull()) { decompress = (IDecompress)(WebConfig.GetApp("DecompressProviderName") ?? "Pub.Class.SharpZip.Decompress,Pub.Class.SharpZip").LoadClass(); } }
public static object DeserializePayloadUsingSpecificSerializer( this DescribedSerialization describedSerialization, IDeserialize deserializer, IDecompress decompressor = null, TypeMatchStrategy typeMatchStrategy = TypeMatchStrategy.NamespaceAndName, MultipleMatchStrategy multipleMatchStrategy = MultipleMatchStrategy.ThrowOnMultiple) { new { describedSerialization }.Must().NotBeNull(); new { deserializer }.Must().NotBeNull(); var localDecompressor = decompressor ?? new NullCompressor(); var targetType = describedSerialization.PayloadTypeRepresentation.ResolveFromLoadedTypes(typeMatchStrategy, multipleMatchStrategy); object ret; switch (describedSerialization.SerializationDescription.SerializationFormat) { case SerializationFormat.Binary: var rawBytes = Convert.FromBase64String(describedSerialization.SerializedPayload); var decompressedBytes = localDecompressor.DecompressBytes(rawBytes); ret = deserializer.Deserialize(decompressedBytes, targetType); break; case SerializationFormat.String: ret = deserializer.Deserialize(describedSerialization.SerializedPayload, targetType); break; default: throw new NotSupportedException(Invariant($"{nameof(SerializationFormat)} - {describedSerialization.SerializationDescription.SerializationFormat} is not supported.")); } return(ret); }
/// <summary> /// 构造器 指定DLL文件和全类名 /// </summary> /// <param name="dllFileName">dll文件名</param> /// <param name="className">命名空间.类名</param> public Decompress(string dllFileName, string className) { if (decompress.IsNull()) { decompress = (IDecompress)dllFileName.LoadClass(className); } }
static Default() { var systemRandomFactory = new SystemRandomFactory(); SystemRandomFactory = systemRandomFactory; SystemRandomWithSeedFactory = systemRandomFactory; var xorShift1024RandomFactory = new XorShift1024RandomFactory(); XorShift1024RandomFactory = xorShift1024RandomFactory; XorShift1024RandomWithSeedFactory = xorShift1024RandomFactory; RandomWithSeedFactory = xorShift1024RandomFactory; RandomFactory = xorShift1024RandomFactory; IdGenerator = new IdGenerator(XorShift1024RandomFactory.Create()); SnappyCompressor = new SnappyCompressor(); SnappyDecompressor = new SnappyDecompressor(); UtcDateTimeProvider = new UtcDateTimeProvider(); }
public void UnzipDirectories(string path) { IDecompress dec = CreateUnZipper(path); dec.ExtractDirectories(); }