public void BeforeEachTest()
        {
            serializer = Serializers.Xml;

            //Generate keypair
            var keyPair = LicensingService.GenerateKeypair();

            //note:only generate the key pair once per application and store the keys somewhere secure.
            //            keyPair.Save(fileinfo, serializer);
            //            keyPair = KeyPair.Load(fileinfo, serializer)

            //customised license
            var number = Rand.Next();
            var name = Rand.String.NextText(1, 3);

            creator = new MyTestLicenseCreator(number, name);

            //create the licensing service
            service = LicensingService.Create(keyPair, serializer, creator);

            //generate license
            var licensee = Rand.String.NextText(1, 3);
            const LicenseType LICENSE_TYPE = LicenseType.Full;
            var expiration = DateTime.MaxValue.AddYears(-50);

            license = service.GenerateLicense(licensee, LICENSE_TYPE, expiration);
        }
Example #2
0
        public static IKeyPair Load(FileInfo file, IDataSerializer serializer)
        {
            file.Refresh();
            if (!file.Exists)
                throw new FileNotFoundException("not found", file.FullName);

            return serializer.Deserialize<KeyPair>(File.ReadAllBytes(file.FullName));
        }
 public SessionStore(IBucket bucket,
     IDataSerializer<AuthenticationTicket> ticketSerializer,
     ILookupNormalizer lookupNormalizer,
     IOptions<IdentityOptions> options)
 {
     _bucket = bucket;
     _timeout = options.Value.Cookies.ApplicationCookie.ExpireTimeSpan;
     _ticketSerializer = ticketSerializer;
     _lookupNormalizer = lookupNormalizer;
 }
Example #4
0
        internal TestRunRequest(IRequestData requestData, TestRunCriteria testRunCriteria, IProxyExecutionManager executionManager, ITestLoggerManager loggerManager, IDataSerializer dataSerializer)
        {
            Debug.Assert(testRunCriteria != null, "Test run criteria cannot be null");
            Debug.Assert(executionManager != null, "ExecutionManager cannot be null");
            Debug.Assert(requestData != null, "request Data is null");
            Debug.Assert(loggerManager != null, "LoggerManager cannot be null");

            if (EqtTrace.IsVerboseEnabled)
            {
                EqtTrace.Verbose("TestRunRequest.ExecuteAsync: Creating test run request.");
            }

            this.testRunCriteria  = testRunCriteria;
            this.ExecutionManager = executionManager;
            this.LoggerManager    = loggerManager;
            this.State            = TestRunState.Pending;
            this.dataSerializer   = dataSerializer;
            this.requestData      = requestData;
        }
Example #5
0
        public SaveData ConvertRawData(IDataSerializer serializer)
        {
            var result = new SaveData
            {
                Type = type
            };

            foreach (var pair in rawData)
            {
                switch (pair.Value)
                {
                case ISaveable saveable:
                    var saveDataBuilder = saveable.GetSaveData();
                    result.Objects.Add(pair.Key, saveDataBuilder.ConvertRawData(serializer));
                    break;

                case string str:
                    result.Values.Add(pair.Key, str);
                    break;

                case IEnumerable collection:
                    var elementType = collection.GetType().GetElementType();
                    var array       = collection.Cast <object>().ToArray();
                    if ((array.Length > 0 && array.All(elem => elem is ISaveable)) ||
                        (elementType != null && elementType.GetInterfaces().Contains(typeof(ISaveable))))
                    {
                        result.ObjectsCollections.Add(pair.Key, array.Cast <ISaveable>().Select(elem => elem.GetSaveData().ConvertRawData(serializer)).ToArray());
                    }
                    else
                    {
                        result.ValuesCollections.Add(pair.Key, array.Select(elem => GetStringValue(elem, serializer)).ToArray());
                    }
                    break;

                default:
                    result.Values.Add(pair.Key, GetStringValue(pair.Value, serializer));
                    break;
                }
            }

            return(result);
        }
        internal TestRequestSender(
            TestHostConnectionInfo connectionInfo,
            IDataSerializer serializer,
            ProtocolConfig protocolConfig,
            int clientExitedWaitTime)
        {
            this.dataSerializer       = serializer;
            this.connected            = new ManualResetEventSlim(false);
            this.clientExited         = new ManualResetEventSlim(false);
            this.clientExitedWaitTime = clientExitedWaitTime;
            this.operationCompleted   = 0;

            this.highestSupportedVersion = protocolConfig.Version;

            // The connectionInfo here is that of RuntimeProvider, so reverse the role of runner.
            this.connectionInfo.Endpoint = connectionInfo.Endpoint;
            this.connectionInfo.Role     = connectionInfo.Role == ConnectionRole.Host
                ? ConnectionRole.Client
                : ConnectionRole.Host;
        }
