public async override void ViewDidLoad()
    {
      base.ViewDidLoad();
            
      #warning first we have to setup connection info and create a session
      var instanceUrl = "http://my.site.com";

      using (var credentials = new SecureStringPasswordProvider("login", "password"))
      using (
        var session = SitecoreWebApiSessionBuilder.AuthenticatedSessionWithHost(instanceUrl)
        .Credentials(credentials)
        .WebApiVersion("v1")
        .DefaultDatabase("web")
        .DefaultLanguage("en")
        .BuildSession())
      {
        // In order to fetch some data we have to build a request
        var request = ItemWebApiRequestBuilder.ReadItemsRequestWithPath("/sitecore/content/home")
          .AddFieldsToRead("text")
          .AddScope(ScopeType.Self)
          .Build();

        // And execute it on a session asynchronously
        var response = await session.ReadItemAsync(request);

        // Now that it has succeeded we are able to access downloaded items
        ISitecoreItem item = response[0];

        // And content stored it its fields
        string fieldContent = item["text"].RawValue;

        UIAlertView alert = new UIAlertView("Sitecore SDK Demo", fieldContent, null, "Ok", null);
        alert.Show();
      }
    }
    public IWebApiCredentials CredentialsShallowCopy()
    {
      var result = new SecureStringPasswordProvider();
      result.providerImpl = this.providerImpl.PasswordProviderCopy();

      return result;
    }
        public IWebApiCredentials CredentialsShallowCopy()
        {
            var result = new SecureStringPasswordProvider();

            result.providerImpl = this.providerImpl.PasswordProviderCopy();

            return(result);
        }
    public void TestPasswordStorageAllowsWhitespaceLogin()
    {
      const string login = "******";
      const string password = "******";

      using (var passwordStorage = new SecureStringPasswordProvider(login, password))
      {
        Assert.AreEqual(login, passwordStorage.Username);
        Assert.AreEqual(password, passwordStorage.Password);
      }
    }
    public void TestPasswordStorageReturnsSameValues()
    {
      const string login = "******";
      const string password = "******";

      using (var passwordStorage = new SecureStringPasswordProvider(login, password))
      {
        Assert.AreEqual(login, passwordStorage.Username);
        Assert.AreEqual(password, passwordStorage.Password);
      }
    }
    public void TestPasswordStorageCopyReturnsSameValues()
    {
      const string login = "******";
      const string password = "******";

      using (var passwordStorage = new SecureStringPasswordProvider(login, password))
      {
        Assert.AreEqual(login, passwordStorage.Username);
        Assert.AreEqual(password, passwordStorage.Password);

        using (var passwordStorageCopy = passwordStorage.CredentialsShallowCopy())
        {
          Assert.AreNotSame(passwordStorage, passwordStorageCopy);

          Assert.AreEqual(login, passwordStorageCopy.Username);
          Assert.AreEqual(password, passwordStorageCopy.Password);
        }
      }
    }
    public ISitecoreWebApiSession GetSession()
    {
      using 
      (
        var credentials = 
          new SecureStringPasswordProvider(
            this.instanceLogin, 
            this.instancePassword)
      )
      {
        var result = SitecoreWebApiSessionBuilder.AuthenticatedSessionWithHost(this.instanceUrl)
          .Credentials(credentials)
          .Site(this.instanceSite)
          .DefaultDatabase(this.instanceDataBase)
          .DefaultLanguage(this.instanceLanguage)
          .BuildSession();

        return result;
      }
    }
    public override async void ViewDidAppear(bool animated)
    {
      base.ViewDidAppear(animated);

      // first we have to setup connection info and create a session
      var instanceUrl = "http://mobiledev1ua1.dk.sitecore.net:722";

      using (var credentials = new SecureStringPasswordProvider("admin", "b"))
      using 
      (
        var session = SitecoreWebApiSessionBuilder.AuthenticatedSessionWithHost(instanceUrl)
          .Credentials(credentials)
          .WebApiVersion("v1")
          .DefaultDatabase("web")
          .DefaultLanguage("en")
          .MediaLibraryRoot("/sitecore/media library")
          .MediaPrefix("~/media/")
          .DefaultMediaResourceExtension("ashx")
          .BuildSession()
      )
      {
        // In order to fetch some data we have to build a request
        var request = ItemWebApiRequestBuilder.ReadItemsRequestWithPath("/sitecore/content/home")
        .AddFieldsToRead("text")
        .AddScope(ScopeType.Self)
        .Build();

        // And execute it on a session asynchronously
        var response = await session.ReadItemAsync(request);

        // Now that it has succeeded we are able to access downloaded items
        ISitecoreItem item = response[0];

        // And content stored it its fields
        string fieldContent = item["text"].RawValue;

        UIAlertView alert = new UIAlertView("Sitecore SDK Demo", fieldContent, null, "Ok", null);
        alert.Show();
      }
    }
    private async void SendAuthRequest()
    {
      try
      {
        using (var credentials = new SecureStringPasswordProvider(this.loginField.Text, this.passwordField.Text))
        using 
        ( 
            var session = SitecoreWebApiSessionBuilder.AuthenticatedSessionWithHost(this.urlField.Text)
            .Credentials(credentials)
            .Site(this.siteField.Text)
            .BuildReadonlySession()
        )
        {
          this.ShowLoader();

          bool response = await session.AuthenticateAsync();

          if (response)
          {
            AlertHelper.ShowLocalizedAlertWithOkOption("Message", "This user exist");
          }
          else
          {
            AlertHelper.ShowLocalizedAlertWithOkOption("Message", "This user not exist");
          }
        }
      }
      catch(Exception e) 
      {
        AlertHelper.ShowLocalizedAlertWithOkOption("Error", e.Message);
      }
      finally
      {
        BeginInvokeOnMainThread(delegate
        {
          this.HideLoader();
        });
      }
    }
    public void TestPasswordStorageAllowsNullPassword()
    {
      const string login = "******";
      const string password = null;

      using (var passwordStorage = new SecureStringPasswordProvider(login, password))
      {
        Assert.AreEqual(login, passwordStorage.Username);
        Assert.AreEqual(password, passwordStorage.Password);
      }
    }