Esempio n. 1
0
        public AzureTentQueues(IGeneralConfiguration configuration, 
            IJsonHelpers jsonHelpers,
            ITaskHelpers taskHelpers,
            ILoggingService loggingService)
        {
            Ensure.Argument.IsNotNull(configuration, nameof(configuration));
            Ensure.Argument.IsNotNull(jsonHelpers, nameof(jsonHelpers));
            Ensure.Argument.IsNotNull(taskHelpers, nameof(taskHelpers));
            Ensure.Argument.IsNotNull(loggingService, nameof(loggingService));

            this.taskHelpers = taskHelpers;
            this.loggingService = loggingService;

            // Create the storage account from the connection string, and the corresponding client.
            var queuesStorageAccount = CloudStorageAccount.Parse(configuration.AzureQueuesConnectionString);
            var queuesClient = queuesStorageAccount.CreateCloudQueueClient();

            // Create the queues references.
            this.mentionsQueue = queuesClient.GetQueueReference("mentions");
            this.subscriptionsQueue = queuesClient.GetQueueReference("subscriptions");
            this.appNotificationQueue = queuesClient.GetQueueReference("appnotifications");
            this.metaSubscriptionQueue = queuesClient.GetQueueReference("metasubscriptions");
            this.retryQueue = queuesClient.GetQueueReference("retries");

            // Create the IQueue objects.
            this.Mentions = new AzureQueue<QueueMentionMessage>(this.mentionsQueue, jsonHelpers);
            this.Subscriptions = new AzureQueue<QueueSubscriptionMessage>(this.subscriptionsQueue, jsonHelpers);
            this.AppNotifications = new AzureQueue<QueueAppNotificationMessage>(this.appNotificationQueue, jsonHelpers);
            this.MetaSubscriptions = new AzureQueue<QueueMetaSubscriptionMessage>(this.metaSubscriptionQueue, jsonHelpers);
            this.Retries = new AzureQueue<QueueRetryMessage>(this.retryQueue, jsonHelpers);

            // Create the initializer for this component.
            this.initializer = new TaskRunner(this.InitializeOnceAsync);
        }
Esempio n. 2
0
        public HttpRequestFactory(IJsonHelpers jsonHelpers,
            ITentConstants tentConstants)
        {
            Ensure.Argument.IsNotNull(jsonHelpers, nameof(jsonHelpers));
            Ensure.Argument.IsNotNull(tentConstants, nameof(tentConstants));

            this.jsonHelpers = jsonHelpers;
            this.tentConstants = tentConstants;
        }
Esempio n. 3
0
        public HttpClientFactory(
            IJsonHelpers jsonHelpers, 
            IHttpHelpers httpHelpers)
        {
            Ensure.Argument.IsNotNull(jsonHelpers, nameof(jsonHelpers));
            Ensure.Argument.IsNotNull(httpHelpers, nameof(httpHelpers));

            this.jsonHelpers = jsonHelpers;
            this.httpHelpers = httpHelpers;
        }
Esempio n. 4
0
        public Http(
            IJsonHelpers jsonHelpers,
            IHttpHelpers httpHelpers)
        {
            Ensure.Argument.IsNotNull(jsonHelpers, nameof(jsonHelpers));
            Ensure.Argument.IsNotNull(httpHelpers, nameof(httpHelpers));

            this.jsonHelpers = jsonHelpers;
            this.httpHelpers = httpHelpers;
        }
Esempio n. 5
0
        public AzureQueue(
            CloudQueue baseQueue,
            IJsonHelpers jsonHelpers)
        {
            Ensure.Argument.IsNotNull(baseQueue, nameof(baseQueue));
            Ensure.Argument.IsNotNull(jsonHelpers, nameof(jsonHelpers));

            this.baseQueue   = baseQueue;
            this.jsonHelpers = jsonHelpers;
        }
Esempio n. 6
0
 public override JObject GetCanonicalJson(IJsonHelpers jsonHelpers)
 {
     return new JObject
     {
         { "category", this.Category },
         { "content_type", this.ContentType },
         { "name", this.Name },
         { "digest", this.Digest },
         { "size", this.Size }
     };
 }
Esempio n. 7
0
        public RedisCaches(
            IJsonHelpers jsonHelpers,
            IConfiguration configuration)
        {
            Ensure.Argument.IsNotNull(jsonHelpers, nameof(jsonHelpers));
            Ensure.Argument.IsNotNull(configuration, nameof(configuration));

            this.jsonHelpers   = jsonHelpers;
            this.configuration = configuration;

            // Create the initializer for this component.
            this.initializer = new TaskRunner(this.InitializeOnceAsync);
        }
Esempio n. 8
0
        public HttpClient(
            IJsonHelpers jsonHelpers,
            IHttpHelpers httpHelpers)
        {
            Ensure.Argument.IsNotNull(jsonHelpers, nameof(jsonHelpers));
            Ensure.Argument.IsNotNull(httpHelpers, nameof(httpHelpers));

            this.jsonHelpers = jsonHelpers;
            this.httpHelpers = httpHelpers;

            // Create the underlying HttpClient.
            this.client = new Native.HttpClient();
        }