Example #7
0
        public RedisLink(ILoggerFactory loggerFactory,
                         IRedisConfiguration configuration,
                         IRedisMultiplexer multiplexer,
                         IResilience resilience,
                         IEntitySubscriber entitySubscriber,
                         IDataSerializer defaultSerialiser)
            : base(configuration?.ServiceName)
        {
            this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
            Multiplexer        = multiplexer ?? throw new ArgumentNullException(nameof(multiplexer));

            Resilience             = resilience ?? throw new ArgumentNullException(nameof(resilience));
            EntitySubscriber       = entitySubscriber;
            this.defaultSerialiser = defaultSerialiser ?? throw new ArgumentNullException(nameof(defaultSerialiser));
            log                     = loggerFactory.CreateLogger <RedisLink>();
            Generator               = new ScriptGenerator();
            IndexManager            = new MainIndexManager(new IndexManagerFactory(loggerFactory, this));
            Client                  = new RedisClient(loggerFactory?.CreateLogger <RedisClient>(), this, IndexManager);
            PersistencyRegistration = new PersistencyRegistrationHandler(loggerFactory, this);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DataHandler{T}" /> class.
        /// </summary>
        /// <param name="dataProvider">The data provider.</param>
        /// <param name="data">Name of the setting.</param>
        /// <param name="dataGridView">The data grid view.</param>
        public DataHandler(IDataSerializer <T> dataProvider, string data, DataGridView dataGridView)
        {
            this.dataSerializer = dataProvider;
            this.settingName    = data;
            this.dataGridView   = dataGridView;

            this.container = this.dataSerializer.GetData(data);
            this.bindingSource.DataSource         = this.container.Data;
            this.container.Data.ListChanged      += this.RaiseOnDataChangedEvent;
            this.dataGridView.CellEndEdit        += this.CellEdited;
            this.dataGridView.ColumnWidthChanged += this.ColumnWidthChanges;

            dataGridView.DataSource            = this.bindingSource;
            dataGridView.AutoGenerateColumns   = true;
            dataGridView.AutoSize              = true;
            dataGridView.AllowUserToAddRows    = false;
            dataGridView.AllowUserToDeleteRows = false;

            this.SetColumnWidths(dataGridView);
        }
Example #9
0
 public static void Serialize(this IDataSerializer serializer, string filename, SerializationSet dataSet)
 {
     FileUtility.Backup(filename);
     try
     {
         FileUtility.Prepare(filename);
         using (var stream = File.OpenWrite(filename))
         {
             serializer.Serialize(stream, dataSet);
         }
     }
     catch
     {
         FileUtility.Restore(filename);
     }
     finally
     {
         FileUtility.Clean(filename);
     }
 }
Example #10
0
 public UsersController(IUserService userService, IModelMapper modelMapper, IRoleService roleService, ICapabilityService capabilityService, IUserRegistrationService userRegistrationService, IDataSerializer dataSerializer, IAddressService addressService, IOrderService orderService, IOrderModelFactory orderModelFactory, IRoleModelFactory roleModelFactory, ICartService cartService, IUserCodeService userCodeService, IInviteRequestService inviteRequestService, IAddressModelFactory addressModelFactory, IUserPointService userPointService, IUserModelFactory userModelFactory, IStoreCreditService storeCreditService)
 {
     _userService             = userService;
     _modelMapper             = modelMapper;
     _roleService             = roleService;
     _capabilityService       = capabilityService;
     _userRegistrationService = userRegistrationService;
     _dataSerializer          = dataSerializer;
     _addressService          = addressService;
     _orderService            = orderService;
     _orderModelFactory       = orderModelFactory;
     _roleModelFactory        = roleModelFactory;
     _cartService             = cartService;
     _userCodeService         = userCodeService;
     _inviteRequestService    = inviteRequestService;
     _addressModelFactory     = addressModelFactory;
     _userPointService        = userPointService;
     _userModelFactory        = userModelFactory;
     _storeCreditService      = storeCreditService;
 }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="hostName"></param>
        /// <param name="userName"></param>
        /// <param name="port"></param>
        /// <param name="password"></param>
        /// <param name="maxQueueCount"></param>
        /// <param name="serializerType"></param>
        /// <param name="loger"></param>
        /// <param name="writeWorkerTaskNumber"></param>
        private RabbitMQClient(string hostName, string userName, string password, int?port, int maxQueueCount
                               , SerializerType serializerType, ILoger loger = null, short writeWorkerTaskNumber = 4)
        {
            factory          = new ConnectionFactory();
            factory.HostName = hostName;
            if (!port.HasValue || port.Value < 0)
            {
                factory.Port = 5672;
            }
            else
            {
                factory.Port = port.Value;
            }
            factory.Password = password;
            factory.UserName = userName;

            serializer = SerializerFactory.Create(serializerType);
            _queue     = new System.Collections.Concurrent.BlockingCollection <StrongBox <QueueMessage> >();

            //_queue = new System.Collections.Queue();
            _maxQueueCount = maxQueueCount > 0 ? maxQueueCount : Options.DefaultMaxQueueCount;

            //isQueueToWrite = false;
            //resetEvent = new AutoResetEvent(false);

            this.loger = loger;
            //this.waitMillisecondsTimeout = 10000;

            //queueWorkThread = new Thread(QueueToWrite);
            //queueWorkThread.IsBackground = true;
            //queueWorkThread.Start();

            var         scheduler   = new ConcurrentExclusiveSchedulerPair(TaskScheduler.Default, writeWorkerTaskNumber).ExclusiveScheduler;
            TaskFactory taskFactory = new TaskFactory(scheduler);

            for (int i = 0; i < writeWorkerTaskNumber; i++)
            {
                taskFactory.StartNew(QueueToWrite, TaskCreationOptions.LongRunning);
                //Task.Factory.StartNew(QueueToWrite);
            }
        }
Example #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataPublisher"/> class.
        /// </summary>
        /// <param name="container">The componentry container.</param>
        /// <param name="dataBusAdapter">The data bus adapter.</param>
        /// <param name="instrumentSerializer">The instrument serializer.</param>
        /// <param name="compressor">The data compressor.</param>
        /// <param name="encryption">The encryption configuration.</param>
        /// <param name="port">The port.</param>
        public DataPublisher(
            IComponentryContainer container,
            IDataBusAdapter dataBusAdapter,
            IDataSerializer <Instrument> instrumentSerializer,
            ICompressor compressor,
            EncryptionSettings encryption,
            Port port)
            : base(
                container,
                dataBusAdapter,
                compressor,
                encryption,
                ZmqNetworkAddress.AllInterfaces(port))
        {
            this.instrumentSerializer = instrumentSerializer;

            this.RegisterHandler <Instrument>(this.OnMessage);

            this.Subscribe <BarData>();
            this.Subscribe <Instrument>();
        }
Example #13
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="logger">The <see cref="ILogger{EtcdDataProvider}"/> which will be used to log events by the provider.</param>
        /// <param name="dataSerializer">The <see cref="IDataProvider{T}"/> which will be used to serialize data from Etcd.</param>
        /// <param name="etcdProviderOptionsAccessor">The <see cref="IDataProviderOptions{T,TOptions}"/> which will be used to access options for the instance of the provider.</param>
        public EtcdDataProvider(ILogger <EtcdDataProvider <T> > logger,
                                IDataSerializer <T> dataSerializer,
                                IDataProviderOptions <T, EtcdProviderOptions> etcdProviderOptionsAccessor)
        {
            _logger              = logger;
            _dataSerializer      = dataSerializer;
            _etcdProviderOptions = etcdProviderOptionsAccessor.Value;

            _etcdClient = new EtcdClient(_etcdProviderOptions.ConnectionString, _etcdProviderOptions.Port,
                                         _etcdProviderOptions.Username, _etcdProviderOptions.Password, _etcdProviderOptions.CaCertificate,
                                         _etcdProviderOptions.ClientCertificate, _etcdProviderOptions.ClientKey,
                                         _etcdProviderOptions.IsPublicRootCa);

            if (!string.IsNullOrEmpty(_etcdProviderOptions.Username) &&
                !string.IsNullOrEmpty(_etcdProviderOptions.Password))
            {
                _metadata = new Metadata
                {
                    { "Authorization", $"Basic {_etcdProviderOptions.Username}:{_etcdProviderOptions.Password}" }
                };
            }
        }
Example #14
0
 public CheckoutController(IPaymentProcessor paymentProcessor, IPaymentAccountant paymentAccountant, IModelMapper modelMapper, IAddressService addressService, ICartService cartService, IDataSerializer dataSerializer, IPluginAccountant pluginAccountant, IOrderService orderService, OrderSettings orderSettings, IRoleService roleService, IUserService userService, IProductService productService, IOrderAccountant orderAccountant, IDownloadService downloadService, ILogger logger, AffiliateSettings affiliateSettings, IStoreCreditService storeCreditService, IPriceAccountant priceAccountant, ICryptographyService cryptographyService)
 {
     _paymentProcessor    = paymentProcessor;
     _paymentAccountant   = paymentAccountant;
     _modelMapper         = modelMapper;
     _addressService      = addressService;
     _cartService         = cartService;
     _dataSerializer      = dataSerializer;
     _pluginAccountant    = pluginAccountant;
     _orderService        = orderService;
     _orderSettings       = orderSettings;
     _roleService         = roleService;
     _userService         = userService;
     _productService      = productService;
     _orderAccountant     = orderAccountant;
     _downloadService     = downloadService;
     _logger              = logger;
     _affiliateSettings   = affiliateSettings;
     _storeCreditService  = storeCreditService;
     _priceAccountant     = priceAccountant;
     _cryptographyService = cryptographyService;
 }
Example #15
0
        public ChronosDataWrapper(string contentPath,
                                  IDataSerializer chronosSaver,
                                  IFileHandlerSimple fileHandler,
                                  IOptions <ChronosSettings> options)
        {
            _dataSaver   = chronosSaver;
            _fileHandler = fileHandler;
            _contentPath = contentPath;
            _settings    = options.Value;

            _activeTimersLock = new ReaderWriterLockSlim();
            _activeTimers     = new Dictionary <string, Chronos <string, Task <bool> > >();

            _activeCalculationsLock = new ReaderWriterLockSlim();
            _activeCalculations     = new Dictionary <string, ActivityToken>();

            _activeExportsLock = new ReaderWriterLockSlim();
            _activeExports     = new Dictionary <string, ActivityToken>();

            _lastTimeDeletedLock   = new ReaderWriterLockSlim();
            _lastTimeIDeletedFiles = DateTime.Now;
            _hoursToKeepData       = _settings.HoursToKeepData;
        }
        public override IEnumerable <TOutput> Load <TOutput>(ILoadCommand command, IDataSerializer <TOutput> serializer, IResponseFormatter <string> formatter)
        {
            long maxRows = GetRowCountForResults(command);

            if (maxRows > _readSplitSize)
            {
                List <TOutput> results  = new List <TOutput>();
                List <string>  commands = new List <string>();

                for (long startIndex = command.StartIndex, batchNum = 0; startIndex < maxRows; startIndex += (batchNum * _readSplitSize), batchNum++)
                {
                    ILoadCommand copyCommand = command.Clone() as ILoadCommand;
                    copyCommand.GetAll     = false;
                    copyCommand.StartIndex = startIndex;
                    copyCommand.MaxRows    = _readSplitSize;

                    string batchCommand = MakeLoadQueryString(copyCommand);

                    commands.Add(batchCommand);
                }
                commands.AsParallel().ForAll(s =>
                {
                    var batchResults = ExecuteLoad(s, command.ResponseFormat, serializer, formatter);
                    lock (results)
                    {
                        results.AddRange(batchResults);
                    }
                });

                return(results);
            }
            else
            {
                //Downgrade to simple operations
                return(base.Load(command, serializer, formatter));
            }
        }
Example #17
0
 public void AddNewItem1(FileSystemEventArgs e, DataItems items, IDataSerializer dataSerializer, string targetFolder)
 {
     try
     {
         string sourceFilePath = e.FullPath;
         //string archiveName = FileCompressor.GetArchiveFileName(e.FullPath);
         string fileName     = Path.GetFileName(sourceFilePath);
         string destFilePath = targetFolder;
         Task.Run(
             () =>
         {
             if (FileMover.Move(sourceFilePath, destFilePath))
             {
                 FileCompressor.Compress(destFilePath);
                 dataSerializer.Store(items);
             }
         }
             );
     }
     catch (Exception ex)
     {
         _log.Error(ex);
     }
 }
Example #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TickPublisher"/> class.
        /// </summary>
        /// <param name="container">The componentry container.</param>
        /// <param name="dataBusAdapter">The data bus adapter.</param>
        /// <param name="quoteSerializer">The quote tick serializer.</param>
        /// <param name="tradeSerializer">The trade tick serializer.</param>
        /// <param name="compressor">The data compressor.</param>
        /// <param name="encryption">The encryption configuration.</param>
        /// <param name="port">The publisher port.</param>
        public TickPublisher(
            IComponentryContainer container,
            IDataBusAdapter dataBusAdapter,
            IDataSerializer <QuoteTick> quoteSerializer,
            IDataSerializer <TradeTick> tradeSerializer,
            ICompressor compressor,
            EncryptionSettings encryption,
            Port port)
            : base(
                container,
                dataBusAdapter,
                compressor,
                encryption,
                ZmqNetworkAddress.AllInterfaces(port))
        {
            this.quoteSerializer = quoteSerializer;
            this.tradeSerializer = tradeSerializer;

            this.RegisterHandler <QuoteTick>(this.OnMessage);
            this.RegisterHandler <TradeTick>(this.OnMessage);

            this.Subscribe <QuoteTick>();
            this.Subscribe <TradeTick>();
        }
 public TestableBaseRunTests(
     IRequestData requestData,
     string package,
     string runSettings,
     TestExecutionContext testExecutionContext,
     ITestCaseEventsHandler testCaseEventsHandler,
     ITestRunEventsHandler testRunEventsHandler,
     ITestPlatformEventSource testPlatformEventSource,
     ITestEventsPublisher testEventsPublisher,
     IThread platformThread,
     IDataSerializer dataSerializer)
     : base(
         requestData,
         package,
         runSettings,
         testExecutionContext,
         testCaseEventsHandler,
         testRunEventsHandler,
         testPlatformEventSource,
         testEventsPublisher,
         platformThread,
         dataSerializer)
 {
 }
Example #20
0
 /// <summary>Push the blob only if etag is matching the etag of the blob in BlobStorage</summary>
 public static bool PutBlob <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, T item, string etag, IDataSerializer serializer = null)
 {
     return(provider.PutBlob(location.ContainerName, location.Path, item, etag, serializer));
 }
