示例#1
0
        private OkHttpClient CreateOkHttpClientInstance()
        {
            var builder = new OkHttpClient.Builder()
                          .ConnectTimeout(100, TimeUnit.Seconds)
                          .WriteTimeout(100, TimeUnit.Seconds)
                          .ReadTimeout(100, TimeUnit.Seconds)
                          .CookieJar(new JavaNetCookieJar(new Java.Net.CookieManager()));

            if (_certificatePinnerBuilder.IsValueCreated)
            {
                builder.CertificatePinner(_certificatePinnerBuilder.Value.Build());
            }

            if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
            {
                // Support TLS1.2 on Android versions before Lollipop
                builder.SslSocketFactory(new TlsSslSocketFactory(KeyManagers, TrustManagers), _x509TrustManager ?? TlsSslSocketFactory.GetSystemDefaultTrustManager());
            }
            else if (_keyMgrFactory != null || _trustMgrFactory != null)
            {
                var context = SSLContext.GetInstance("TLS");
                context.Init(KeyManagers, TrustManagers, null);
                builder.SslSocketFactory(context.SocketFactory, _x509TrustManager ?? TlsSslSocketFactory.GetSystemDefaultTrustManager());
            }

            return(builder.Build());
        }
        public OkHttpHandler()
        {
            var b = new OkHttpClient.Builder();

            b.ConnectTimeout(1, TimeUnit.Minutes).WriteTimeout(1, TimeUnit.Minutes).ReadTimeout(1, TimeUnit.Minutes);
            Square.OkHttp3.Cache cache = new Cache(new File(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "/web-cache"), 100 * 1024 * 1024);
            b.Cache(cache);
            this.Client     = b.Build();
            this.UseCookies = false;
        }
示例#3
0
        private async void PlayEdit(Edit edit)
        {
            var videofile = edit.shortlink;

            shareedit = edit;

            Bootlegger.BootleggerClient.LogUserAction("Preview",
                                                      new KeyValuePair <string, string>("editid", edit.id));

            //AndHUD.Shared.Show(this, "Loading...", -1, MaskType.Black, null, null, true);
            //FindViewById<EditVideoView>(Resource.Id.videoplayer).ClearVideoSource();
            //FindViewById<ImageButton>(Resource.Id.sharebtn).Visibility = ViewStates.Visible;
            //get video url:
            try {
                //set other fields:
                FindViewById <TextView>(Resource.Id.metadata).Text = edit.title;
                FindViewById <TextView>(Resource.Id.timemeta).Text = edit.createdAt.LocalizeFormat("ha E d MMM yy");
                if (string.IsNullOrEmpty(edit.description))
                {
                    FindViewById <TextView>(Resource.Id.description).Visibility = ViewStates.Gone;
                }
                else
                {
                    FindViewById <TextView>(Resource.Id.description).Text       = edit.description;
                    FindViewById <TextView>(Resource.Id.description).Visibility = ViewStates.Visible;
                }

                string url = await Bootlegger.BootleggerClient.GetEditUrl(edit);


                //DefaultHttpDataSourceFactory httpDataSourceFactory = new DefaultHttpDataSourceFactory("BootleggerPreview");

                ////var ok = new OkHttpClient();
                //int cacheSize = 300 * 1024 * 1024; // 300 MiB
                //Square.OkHttp3.Cache cache = new Square.OkHttp3.Cache(FilesDir, cacheSize);

                var client = new OkHttpClient.Builder()
                             //.Cache((Application as  BootleggerApp).FilesCache)
                             .Build();
                OkHttpDataSourceFactory httpDataSourceFactory = new OkHttpDataSourceFactory(client, "BootleggerPreview");

                var extractorsFactory = new DefaultExtractorsFactory();
                mediaSource = new ExtractorMediaSource(Android.Net.Uri.Parse(url), httpDataSourceFactory, extractorsFactory, null, null);
                _player.Prepare(mediaSource);
            }
            catch (Exception e)
            {
                //adjust to what kind of exception it is:
                LoginFuncs.ShowToast(this, e);
            }
            finally
            {
                //AndHUD.Shared.Dismiss();
            }
        }
