public (PackageKind packageType, object payload, Guid?packageId) Unwrap(byte[] package)
        {
            IPayloadPackage wrapperPackage = (IPayloadPackage)_modelSerializer.Deserialize(typeof(PayloadPackage), package);

            Guid?packageId = new Guid?();

            object payload = _modelSerializer.Deserialize(Type.GetType(wrapperPackage.PayloadType), wrapperPackage.Payload);

            if (payload is InterlinkedPackage interlinkedPackage)
            {
                packageId = interlinkedPackage.Id;
                payload   = _modelSerializer.Deserialize(Type.GetType(interlinkedPackage.PayloadType), interlinkedPackage.Payload);
            }

            return(wrapperPackage.PackageKind, payload, packageId);
        }
 public static async Task <T> DeserializeHttpResponseAsync <T>(this IContractSerializer contractSerializer, HttpResponseMessage response)
 {
     return(contractSerializer.Deserialize <T>(await response.Content.ReadAsStreamAsync(), false));
 }