Example #21
0
 public static void PutBlob <T>(this IBlobStorageProvider provider, IBlobLocation location, T item, IDataSerializer serializer = null)
 {
     provider.PutBlob(location.ContainerName, location.Path, item, serializer);
 }
Example #22
0
 public static bool PutBlob <T>(this IBlobStorageProvider provider, IBlobLocation location, T item, bool overwrite, IDataSerializer serializer = null)
 {
     return(provider.PutBlob(location.ContainerName, location.Path, item, overwrite, serializer));
 }
Example #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestRequestSender"/> class.
        /// </summary>
        /// <param name="communicationManager">Communication Manager for sending and receiving messages.</param>
        /// <param name="connectionInfo">ConnectionInfo to set up transport layer</param>
        /// <param name="dataSerializer">Serializer for serialization and deserialization of the messages.</param>
        /// <param name="protocolConfig">Protocol related information</param>
        internal TestRequestSender(ICommunicationManager communicationManager, TestHostConnectionInfo connectionInfo, IDataSerializer dataSerializer, ProtocolConfig protocolConfig)
        {
            this.highestSupportedVersion = protocolConfig.Version;
            this.communicationManager    = communicationManager;

            // The connectionInfo here is that of RuntimeProvider, so reverse the role of runner.
            connectionInfo.Role = connectionInfo.Role == ConnectionRole.Host
                                                ? ConnectionRole.Client
                                                : ConnectionRole.Host;

            this.transport      = new SocketTransport(communicationManager, connectionInfo);
            this.dataSerializer = dataSerializer;
        }
 public EnvelopeStreamer(IDataSerializer dataSerializer, IEnvelopeSerializer envelopeSerializer = null)
 {
     _envelopeSerializer = envelopeSerializer ?? new EnvelopeSerializerWithDataContracts();
     _dataSerializer = dataSerializer;
 }