示例#4
0
        private async Task Init()
        {
            var cameraStatus = await Permissions.RequestAsync <Permissions.Camera>();

            var micStatus = await Permissions.RequestAsync <Permissions.Microphone>();

            _webRtcClient = new WebRtcClient(this, _remoteView, _localView, this);

            var dialogTcs = new TaskCompletionSource <string>();

            var linearLayout = new LinearLayout(this);

            linearLayout.Orientation = Orientation.Vertical;
            linearLayout.SetPadding(48, 24, 48, 24);
            var ipAddr = new EditText(this)
            {
                Hint = "IP Address", Text = "192.168.1.119"
            };
            var port = new EditText(this)
            {
                Hint = "Port", Text = "8080"
            };

            linearLayout.AddView(ipAddr);
            linearLayout.AddView(port);

            var alert = new AlertDialog.Builder(this)
                        .SetTitle("Socket Address")
                        .SetView(linearLayout)
                        .SetPositiveButton("OK", (sender, args) =>
            {
                dialogTcs.TrySetResult($"ws://{ipAddr.Text}:{port.Text}");
            })
                        .Create();

            alert.Show();

            var wsUrl = await dialogTcs.Task;

            var okHttpClient = new OkHttpClient.Builder()
                               .ReadTimeout(0, Java.Util.Concurrent.TimeUnit.Milliseconds)
                               .Build();
            var request = new Request.Builder()
                          .Url(wsUrl)
                          .Build();

            _socket = okHttpClient.NewWebSocket(
                request,
                new WebSocketObserver(ReadMessage));
        }
        //https://github.com/square/okhttp/issues/2372#issuecomment-244807676
        public static OkHttpClient.Builder EnableTls12OnPreLollipopDevices(this OkHttpClient.Builder builder)
        {
            int currentVersion = (int)Build.VERSION.SdkInt;

            if (currentVersion >= 16 && currentVersion < 22)
            {
                try
                {
                    //Creation of X509TrustManager : https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.Builder.html#sslSocketFactory-javax.net.ssl.SSLSocketFactory-javax.net.ssl.X509TrustManager-
                    var trustManagerFactory = TrustManagerFactory.GetInstance(TrustManagerFactory.DefaultAlgorithm);
                    trustManagerFactory.Init((Java.Security.KeyStore)null);
                    var trustManagers = trustManagerFactory.GetTrustManagers();

                    if (trustManagers.Length != 1)
                    {
                        throw new Java.Lang.IllegalStateException($"Unexpected default trust managers: {trustManagers}");
                    }

                    var trustManager = trustManagers[0].JavaCast <IX509TrustManager>();
                    if (trustManager == null)
                    {
                        throw new Java.Lang.IllegalStateException($"Unexpected default trust managers: {trustManagers}");
                    }

                    var context = SSLContext.GetInstance("TLS");
                    context.Init(null, new ITrustManager[] { trustManager }, null);
                    builder.SslSocketFactory(new ImprovedSSLSocketFactory(context.SocketFactory, trustManager), trustManager);

                    ConnectionSpec connectionSpec = new ConnectionSpec.Builder(ConnectionSpec.ModernTls)
                                                    .TlsVersions(TlsVersion.Tls12)
                                                    .Build();

                    List <ConnectionSpec> connexionSpecs = new List <ConnectionSpec>
                    {
                        new ConnectionSpec.Builder(ConnectionSpec.ModernTls).TlsVersions(TlsVersion.Tls12).Build(),
                        ConnectionSpec.ModernTls,
                        ConnectionSpec.CompatibleTls,
                        ConnectionSpec.Cleartext,
                    };

                    builder.ConnectionSpecs(connexionSpecs);
                }
                catch (Exception ex)
                {
                    Android.Util.Log.Warn("ModernHttpClient", $"Unable to enable TLS 1.2 on okhttpclient: {ex}");
                }
            }

            return(builder);
        }
        private static OkHttpClient CreateOkHttpClientInstance()
        {
            var builder = new OkHttpClient.Builder()
                          .ConnectTimeout(100, TimeUnit.Seconds)
                          .WriteTimeout(100, TimeUnit.Seconds)
                          .ReadTimeout(100, TimeUnit.Seconds);

            builder.CookieJar(new NativeCookieJar());
            if ((int)Build.VERSION.SdkInt < 21)
            {
                // Support TLS1.2 on Android versions before Lollipop
                builder.SslSocketFactory(new TlsSslSocketFactory(), TlsSslSocketFactory.GetSystemDefaultTrustManager());
            }
            return(builder.Build());
        }
        private void CommonClientBuilder(OkHttpClient.Builder builder)
        {
            if (CustomSSLVerification)
            {
                builder.HostnameVerifier(new HostnameVerifier());
            }

            if (Timeout != null)
            {
                var timeout = (long)Timeout.Value.TotalMilliseconds;
                builder.ConnectTimeout(timeout, TimeUnit.Milliseconds)
                .WriteTimeout(timeout, TimeUnit.Milliseconds)
                .ReadTimeout(timeout, TimeUnit.Milliseconds);
            }
        }
        public void RebuildClient(Action <OkHttpClient.Builder> customBuild)
        {
            if (client != null)
            {
                // This should finish out any in flight requests
                client.Dispatcher().ExecutorService().Shutdown();
                client = null;
            }

            var builder = new OkHttpClient.Builder();

            CommonClientBuilder(builder);
            customBuild?.Invoke(builder);
            client = builder.Build();
        }
