Example #1
0
 public BewitFactory(ICryptoHelpers cryptoHelpers, 
     ITextHelpers textHelpers)
 {
     Ensure.Argument.IsNotNull(cryptoHelpers, nameof(cryptoHelpers));
     Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
     this.cryptoHelpers = cryptoHelpers;
     this.textHelpers = textHelpers;
 }
Example #2
0
        protected BaseContractResolver(ITextHelpers textHelpers, Type toIncludeAttributeType)
        {
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
            Ensure.Argument.IsNotNull(toIncludeAttributeType, nameof(toIncludeAttributeType));

            this.textHelpers = textHelpers;
            this.toIncludeAttributeType = toIncludeAttributeType;
            this.modelType = typeof(ModelBase);
        }
Example #3
0
        public TentHawkSignatureFactory(ICryptoHelpers cryptoHelpers, 
            ITextHelpers textHelpers, 
            IUriHelpers uriHelpers)
        {
            Ensure.Argument.IsNotNull(cryptoHelpers, "cryptoHelpers");
            Ensure.Argument.IsNotNull(textHelpers, "textHelpers");
            Ensure.Argument.IsNotNull(uriHelpers, "uriHelpers");

            this.cryptoHelpers = cryptoHelpers;
            this.textHelpers = textHelpers;
            this.uriHelpers = uriHelpers;
        }
Example #4
0
        public TentHawkSignature(ICryptoHelpers cryptoHelpers, 
            ITextHelpers textHelpers, 
            IUriHelpers uriHelpers)
        {
            Ensure.Argument.IsNotNull(cryptoHelpers, nameof(cryptoHelpers));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
            Ensure.Argument.IsNotNull(uriHelpers, nameof(uriHelpers));

            this.cryptoHelpers = cryptoHelpers;
            this.textHelpers = textHelpers;
            this.uriHelpers = uriHelpers;
        }
Example #5
0
        public AttachmentLoader(
            ITables tables,
            ITextHelpers textHelpers,
            IResourceCacheService resourceCacheService)
        {
            Ensure.Argument.IsNotNull(tables, nameof(tables));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
            Ensure.Argument.IsNotNull(resourceCacheService, nameof(resourceCacheService));

            this.textHelpers          = textHelpers;
            this.resourceCacheService = resourceCacheService;
            this.attachmentsTable     = tables.TableForType <CacheAttachment>();
        }
Example #6
0
        public HawkSignature(
            ICryptoHelpers cryptoHelpers,
            ITextHelpers textHelpers,
            IUriHelpers uriHelpers)
        {
            Ensure.Argument.IsNotNull(cryptoHelpers, nameof(cryptoHelpers));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
            Ensure.Argument.IsNotNull(uriHelpers, nameof(uriHelpers));

            this.cryptoHelpers = cryptoHelpers;
            this.textHelpers   = textHelpers;
            this.uriHelpers    = uriHelpers;
        }
Example #7
0
        public InternalUserLoader(
            ITables tables,
            ITextHelpers textHelpers,
            IResourceCacheService resourceCacheService)
        {
            Ensure.Argument.IsNotNull(tables, nameof(tables));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
            Ensure.Argument.IsNotNull(resourceCacheService, nameof(resourceCacheService));

            this.textHelpers          = textHelpers;
            this.resourceCacheService = resourceCacheService;
            this.userTable            = tables.TableForVersionedType <CacheUser>();
        }
Example #8
0
        public HawkSignatureFactory(
            ICryptoHelpers cryptoHelpers,
            ITextHelpers textHelpers,
            IUriHelpers uriHelpers)
        {
            Ensure.Argument.IsNotNull(cryptoHelpers, nameof(cryptoHelpers));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
            Ensure.Argument.IsNotNull(uriHelpers, nameof(uriHelpers));

            this.cryptoHelpers = cryptoHelpers;
            this.textHelpers   = textHelpers;
            this.uriHelpers    = uriHelpers;

            this.authorizationHeaderRegex = new Regex("(id|ts|nonce|mac|ext|hash|app)=\"([^\"\\\\]*)\"");
        }