Example #25
0
 /// <summary>
 /// Inserts or updates a blob depending on whether it already exists or not.
 /// If the insert or update lambdas return empty, the blob will be deleted (if it exists).
 /// </summary>
 /// <remarks>
 /// <para>
 /// The provided lambdas can be executed multiple times in case of
 /// concurrency-related retrials, so be careful with side-effects
 /// (like incrementing a counter in them).
 /// </para>
 /// <para>
 /// This method is idempotent if and only if the provided lambdas are idempotent
 /// and if the object returned by the insert lambda is an invariant to the update lambda
 /// (if the second condition is not met, it is idempotent after the first successful call).
 /// </para>
 /// </remarks>
 /// <returns>The value returned by the lambda. If empty, then the blob has been deleted.</returns>
 public static Maybe <T> UpsertBlobOrDelete <T>(
     this IBlobStorageProvider provider, IBlobLocationAndType <T> location, Func <Maybe <T> > insert, Func <T, Maybe <T> > update, IDataSerializer serializer = null)
 {
     return(provider.UpsertBlobOrDelete(location.ContainerName, location.Path, insert, update, serializer));
 }
 public void Register(IDataSerializer serializer)
 {
     dataSerializers.Add(serializer);
 }
Example #27
0
 public DataService(IDataSerializer serializer)
 {
     _serializer = serializer;
     _webClient = new WebClient {BaseAddress = ConfigurationManager.ConnectionStrings["host"].ConnectionString};
     _webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
 }
 /// <summary>
 /// Replace the default data serializer with a custom implementation
 /// </summary>
 public CloudStorageBuilder WithDataSerializer(IDataSerializer dataSerializer)
 {
     DataSerializer = dataSerializer;
     return this;
 }
 public EnvelopeStreamer(IEnvelopeSerializer envelopeSerializer, IDataSerializer dataSerializer)
 {
     _envelopeSerializer = envelopeSerializer;
     _dataSerializer = dataSerializer;
 }