示例#9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //var vm = new MainViewModel();

            Button button = FindViewById <Button>(Resource.Id.myButton);

            button.Click += async delegate {
                // The easiest way to pin a host is turn on pinning with a broken configuration and read the expected configuration when the connection fails.
                // Be sure to do this on a trusted network, and without man -in-the - middle tools like Charles or Fiddler.

                var hostname = "reqres.in";

                var certificatePinner = new Square.OkHttp3.CertificatePinner.Builder()
                                        .Add(hostname, "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
                                        .Build();

                var client = new OkHttpClient.Builder()
                             .CertificatePinner(certificatePinner)
                             .Build();

                var request = new Request.Builder()
                              .Url("https://" + hostname)
                              .Build();

                var call = client.NewCall(request);

                var response = await call.ExecuteAsync();

                // As expected, this fails with a certificate pinning exception:

                /*Certificate pinning failure!
                 * Peer certificate chain:
                 *  sha256/CZEvkurQ3diX6pndH4Z5/dUNzK1Gm6+n8Hdx/DQgjO0=: CN=sni96286.cloudflaressl.com,OU=PositiveSSL Multi-Domain,OU=Domain Control Validated
                 *  sha256/x9SZw6TwIqfmvrLZ/kz1o0Ossjmn728BnBKpUFqGNVM=: CN=COMODO ECC Domain Validation Secure Server CA 2,O=COMODO CA Limited,L=Salford,ST=Greater Manchester,C=GB
                 *  sha256/58qRu/uxh4gFezqAcERupSkRYBlBAvfcw7mEjGPLnNU=: CN=COMODO ECC Certification Authority,O=COMODO CA Limited,L=Salford,ST=Greater Manchester,C=GB
                 * Pinned certificates for reqres.in:
                 *  sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=*/

                // Follow up by pasting the public key hashes from the exception into the NativeMessageHandler certificate pinner's configuration.

                //await vm.Get();
            };
        }