Example #9
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;
        }
Example #10
0
        public MongoTables(
            ILoggingService loggingService,
            ITextHelpers textHelpers,
            IConfiguration configuration)
        {
            Ensure.Argument.IsNotNull(loggingService, nameof(loggingService));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
            Ensure.Argument.IsNotNull(configuration, nameof(configuration));

            this.configuration = configuration;

            // Configure the Mongo connection.
            var clientSettings = new MongoClientSettings
            {
                Servers         = configuration.MongoServers.Select(kv => new MongoServerAddress(kv.Key, kv.Value)),
                ApplicationName = "MainApp",
                //WriteConcern = WriteConcern.WMajority,
                //ReadConcern = ReadConcern.Majority,
                ReadPreference     = ReadPreference.Nearest,
                GuidRepresentation = GuidRepresentation.Standard
            };

            // If needed, set up logging.
            if (configuration.MongoDebug)
            {
                clientSettings.ClusterConfigurator = cluster =>
                {
                    cluster.Subscribe <CommandStartedEvent>(e => loggingService.Info("[Mongo] {0} Started - {1}", e.CommandName, e.Command.ToJson()));
                    cluster.Subscribe <CommandSucceededEvent>(e => loggingService.Info("[Mongo] {0} Succeeded - {1}", e.CommandName, e.Reply.ToJson()));
                    cluster.Subscribe <CommandFailedEvent>(e => loggingService.Exception(e.Failure, "[Mongo] {0} Failed", e.CommandName));
                }
            }
            ;

            // Configure serialization.
            var conventionPack = new ConventionPack();

            conventionPack.Add(new SnakeCaseElementNameConvention(textHelpers));
            ConventionRegistry.Register("snakeCase", conventionPack, t => true);

            // Create the client and get a reference to the Db.
            var client = new MongoClient(clientSettings);

            this.database = client.GetDatabase(configuration.MongoDatabaseName);

            // Create the initializer for this component.
            this.initializer = new TaskRunner(this.InitializeOnceAsync);
        }
Example #11
0
        public ResourceCacheService(
            ITables tables,
            ICaches caches,
            ITextHelpers textHelpers)
        {
            Ensure.Argument.IsNotNull(tables, nameof(tables));
            Ensure.Argument.IsNotNull(caches, nameof(caches));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));

            this.tables      = tables;
            this.caches      = caches;
            this.textHelpers = textHelpers;

            // Create our collections.
            this.resources     = new Dictionary <string, object>();
            this.resourceLocks = new Dictionary <string, AsyncLock>();
        }
Example #12
0
        public JsMainBinding(ITaskBarOverlayService taskBarOverlayService,
                             INotificationsService notificationsService,
                             IViewModelFactory viewModelFactory,
                             IDispatcherService dispatcherService,
                             ITextHelpers textHelpers)
        {
            Ensure.Argument.IsNotNull(taskBarOverlayService, nameof(taskBarOverlayService));
            Ensure.Argument.IsNotNull(notificationsService, nameof(notificationsService));
            Ensure.Argument.IsNotNull(viewModelFactory, nameof(viewModelFactory));
            Ensure.Argument.IsNotNull(dispatcherService, nameof(dispatcherService));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));

            this.taskBarOverlayService = taskBarOverlayService;
            this.notificationsService  = notificationsService;
            this.viewModelFactory      = viewModelFactory;
            this.dispatcherService     = dispatcherService;
            this.textHelpers           = textHelpers;
        }
Example #13
0
        public JsBridgeService(IViewModelFactory viewModelFactory,
                               IJsBindingFactory jsBindingFactory,
                               IWindowService windowService,
                               ITextHelpers textHelpers,
                               IAppConstants appConstants)
        {
            Ensure.Argument.IsNotNull(viewModelFactory, "viewModelFactory");
            Ensure.Argument.IsNotNull(jsBindingFactory, "jsBindingFactory");
            Ensure.Argument.IsNotNull(windowService, "windowService");
            Ensure.Argument.IsNotNull(textHelpers, "textHelpers");
            Ensure.Argument.IsNotNull(appConstants, "appConstants");

            this.viewModelFactory = viewModelFactory;
            this.jsBindingFactory = jsBindingFactory;
            this.windowService    = windowService;
            this.textHelpers      = textHelpers;
            this.appConstants     = appConstants;
        }