Example #30
0
 public void Save(FileInfo file, IDataSerializer serializer)
 {
     File.WriteAllBytes(file.FullName, serializer.Serialize(this));
 }
 public MyAnonymousCommandSender(IQueueWriter writer, IDataSerializer serializer, IEnvelopeStreamer streamer)
 {
     _writer = writer;
     _serializer = serializer;
     _streamer = streamer;
 }
Example #32
0
 /// <summary>Build a new package loader.</summary>
 public AssemblyLoader(IBlobStorageProvider storage)
 {
     _blobs = storage;
     _runtimeSerializer = new CloudFormatter();
 }
 public TestableTestRequestHandler(TestHostConnectionInfo testHostConnectionInfo, ICommunicationEndpointFactory communicationEndpointFactory, IDataSerializer dataSerializer, JobQueue <Action> jobQueue)
     : base(testHostConnectionInfo, communicationEndpointFactory, dataSerializer, jobQueue, OnAckMessageReceived)
 {
 }
Example #34
0
 /// <summary>
 /// Updates a blob if it already exists.
 /// If the insert or update lambdas return empty, the blob will not be changed.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The provided lambdas can be executed multiple times in case of
 /// concurrency-related retrials, so be careful with side-effects
 /// (like incrementing a counter in them).
 /// </para>
 /// <para>This method is idempotent if and only if the provided lambdas are idempotent.</para>
 /// </remarks>
 /// <returns>The value returned by the lambda, or empty if the blob did not exist or no change was applied.</returns>
 public static Maybe <T> UpdateBlobIfExistOrSkip <T>(
     this IBlobStorageProvider provider, IBlobLocationAndType <T> location, Func <T, Maybe <T> > update, IDataSerializer serializer = null)
 {
     return(provider.UpsertBlobOrSkip(location.ContainerName, location.Path, () => Maybe <T> .Empty, update, serializer));
 }