示例#10
0
        private OkHttpClient CreateOkHttpClientInstance()
        {
            var builder = new OkHttpClient.Builder()
                          .ConnectTimeout(100, TimeUnit.Seconds)
                          .WriteTimeout(100, TimeUnit.Seconds)
                          .ReadTimeout(100, TimeUnit.Seconds)
                          .FollowRedirects(AllowAutoRedirect)
                          .AddInterceptor(new DecompressInterceptor(_logger));

            if (UseCookies)
            {
                builder.CookieJar(new JavaNetCookieJar(new Java.Net.CookieManager()));
            }

            if (!UseProxy)
            {
                builder.Proxy(Java.Net.Proxy.NoProxy);
            }
            else if (Proxy is WebProxy webProxy)
            {
                var proxyAddress = new InetSocketAddress(webProxy.Address.Host, webProxy.Address.Port);
                builder.Proxy(new Proxy(Java.Net.Proxy.Type.Http, proxyAddress));
            }

            if (_certificatePinnerBuilder.IsValueCreated)
            {
                builder.CertificatePinner(_certificatePinnerBuilder.Value.Build());
            }

            if (_keyMgrFactory != null || _trustMgrFactory != null)
            {
                var context = SSLContext.GetInstance("TLS");
                context.Init(KeyManagers, TrustManagers, null);
                builder.SslSocketFactory(context.SocketFactory, _x509TrustManager ?? TlsSslSocketFactory.GetSystemDefaultTrustManager());
            }

            return(builder.Build());
        }
        FileUploadResponse MakeRequest(string url, string tag, MultipartBody.Builder requestBodyBuilder, IDictionary <string, string> headers = null)
        {
            //RequestBody requestBody = requestBodyBuilder.Build();
            CountingRequestBody requestBody = new CountingRequestBody(requestBodyBuilder.Build(), tag, this);
            var requestBuilder = new Request.Builder();

            if (headers != null)
            {
                foreach (string key in headers.Keys)
                {
                    if (!string.IsNullOrEmpty(headers[key]))
                    {
                        requestBuilder = requestBuilder.AddHeader(key, headers[key]);
                    }
                }
            }

            Request request = requestBuilder
                              .Url(url)
                              .Post(requestBody)
                              .Build();

            var builder = new OkHttpClient.Builder();

            builder.ConnectTimeout(ConnectUploadTimeout, UploadTimeoutUnit);
            builder.ReadTimeout(SocketUploadTimeout, UploadTimeoutUnit);

            var client = builder.Build();

            Response response       = client.NewCall(request).Execute();
            var      responseString = response.Body().String();
            var      code           = response.Code();

            IDictionary <string, string> responseHeaders = new Dictionary <string, string>();
            var rHeaders = response.Headers();

            if (rHeaders != null)
            {
                var names = rHeaders.Names();
                foreach (string name in names)
                {
                    if (!string.IsNullOrEmpty(rHeaders.Get(name)))
                    {
                        responseHeaders.Add(name, rHeaders.Get(name));
                    }
                }
            }

            FileUploadResponse fileUploadResponse = new FileUploadResponse(responseString, code, tag, new ReadOnlyDictionary <string, string>(responseHeaders));


            if (response.IsSuccessful)
            {
                FileUploadCompleted(this, fileUploadResponse);
            }
            else
            {
                FileUploadError(this, fileUploadResponse);
            }

            return(fileUploadResponse);
        }
 public SecureHttpClientHandler()
 {
     _builder = OkHttpClientInstance.Value.NewBuilder().CookieJar(new NativeCookieJar());
     _certificatePinnerBuilder = new Lazy <CertificatePinner.Builder>();
 }
