示例#1
0
        public static bool TryReadBlob <T>(CloudBlockBlob blob, out T configurationStore)
            where T : class
        {
            configurationStore = default(T);
            try
            {
                string content = blob.DownloadText();
                if (content == Constants.ConfigurationStoreUpdatingText)
                {
                    return(false);
                }

                string blobContent = content;
                configurationStore = JsonStore <T> .Deserialize(blobContent);

                return(true);
            }
            catch (Exception e)
            {
                ReplicatedTableLogger.LogError("Error reading blob: {0}. Exception: {1}",
                                               blob.Uri,
                                               e.Message);
            }

            return(false);
        }
        public static ReplicatedTableConfiguration MakeCopy(ReplicatedTableConfiguration config)
        {
            if (config == null)
            {
                return(null);
            }

            var str = config.ToJson();

            return(JsonStore <ReplicatedTableConfiguration> .Deserialize(str));
        }
        public static ReplicatedTableConfiguration FromJson(string json)
        {
            if (string.IsNullOrEmpty(json))
            {
                return(new ReplicatedTableConfiguration());
            }

            var config = JsonStore <ReplicatedTableConfiguration> .Deserialize(json);

            config.ValidateAndFixConfig();

            return(config);
        }