Example #35
0
 public EventStore(IMessageSender sender, ITapeStorageFactory tapeFactory, IDataSerializer serializer)
 {
     this.sender = sender;
     this.tapeFactory = tapeFactory;
     this.serializer = serializer;
 }
Example #36
0
 /// <summary>
 /// Inserts or updates a blob depending on whether it already exists or not.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The provided lambdas can be executed multiple times in case of
 /// concurrency-related retrials, so be careful with side-effects
 /// (like incrementing a counter in them).
 /// </para>
 /// <para>
 /// This method is idempotent if and only if the provided lambdas are idempotent
 /// and if the object returned by the insert lambda is an invariant to the update lambda
 /// (if the second condition is not met, it is idempotent after the first successful call).
 /// </para>
 /// </remarks>
 /// <returns>The value returned by the lambda.</returns>
 public static T UpsertBlob <T>(this IBlobStorageProvider provider, IBlobLocation location, Func <T> insert, Func <T, T> update, IDataSerializer serializer = null)
 {
     return(provider.UpsertBlobOrSkip <T>(location.ContainerName, location.Path, () => insert(), t => update(t), serializer).Value);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudConfiguration"/> class.
 /// </summary>
 public CloudConfiguration(IBlobStorageProvider storage)
 {
     _blobs = storage;
     _runtimeSerializer = new CloudFormatter();
 }
Example #38
0
 /// <summary>
 /// List and get all blobs matching the provided blob name prefix.
 /// </summary>
 /// <remarks>
 /// <para>This method is sideeffect-free, except for infrastructure effects like thread pool usage.</para>
 /// </remarks>
 public static IEnumerable <T> ListBlobs <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> locationPrefix, int skip = 0, IDataSerializer serializer = null)
 {
     return(provider.ListBlobs <T>(locationPrefix.ContainerName, locationPrefix.Path, skip, serializer));
 }
 public MouseEventsRequestHandler(IQueueWriter writer, IDataSerializer serializer, IEnvelopeStreamer streamer)
 {
     _writer = writer;
     _serializer = serializer;
     _streamer = streamer;
 }