示例#13
0
        //private void Preview_Click(object sender, EventArgs e)
        //{
        //    Intent sharingIntent = new Intent(Intent.ActionSend);
        //    sharingIntent.SetType("text/plain");
        //    sharingIntent.PutExtra(Intent.ExtraSubject, shareedit.title);
        //    sharingIntent.PutExtra(Intent.ExtraText, Bootlegger.BootleggerClient.server + "/v/" + shareedit.shortlink);
        //    StartActivity(Intent.CreateChooser(sharingIntent, new Java.Lang.String(Resources.GetString(Resource.String.sharevia))));
        //}

        public async void PlayVideo(MediaItem media)
        {
            Bootlegger.BootleggerClient.LogUserAction("Preview",
                                                      new KeyValuePair <string, string>("mediaid", media.id));

            if (Intent.GetBooleanExtra(Review.INGEST_MODE, false))
            {
                var rv = FindViewById <RecyclerView>(Resource.Id.list);
                rv.SetLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false));

                var _readonly = Intent.GetBooleanExtra(Review.READ_ONLY, false);

                var chips = new ChipAdapter(this, _readonly);

                //var prev = Resources.GetStringArray(Resource.Array.default_edit_topics).ToList();
                //if (string.IsNullOrEmpty(Bootlegger.BootleggerClient.CurrentEvent.topics))
                //    Bootlegger.BootleggerClient.CurrentEvent.topics = string.Join(",", prev);
                //else
                //prev = Bootlegger.BootleggerClient.CurrentEvent.topics.Split(',').ToList();

                if (_readonly)
                {
                    chips.Update(null, media);
                }
                else
                {
                    chips.Update(Bootlegger.BootleggerClient.CurrentEvent.topics.ToList(), media);
                }

                rv.SetAdapter(chips);
                FindViewById(Resource.Id.videometadata).Visibility = ViewStates.Gone;
            }

            FindViewById <ImageView>(Resource.Id.imageplayer).SetImageDrawable(null);

            try
            {
                FindViewById <TextView>(Resource.Id.metadata).Text = media.meta.shot_ex["name"].ToString() + " at " + media.meta.role_ex["name"].ToString() + " during " + media.meta.phase_ex["name"].ToString();
            }
            catch
            {
                FindViewById <TextView>(Resource.Id.metadata).Text = "";
            }
            try
            {
                FindViewById <TextView>(Resource.Id.timemeta).Text = media.CreatedAt.LocalizeFormat("ha E d MMM yy");
            }
            catch
            {
                FindViewById <TextView>(Resource.Id.timemeta).Text = media.Static_Meta["captured_at"].ToString();
            }


            FindViewById <TextView>(Resource.Id.description).Visibility = ViewStates.Gone;

            switch (media.MediaType)
            {
            case Shot.ShotTypes.VIDEO:
            case Shot.ShotTypes.AUDIO:
                //FindViewById<View>(Resource.Id.videoplayer).Visibility = ViewStates.Visible;
                try
                {
                    //set other fields:
                    string url = await Bootlegger.BootleggerClient.GetVideoUrl(media);

                    if (url.StartsWith("file://"))
                    {
                        DefaultDataSourceFactory httpDataSourceFactory = new DefaultDataSourceFactory(this, "BootleggerPreview");

                        var extractorsFactory = new DefaultExtractorsFactory();
                        mediaSource = new ExtractorMediaSource(Android.Net.Uri.Parse(url), httpDataSourceFactory, extractorsFactory, null, null);
                    }
                    else
                    {
                        var client = new OkHttpClient.Builder()
                                     .Cache((Application as BootleggerApp).FilesCache)
                                     .Build();

                        OkHttpDataSourceFactory httpDataSourceFactory = new OkHttpDataSourceFactory(client, "BootleggerPreview");

                        var extractorsFactory = new DefaultExtractorsFactory();
                        mediaSource = new ExtractorMediaSource(Android.Net.Uri.Parse(url), httpDataSourceFactory, extractorsFactory, null, null);
                    }

                    _player.Prepare(mediaSource);
                }
                catch (Exception e)
                {
                    //Toast.MakeText(this, Resource.String.cannotloadvideo, ToastLength.Short).Show();
                    LoginFuncs.ShowToast(this, e);
                }
                break;

            case Shot.ShotTypes.PHOTO:
                //FindViewById<View>(Resource.Id.videoplayer).Visibility = ViewStates.Gone;
                if (media.Status == MediaItem.MediaStatus.DONE && !string.IsNullOrEmpty(media.path))
                {
                    //string url = await (Application as BootleggerApp).Comms.(videofile);
                    Picasso.With(this).Load(media.Thumb + "?s=300").Fit().CenterInside().Into(FindViewById <ImageView>(Resource.Id.imageplayer));
                }
                else
                {
                    Picasso.With(this).Load("file://" + media.Filename).Fit().CenterInside().Into(FindViewById <ImageView>(Resource.Id.imageplayer));
                }

                break;
            }
        }