Example #14
0
        public ExternalUserLoader(
            IConstants constants,
            ITextHelpers textHelpers,
            IHttp http,
            IProtocol protocol,
            IResourceCacheService resourceCacheService)
        {
            Ensure.Argument.IsNotNull(constants, nameof(constants));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
            Ensure.Argument.IsNotNull(http, nameof(http));
            Ensure.Argument.IsNotNull(protocol, nameof(protocol));
            Ensure.Argument.IsNotNull(resourceCacheService, nameof(resourceCacheService));

            this.constants            = constants;
            this.textHelpers          = textHelpers;
            this.http                 = http;
            this.protocol             = protocol;
            this.resourceCacheService = resourceCacheService;
        }
Example #15
0
        public JsonHelpers(
            ILoggingService loggingService,
            ITextHelpers textHelpers,
            IConfiguration configuration)
        {
            Ensure.Argument.IsNotNull(loggingService, nameof(loggingService));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
            Ensure.Argument.IsNotNull(configuration, nameof(configuration));

            this.configuration  = configuration;
            this.loggingService = loggingService;

            this.defaultFormatting = Formatting.None;
            this.defaultSettings   = new JsonSerializerSettings
            {
                TraceWriter      = this,
                ContractResolver = new BaseContractResolver(textHelpers)
            };
        }
Example #16
0
        public static User FromMetaPost(
            ITextHelpers textHelpers,
            IResourceCacheService resourceCacheService,
            ApiPost <MetaPostContent> metaPost)
        {
            Ensure.Argument.IsNotNull(metaPost, nameof(metaPost));

            var dateNow     = DateTime.UtcNow;
            var metaContent = metaPost.Content;

            return(new User(resourceCacheService)
            {
                Id = textHelpers.GenerateUniqueId(),
                CreatedAt = dateNow,

                OriginalCreatedAt = dateNow,

                Entity = metaContent.Entity
            });
        }
Example #17
0
        public InternalPostLoader(
            ITables tables,
            IPostLicenseLoader postLicenseLoader,
            ITextHelpers textHelpers,
            IResourceCacheService resourceCacheService,
            IInternalUserLoader internalUserLoader,
            IAttachmentLoader attachmentLoader)
        {
            Ensure.Argument.IsNotNull(tables, nameof(tables));
            Ensure.Argument.IsNotNull(postLicenseLoader, nameof(postLicenseLoader));
            Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
            Ensure.Argument.IsNotNull(resourceCacheService, nameof(resourceCacheService));
            Ensure.Argument.IsNotNull(internalUserLoader, nameof(internalUserLoader));
            Ensure.Argument.IsNotNull(attachmentLoader, nameof(attachmentLoader));

            this.textHelpers          = textHelpers;
            this.resourceCacheService = resourceCacheService;
            this.internalUserLoader   = internalUserLoader;
            this.attachmentLoader     = attachmentLoader;
            this.postLicenseLoader    = postLicenseLoader;
            this.postTable            = tables.TableForVersionedType <CachePost>();
        }
Example #18
0
 public DbContractResolver(ITextHelpers textHelpers)
     : base(textHelpers, typeof(DbPropertyAttribute))
 {
 }
Example #19
0
 public UserFactory(ITextHelpers textHelpers)
 {
     Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
     this.textHelpers = textHelpers;
 }
 public SnakeCaseElementNameConvention(ITextHelpers textHelpers)
 {
     Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
     this.textHelpers = textHelpers;
 }
Example #21
0
 public BaseContractResolver(ITextHelpers textHelpers)
 {
     Ensure.Argument.IsNotNull(textHelpers, nameof(textHelpers));
     this.textHelpers = textHelpers;
 }