Example #40
0
 public UiSliderController(IUiSliderService uiSliderService, IModelMapper modelMapper, IMediaAccountant mediaAccountant, IDataSerializer dataSerializer)
 {
     _uiSliderService = uiSliderService;
     _modelMapper     = modelMapper;
     _mediaAccountant = mediaAccountant;
     _dataSerializer  = dataSerializer;
 }
Example #41
0
 public static Maybe <T> GetBlob <T>(this IBlobStorageProvider provider, IBlobLocationAndType <T> location, out string etag, IDataSerializer serializer = null)
 {
     return(provider.GetBlob <T>(location.ContainerName, location.Path, out etag, serializer));
 }
Example #42
0
 internal VsTestConsoleRequestSender(ICommunicationManager communicationManager, IDataSerializer dataSerializer, ITestPlatformEventSource testPlatformEventSource)
 {
     this.communicationManager    = communicationManager;
     this.dataSerializer          = dataSerializer;
     this.testPlatformEventSource = testPlatformEventSource;
 }
        public virtual void SetUp()
        {
            serializer = new JsonDataSerializer();

            testObject = new JsonTestObject("cmartin", "*****@*****.**");
        }
Example #44
0
 internal TestableDesignModeClient(ICommunicationManager communicationManager,
                                   IDataSerializer dataSerializer)
     : base(communicationManager, dataSerializer)
 {
 }
Example #45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudServices"/> class.
 /// </summary>
 public CloudServices(IBlobStorageProvider storage)
 {
     _blobs = storage;
     _runtimeSerializer = new CloudFormatter();
 }