示例#14
0
        public void Startup()
        {
            /*** NEW PLAYER ***/
            _player = ExoPlayerFactory.NewSimpleInstance(Context, new DefaultTrackSelector());
            _player.PlayWhenReady = true;
            _player.AddListener(this);

            progress?.Dispose();
            clipper?.Dispose();

            progress = new ProgressTracker(_player);
            progress.OnPositionChange += Progress_OnPositionChange;
            clipper = new ProgressTracker(_player, 50);
            clipper.OnPositionChange += Clipper_OnPositionChange;

            _playerView = FindViewById <PlayerView>(Resource.Id.videoview);

            Android.Graphics.Typeface subtitleTypeface = ResourcesCompat.GetFont(Context, Resource.Font.montserratregular);

            var captionStyleCompat = new CaptionStyleCompat(Android.Graphics.Color.White, Android.Graphics.Color.Transparent, Android.Graphics.Color.Transparent, CaptionStyleCompat.EdgeTypeNone, Android.Graphics.Color.Transparent, subtitleTypeface);

            _playerView.SubtitleView.SetStyle(captionStyleCompat);
            _playerView.SubtitleView.SetFractionalTextSize(0.06f);
            //_playerView.SubtitleView.SetFixedTextSize((int)ComplexUnitType.Sp, 10);

            _playerView.SubtitleView.SetBottomPaddingFraction(0.4f);
            _playerView.SubtitleView.TextAlignment = TextAlignment.Center;


            _playerView.Player        = _player;
            _playerView.UseController = true;

            webclient = new OkHttpClient.Builder()
                        .Cache((Context.ApplicationContext as BootleggerApp).FilesCache)
                        .Build();
            httpDataSourceFactory    = new OkHttpDataSourceFactory(webclient, "BootleggerEditor", null);
            extractorsFactory        = new DefaultExtractorsFactory();
            defaultDataSourceFactory = new DefaultDataSourceFactory(Context, "BootleggerEditor");
            /*************/

            _audioPlayer            = ExoPlayerFactory.NewSimpleInstance(Context, new DefaultTrackSelector());
            _audioPlayer.Volume     = 0.4f;
            _audioPlayer.RepeatMode = Player.RepeatModeOne;

            cursor                       = FindViewById <View>(Resource.Id.trackposition);
            seeker                       = FindViewById <RangeSliderControl>(Resource.Id.seeker);
            trackcontrols                = FindViewById <View>(Resource.Id.trackcontrols);
            seeker.LowerValueChanged    += Seeker_LeftValueChanged;
            seeker.UpperValueChanged    += Seeker_RightValueChanged;
            seeker.StepValueContinuously = true;
            track = FindViewById <View>(Resource.Id.track);

            title = FindViewById <TextView>(Resource.Id.title);

            FindViewById <ImageButton>(Resource.Id.fullscreenbtn).Click += Fullscreen_Click;

            videoWrapper = FindViewById(Resource.Id.videoWrapper);

            mFullScreenDialog = new FullScreenVideoDialog(Context, Android.Resource.Style.ThemeBlackNoTitleBarFullScreen);
            mFullScreenDialog.OnAboutToClose += MFullScreenDialog_OnAboutToClose;

            seeker.Visibility = ViewStates.Invisible;
        }
示例#15
0
        public async Task <T> Invoke <T>(INetActionConfig action)
        {
            try
            {
                using (var requestBuilder = new Request.Builder())
                {
                    if (_netService.Config.HasCredentials)
                    {
                        requestBuilder.AddHeader("Authentication",
                                                 Credentials.Basic(_netService.Config.UserName, _netService.Config.Password ?? ""));
                    }

                    requestBuilder.Url(GetUri(action));

                    if (action.Payload != null)
                    {
                        requestBuilder.Post(
                            GetBody(action));
                    }

                    using (var request = requestBuilder.Build())
                    {
                        using (var clientBuilder = new OkHttpClient.Builder())
                        {
                            // Setup Client here
                            using (var client = clientBuilder.Build())
                            {
                                using (var response = await client.NewCall(request).ExecuteAsync().ConfigureAwait(false)
                                       )
                                {
                                    if (!response.IsSuccessful)
                                    {
                                        throw new Exception($"Error: code:{response.Code()}, msg:{response.Message()}");
                                    }

                                    using (var contentType = response.Body().ContentType())
                                    {
                                        _logger.Info(contentType);

                                        if (contentType.Type().EndsWith("xml"))
                                        {
                                            var body = await response.Body().StringAsync();

                                            return(Deserialize <T>(body));
                                        }

                                        if (contentType.Type().EndsWith("json"))
                                        {
                                            return(JsonConvert.DeserializeObject <T>(
                                                       await response.Body().StringAsync()));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _logger.Error(e);
            }

            return(default(T));
        }