Esempio n. 9
0
        public override JObject GetCanonicalJson(IJsonHelpers jsonHelpers)
        {
            var result = new JObject
            {
                { "published_at", this.PublishedAt.GetValueOrDefault().ToUnixTime() },
            };

            if (this.Parents != null && this.Parents.Any())
            {
                result.Add("parents", jsonHelpers.FromObject(this.Parents.Select(p => p.GetCanonicalJson(jsonHelpers))));
            }

            return result;
        }
Esempio n. 10
0
        public AwsQueue(IJsonHelpers jsonHelpers,
                        ITextHelpers textHelpers,
                        AmazonSQSClient client,
                        string queueUrl)
        {
            Ensure.Argument.IsNotNull(jsonHelpers, nameof(jsonHelpers));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
            Ensure.Argument.IsNotNull(client, nameof(client));
            Ensure.Argument.IsNotNullOrWhiteSpace(queueUrl, nameof(queueUrl));

            this.jsonHelpers = jsonHelpers;
            this.textHelpers = textHelpers;
            this.client      = client;
            this.queueUrl    = queueUrl;
        }
Esempio n. 11
0
        public override JObject GetCanonicalJson(IJsonHelpers jsonHelpers)
        {
            var result = new JObject();

            if (!string.IsNullOrWhiteSpace(this.Name))
            {
                result.Add("name", this.Name);
            }

            if (!string.IsNullOrWhiteSpace(this.Url))
            {
                result.Add("url", this.Url);
            }

            return result;
        }
Esempio n. 12
0
        public HttpRequest(
            IJsonHelpers jsonHelpers,
            IHttpHelpers httpHelpers,
            Native.HttpClient client,
            Native.HttpMethod method,
            Uri target)
        {
            Ensure.Argument.IsNotNull(jsonHelpers, nameof(jsonHelpers));
            Ensure.Argument.IsNotNull(httpHelpers, nameof(httpHelpers));
            Ensure.Argument.IsNotNull(client, nameof(client));
            Ensure.Argument.IsNotNull(target, nameof(target));

            this.jsonHelpers = jsonHelpers;
            this.httpHelpers = httpHelpers;
            this.client      = client;
            this.request     = new Native.HttpRequestMessage(method, target);
        }
Esempio n. 13
0
        public RedisCacheStore(
            IJsonHelpers jsonHelpers,
            IConfiguration configuration,
            IDatabase db)
        {
            Ensure.Argument.IsNotNull(jsonHelpers, nameof(jsonHelpers));
            Ensure.Argument.IsNotNull(configuration, nameof(configuration));
            Ensure.Argument.IsNotNull(db, nameof(db));

            this.jsonHelpers = jsonHelpers;
            this.db          = db;

            // Find the cache key for this resource type.
            var resourceType = typeof(TCacheResource);

            this.cacheKeyRoot = configuration.CachePrefixes[resourceType];
        }
Esempio n. 14
0
File: User.cs Progetto: Campr/Server
        public override JObject GetCanonicalJson(IJsonHelpers jsonHelpers)
        {
            var result = new JObject
            {
                {"id", this.Id},
                {"created_at", this.CreatedAt.GetValueOrDefault()},
                {"updated_at", this.UpdatedAt.GetValueOrDefault()},
                {"handle", this.Handle},
                {"entity", this.Entity},
                {"email", this.Email},
                {"password", this.Password},
                {"password_salt", this.PasswordSalt},
                {"is_bot_followed", this.IsBotFollowed},
                {"last_discovery_attempt", this.LastDiscoveryAttempt.GetValueOrDefault()},
                {"deleted_at", this.DeletedAt.GetValueOrDefault()}
            };

            return result.Sort();
        }
Esempio n. 15
0
        public override JObject GetCanonicalJson(IJsonHelpers jsonHelpers)
        {
            var result = new JObject
            {
                { "post", this.PostId }
            };
            
            if (!string.IsNullOrWhiteSpace(this.OriginalEntity))
                result.Add("entity", this.OriginalEntity);
            else if (!string.IsNullOrWhiteSpace(this.Entity))
                result.Add("entity", this.Entity);

            if (!string.IsNullOrWhiteSpace(this.VersionId))
                result.Add("version", this.VersionId);

            if (this.Type != null)
                result.Add("type", this.Type.ToString());

            return result;
        }
Esempio n. 16
0
        public override JObject GetCanonicalJson(IJsonHelpers jsonHelpers)
        {
            // Create the canonical Json object.
            var result = new JObject
            {
                { "version", this.VersionId }
            };

            if (!string.IsNullOrEmpty(this.OriginalEntity))
            {
                result.Add("entity", this.OriginalEntity);
            }
            else if (!string.IsNullOrEmpty(this.Entity))
            {
                result.Add("entity", this.Entity);
            }

            if (!string.IsNullOrEmpty(this.PostId))
            {
                result.Add("post", this.PostId);
            }

            return result;
        }
Esempio n. 17
0
 public virtual JObject GetCanonicalJson(IJsonHelpers jsonHelpers)
 {
     throw new NotImplementedException("This method shouldn't be called on this object.");
 }