コード例 #1
0
        void DoTestAllDataWithDictionaryMultiple()
        {
            bool isSuccess;

            try
            {
                StashClientOptions
                    options = StashConfiguration.GetDefaultOptions();

                AllDataWithDictionaryMultiple(options);                         // use large data must fail

                // if control came here we failed
                isSuccess = false;
            }
            catch (Exception)
            {
                isSuccess = true;
            }

            if (!isSuccess)
            {
                Assert.Fail();
            }


            {
                StashClientOptions
                    options = StashConfiguration.GetDefaultOptions();

                options.SupportLargeObjectsInPool = true;

                AllDataWithDictionary
                    entity = AllDataWithDictionaryMultiple(options);

                // now read without the support large pool options and validate the the entities do NOT match
                //	and the unmapped pool count is different
                options.SupportLargeObjectsInPool = false;

                StashClient <AllDataWithDictionary>
                client = StashConfiguration.GetClient <AllDataWithDictionary>(options);

                AllDataWithDictionary
                    entityRead = client.Get(entity.PartitionKey, entity.RowKey);

                Assert.IsFalse(entityRead.Equals(entity));

                // now read without the support large pool options and validate the the entities DO match
                //	and the unmapped pool count is different
                options.SupportLargeObjectsInPool = true;

                client = StashConfiguration.GetClient <AllDataWithDictionary>(options);

                entityRead = client.Get(entity.PartitionKey, entity.RowKey);

                Assert.IsTrue(entityRead.Equals(entity));

                // delete
                client.Delete(entityRead);
            }
        }
コード例 #2
0
 GetStasherUsingCloudStorageAccount <T>(
     string settings,
     StashClientOptions options)
 {
     return(GetStasherUsingCloudStorageAccount <T>(
                GetCloudStorageAccount(settings),
                options));
 }
コード例 #3
0
        GetStasherUsingCloudStorageAccount <T>(
            CloudStorageAccount account,
            StashClientOptions options)
        {
            options.UseHttps = account.TableEndpoint.Scheme == "https";

            return(new StashClient <T>(
                       account.Credentials.AccountName,
                       new SignRequest(h => account.Credentials.SignRequestLite(h)),
                       options));
        }
コード例 #4
0
        GetClient <T>(
            StashClientOptions options)
        {
            // Change the type here to target different storage accounts and different credential methods.
            ConfigurationType
                configType = ConfigurationType.StashEmulator;

            StashClient <T>
            result = null;

            switch (configType)
            {
            // Use the StashCredential class.
            case ConfigurationType.StashCloud:

                result = new StashClient <T>(
                    new StorageAccountKey(
                        ConfigurationManager.AppSettings["AccountName"],
                        ConfigurationManager.AppSettings["key"]),
                    options);
                break;

            // The storage emulator credentials are built into Stash.
            case ConfigurationType.StashEmulator:

                result = new StashClient <T>(
                    options);
                break;

#if USE_STORAGE_CLIENT
            // Use the Azure Storage Client credentials infrastructure.
            case ConfigurationType.StorageAccountCloud:

                result = GetStasherUsingCloudStorageAccount <T>(
                    "DataConnectionString",
                    options);
                break;

            // Use the Azure Storage Client credentials infrastructure for the emulator.
            case ConfigurationType.StorageAccountEmulator:

                result = GetStasherUsingCloudStorageAccount <T>(
                    "DataConnectionStringEmulator",
                    options);
                break;
#endif
            default:
                throw new ApplicationException("Incorrect Configuration Type.");
            }

            return(result);
        }
コード例 #5
0
        GetStasherUsingCloudStorageAccount <T>(
            CloudStorageAccount account,
            StashClientOptions options)
        {
            // indicate it https is selected.
            options.UseHttps = account.TableEndpoint.Scheme == "https";

            // instantiate the client with the SignRequestLite method from the Credentials.
            return(new StashClient <T>(
                       account.Credentials.AccountName,
                       new SignRequest(h => account.Credentials.SignRequestLite(h)),
                       options));
        }
コード例 #6
0
        AllDataWithDictionaryMultiple(
            StashClientOptions options)
        {
            StashClient <AllDataWithDictionary>
            client = StashConfiguration.GetClient <AllDataWithDictionary>(options);

            AllDataWithDictionary
                entity = TypeFactory <AllDataWithDictionary> .Create(DataSize.Multiple);       // DataSize.Multiple

            client.Insert(entity);

            AllDataWithDictionary
                entityRead = client.Get(entity.PartitionKey, entity.RowKey);

            Assert.IsTrue(entityRead.Equals(entity));

            return(entityRead);
        }
コード例 #7
0
        GetClient <T>(
            StashClientOptions options)
        {
            StashClient <T>
            result = null;

            switch (ConfigType)
            {
            case ConfigurationType.StashCloud:

                result = new StashClient <T>(
                    new StorageAccountKey(
                        ConfigurationManager.AppSettings["AccountName"],
                        ConfigurationManager.AppSettings["key"]),
                    options);
                break;

            case ConfigurationType.StashEmulator:

                result = new StashClient <T>(
                    options);
                break;

#if USE_STORAGE_CLIENT
            case ConfigurationType.StorageAccountCloud:

                result = GetStasherUsingCloudStorageAccount <T>(
                    "DataConnectionString",
                    options);
                break;

            case ConfigurationType.StorageAccountEmulator:

                result = GetStasherUsingCloudStorageAccount <T>(
                    "DataConnectionStringEmulator",
                    options);
                break;
#endif
            }

            return(result);
        }
コード例 #8
0
        AddRetryInterceptor(
            StashClientOptions options)
        {
            // Get a function which creates the policy and invoke it to get the actual policy
            var exponentatial =
                RetryPolicies.GetExponential(
                    Retryable.DefaultAttempts,
                    Retryable.DefaultDeltaBackoff)();

            // create an interceptor which wraps the policy and assigns it to the option.
            options.RetryPolicy =
                () =>
                (attempt, ex) => {
                System.Diagnostics.Debug.WriteLine(
                    "Attempt = {0}. Exception = {1}",
                    attempt,
                    ex);

                return(exponentatial(attempt, ex));
            };
        }