Beispiel #1
0
        private void On_PluginOptions_Load(object sender, EventArgs e)
        {
            var config = new DefaultFactory(Log).CreateFdsConfig() ?? new FdsPluginConfig
            {
                ElementSize    = 100,
                DevicesDensity = 4,
                InfoCollectors = GetInfoCollectors()
            };

            tbFdsPath.Text       = config.PathToFds;
            tbSmokeViewPath.Text = config.PathToSmokeView;

            chbElementSize.Checked = config.UseCustomElementSize;
            gbElementSize.Enabled  = config.UseCustomElementSize;
            tbElementSize.Text     = config.ElementSize.ToString();

            chbDevicesDensity.Checked = config.DefineCustomDevicesDensity;
            gbDevicesDensity.Enabled  = config.DefineCustomDevicesDensity;
            tbDevicesDensity.Text     = config.DevicesDensity.ToString();

            foreach (var collector in config.InfoCollectors)
            {
                chlbDevices.Items.Add(collector, collector.CollectInfo);
            }
        }
Beispiel #2
0
    static async Task AsyncMain()
    {
        #region logging
        DefaultFactory defaultFactory = LogManager.Use <DefaultFactory>();
        defaultFactory.Level(LogLevel.Fatal);
        #endregion
        BusConfiguration busConfiguration = new BusConfiguration();
        busConfiguration.EndpointName("Samples.Logging.Default");
        busConfiguration.SendFailedMessagesTo("error");
        busConfiguration.UseSerialization <JsonSerializer>();
        busConfiguration.EnableInstallers();
        busConfiguration.UsePersistence <InMemoryPersistence>();

        IEndpointInstance endpoint = await Endpoint.Start(busConfiguration);

        try
        {
            IBusContext busContext = endpoint.CreateBusContext();
            await busContext.SendLocal(new MyMessage());

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpoint.Stop();
        }
    }
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            TaskScheduler.UnobservedTaskException      += TaskScheduler_UnobservedTaskException;

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            DefaultFactory defaultFactory = LogManager.Use <DefaultFactory>();

            defaultFactory.Level(LogLevel.Debug);

            var configuration = new BusConfiguration();

            configuration.EndpointName("NServiceBusV5.AsyncVoid");

            configuration.UseTransport <MsmqTransport>();
            configuration.UsePersistence <InMemoryPersistence>();

            var bus = Bus.Create(configuration).Start();

            bus.SendLocal(new AcquireVanilla());

            Console.ReadLine();
        }
Beispiel #4
0
        public ModelItemListData()
        {
            var userSettings = DefaultFactory.GetDefaultUserSettings();

            _FileOnlyFoldersFilter = userSettings.GetSettingBool(Shared.Enums.UserSettingEnum.EnableTreeOnlyFolders);
            _FileCollectionMode    = userSettings.GetSettingBool(Shared.Enums.UserSettingEnum.EnableTreeCollections);
        }
        public static ICspProxyFactory Create(X509Certificate2 certificate, bool includePrivateKey)
        {
            ICspProxyFactory factory;
            RSACryptoServiceProvider rsa;

            if (includePrivateKey && certificate.HasPrivateKey)
                rsa = (RSACryptoServiceProvider)certificate.PrivateKey;
            else
                rsa = (RSACryptoServiceProvider)certificate.PublicKey.Key;

            // Export will fail if we attempt to export private when there is none
            // Export also fails if key is not exportable
            if (rsa.PublicOnly)
            {
                factory = new DefaultFactory(rsa.ExportCspBlob(false), rsa.KeySize);
                rsa.Dispose();
            }
            else if (rsa.CspKeyContainerInfo.Exportable)
            {
                factory = new DefaultFactory(rsa.ExportCspBlob(true), rsa.KeySize);
                rsa.Dispose();
            }
            else
            {
                factory = new CachingFactory(rsa);
            }

            return factory;
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            DefaultFactory defaultFactory = LogManager.Use <DefaultFactory>();

            defaultFactory.Level(LogLevel.Fatal);

            var configuration = new BusConfiguration();

            configuration.EndpointName("Chocolate.Facility.Producer");

            configuration.UseTransport <MsmqTransport>();
            configuration.UsePersistence <InMemoryPersistence>();

            var bus = Bus.Create(configuration).Start();

            stopWatch.Stop();

            Console.WriteLine($"Initalizing the bus took { stopWatch.Elapsed.ToString("G")}");
            stopWatch.Reset();
            stopWatch.Start();
            Syncher.SyncEvent.Wait();
            stopWatch.Stop();
            Console.WriteLine($"Receiving #{ Syncher.SyncEvent.InitialCount } of msgs over the bus took { stopWatch.Elapsed.ToString("G")}");

            Console.ReadLine();
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            var stopWatch = new Stopwatch();
            stopWatch.Start();
            DefaultFactory defaultFactory = LogManager.Use<DefaultFactory>();
            defaultFactory.Level(LogLevel.Fatal);

            var configuration = new EndpointConfiguration("Chocolate.Facility.Producer");

            configuration.UseTransport<MsmqTransport>();
            configuration.UsePersistence<InMemoryPersistence>();
            configuration.EnableInstallers();
            configuration.LimitMessageProcessingConcurrencyTo(Constants.MaxConcurrency);

            var bus = Endpoint.Start(configuration).GetAwaiter().GetResult();
            stopWatch.Stop();

            Console.WriteLine($"Initalizing the bus took { stopWatch.Elapsed.ToString("G")}");
            stopWatch.Reset();
            stopWatch.Start();
            Syncher.SyncEvent.Wait();
            stopWatch.Stop();
            Console.WriteLine($"Receiving #{ Syncher.SyncEvent.InitialCount } of msgs over the bus took { stopWatch.Elapsed.ToString("G")}");

            Console.ReadLine();
        }
        public override void WriteEndVersion(Process process, AbstractConnection input, Entity entity, bool force = false) {
            if (entity.Updates + entity.Inserts > 0 || force) {
                var client = new ElasticSearchClientFactory().Create(this, TflBatchEntity(entity.ProcessName));
                var versionType = entity.Version == null ? "string" : entity.Version.SimpleType;

                string end;
                if (versionType.Equals("datetime") && entity.End is DateTime) {
                    end = ((DateTime)entity.End).ToString("yyyy-MM-ddTHH:mm:ss.fff");
                } else if (versionType.Equals("byte[]") || versionType.Equals("rowversion")) {
                    end = Common.BytesToHexString((byte[])entity.End);
                } else {
                    end = new DefaultFactory(Logger).Convert(entity.End, versionType).ToString();
                }

                var body = new {
                    id = entity.TflBatchId,
                    tflbatchid = entity.TflBatchId,
                    process = entity.ProcessName,
                    connection = input.Name,
                    entity = entity.Alias,
                    updates = entity.Updates,
                    inserts = entity.Inserts,
                    deletes = entity.Deletes,
                    version = end,
                    version_type = versionType,
                    tflupdate = DateTime.UtcNow
                };
                client.Client.Index(client.Index, client.Type, body);
            }
        }
Beispiel #9
0
        public static ICspProxyFactory Create(X509Certificate2 certificate, bool includePrivateKey)
        {
            ICspProxyFactory         factory;
            RSACryptoServiceProvider rsa;

            if (includePrivateKey && certificate.HasPrivateKey)
            {
                rsa = (RSACryptoServiceProvider)certificate.PrivateKey;
            }
            else
            {
                rsa = (RSACryptoServiceProvider)certificate.PublicKey.Key;
            }

            // Export will fail if we attempt to export private when there is none
            // Export also fails if key is not exportable
            if (rsa.PublicOnly)
            {
                factory = new DefaultFactory(rsa.ExportCspBlob(false), rsa.KeySize);
                rsa.Dispose();
            }
            else if (rsa.CspKeyContainerInfo.Exportable)
            {
                factory = new DefaultFactory(rsa.ExportCspBlob(true), rsa.KeySize);
                rsa.Dispose();
            }
            else
            {
                factory = new CachingFactory(rsa);
            }

            return(factory);
        }
        public void LoadSettings()
        {
            var userSettings = DefaultFactory.GetDefaultUserSettings();

            LinkedProgramsData            = new ObservableCollection <LinkedProgramData>(userSettings.GetSettingSerialized <List <LinkedProgramData> >(UserSettingEnum.ConfigLinkedProgramsList) ?? new List <LinkedProgramData>());
            EnableDebugLogs               = userSettings.GetSettingBool(UserSettingEnum.EnableDebugLogs);
            CachePath                     = (CacheEnums.CachePathType)userSettings.GetSettingInt(UserSettingEnum.PreferredCachePath);
            SelectedThumbnailRenderAspec  = (RenderAspectEnum)userSettings.GetSettingInt(UserSettingEnum.Thumbnails3DAspect);
            EnableThumnailColorsByShaders = userSettings.GetSettingBool(UserSettingEnum.EnableThumnailColorsByShaders);
            EnableChangingViewColorChangesThumnailColor = userSettings.GetSettingBool(UserSettingEnum.EnableChangingViewColorChangesThumnailColor);

            EnableMeshDecimation            = userSettings.GetSettingBool(UserSettingEnum.EnableMeshDecimation);
            MinTrianglesForMeshDecimation   = userSettings.GetSettingInt(UserSettingEnum.MinTrianglesForMeshDecimation);
            EnableMaxSizeMBToLoadMeshInView = userSettings.GetSettingBool(UserSettingEnum.EnableMaxSizeMBToLoadMeshInView);
            MaxSizeMBToLoadMeshInView       = userSettings.GetSettingInt(UserSettingEnum.MaxSizeMBToLoadMeshInView);

            EnableReduceThumbnailResolution = userSettings.GetSettingBool(UserSettingEnum.EnableReduceThumbnailResolution);
            EnableReduceThumbnailQuality    = userSettings.GetSettingBool(UserSettingEnum.EnableReduceThumbnailQuality);


            NotifyPropertyChanged(nameof(LinkedProgramsData));
            NotifyPropertyChanged(nameof(EnableDebugLogs));
            NotifyPropertyChanged(nameof(CachePath));
            NotifyPropertyChanged(nameof(SelectedThumbnailRenderAspec));
            NotifyPropertyChanged(nameof(EnableThumnailColorsByShaders));
            NotifyPropertyChanged(nameof(EnableChangingViewColorChangesThumnailColor));
            NotifyPropertyChanged(nameof(EnableMeshDecimation));
            NotifyPropertyChanged(nameof(MinTrianglesForMeshDecimation));
            NotifyPropertyChanged(nameof(EnableMaxSizeMBToLoadMeshInView));
            NotifyPropertyChanged(nameof(MaxSizeMBToLoadMeshInView));
            NotifyPropertyChanged(nameof(EnableReduceThumbnailResolution));
            NotifyPropertyChanged(nameof(EnableReduceThumbnailQuality));
        }
        public override void WriteEndVersion(Process process, AbstractConnection input, Entity entity, bool force = false) {

            if (entity.Updates + entity.Inserts > 0 || force) {

                var solr = GetOperations(process, entity.OutputName());
                var versionType = entity.Version == null ? "string" : entity.Version.SimpleType;

                string end;
                if (versionType.Equals("datetime") && entity.End is DateTime) {
                    end = ((DateTime)entity.End).ToString("yyyy-MM-ddTHH:mm:ss.fff");
                } else if (versionType.Equals("byte[]") || versionType.Equals("rowversion")) {
                    end = Common.BytesToHexString((byte[])entity.End);
                } else {
                    end = new DefaultFactory(Logger).Convert(entity.End, versionType).ToString();
                }

                var doc = new Dictionary<string, object> {
                    { "id", entity.TflBatchId},
                    { "tflbatchid", entity.TflBatchId},
                    { "process", entity.ProcessName},
                    { "connection", input.Name},
                    { "entity", entity.Alias},
                    { "updates", entity.Updates},
                    { "inserts", entity.Inserts},
                    { "deletes", entity.Deletes},
                    { "version", end},
                    { "version_type", versionType},
                    { "tflupdate", DateTime.UtcNow}
                };
                solr.Add(doc);
                solr.Commit();
            }
        }
        public DefinitionBuilderFacts()
        {
            var factory    = new DefaultFactory();
            var definition = new Definition <TestQuestion, string, int, string>();

            this.testee = new DefinitionBuilder <TestQuestion, string, int, string>(definition, factory);
        }
    static async Task AsyncMain()
    {
        Console.Title = "Samples.Notifications";
        #region logging
        DefaultFactory defaultFactory = LogManager.Use <DefaultFactory>();
        defaultFactory.Level(LogLevel.Fatal);
        #endregion
        #region endpointConfig
        EndpointConfiguration endpointConfiguration = new EndpointConfiguration("Samples.Notifications");
        SubscribeToNotifications.Subscribe(endpointConfiguration);
        #endregion

        endpointConfiguration.SendFailedMessagesTo("error");
        endpointConfiguration.UseSerialization <JsonSerializer>();
        endpointConfiguration.EnableInstallers();
        endpointConfiguration.UsePersistence <InMemoryPersistence>();


        IEndpointInstance endpoint = await Endpoint.Start(endpointConfiguration);

        try
        {
            await endpoint.SendLocal(new MyMessage());

            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
        finally
        {
            await endpoint.Stop();
        }
    }
Beispiel #14
0
        public static IEnumerable <object[]> GetMetaData()
        {
            IAbstractFactory factory = new DefaultFactory();

            yield return(new object[] { factory.CreateCoreMetaData(null) });

            yield return(new object[] { factory.CreateExtensionMetaData(null) });
        }
Beispiel #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EvaluationEngine"/> class.
        /// </summary>
        /// <param name="parentEngine">The parent engine. Pass the parent engine to build up hierarchical engines.</param>
        public EvaluationEngine(IDefinitionHostProvider parentEngine)
        {
            Ensure.ArgumentNotNull(parentEngine, "parentEngine");

            var factory = new DefaultFactory();

            this.engine = new Engine(new DefinitionHost(parentEngine.DefinitionHost), factory, factory);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EvaluationEngine"/> class.
        /// </summary>
        /// <param name="parentEngine">The parent engine. Pass the parent engine to build up hierarchical engines.</param>
        public EvaluationEngine(IDefinitionHostProvider parentEngine)
        {
            Guard.AgainstNullArgument("parentEngine", parentEngine);

            var factory = new DefaultFactory();

            this.engine = new Engine(new DefinitionHost(parentEngine.DefinitionHost), factory, factory);
        }
Beispiel #17
0
 public static ILogger CreateLogger <T>()
 {
     if (LoggerFactory == null)
     {
         return(DefaultFactory.CreateLogger <T>());
     }
     return(LoggerFactory.CreateLogger <T>());
 }
Beispiel #18
0
        public void ShouldCreateTokenizer()
        {
            var factory      = new DefaultFactory();
            var fileMetaData = new CoreFileMetaData(coreFileType);
            var tokenizer    = factory.CreateTokenizer(fileMetaData);

            Assert.IsType <Tokenizer>(tokenizer);
            Assert.IsAssignableFrom <ITokenizer>(tokenizer);
        }
        public ActionResult CreateActionResult(ActionResultSelector selector)
        {
            if (actionResultRegistry.CanSatisfy(selector))
            {
                return(CreateActionResultFromRegistry(selector));
            }

            return(ActionResultPipeLine.Create(selector) ?? DefaultFactory.Create(selector));
        }
Beispiel #20
0
        public static void InicializationCore()
        {
            var factory = new DefaultFactory();

            core = new PlayerCore(factory);
            core.SaveDatabase();
            Scaning();
            StartCalculeteProcessor();
        }
        void ChangingLevel()
        {
            #region OverrideLoggingLevelInCode

            DefaultFactory defaultFactory = LogManager.Use <DefaultFactory>();
            defaultFactory.Level(LogLevel.Debug);

            #endregion
        }
Beispiel #22
0
        static void Main(string[] args)
        {
            var container = new Container();

            container.Register <ResourceManager>(Properties.Resources.ResourceManager).WithLifetime(Lifetime.Singleton);
            var objectFactory = new DefaultFactory(container);

            ConsoleApplicationManager.For <Program>().UsingFactory(objectFactory).Run(args);
            Console.ReadLine();
        }
    public void ChangingDefaults()
    {
        #region OverrideLoggingDefaultsInCode

        DefaultFactory defaultFactory = LogManager.Use <DefaultFactory>();
        defaultFactory.Directory("pathToLoggingDirectory");
        defaultFactory.Level(LogLevel.Debug);

        #endregion
    }
        public void When_directory_is_bad_should_throw()
        {
            var defaultFactory = new DefaultFactory();
            var nonExistingDirectoryException = Assert.Throws <DirectoryNotFoundException>(() => defaultFactory.Directory("baddir"));

            Assert.AreEqual("Could not find logging directory: 'baddir'", nonExistingDirectoryException.Message);
            Assert.Throws <ArgumentNullException>(() => defaultFactory.Directory(null));
            Assert.Throws <ArgumentNullException>(() => defaultFactory.Directory(""));
            Assert.Throws <ArgumentNullException>(() => defaultFactory.Directory(" "));
        }
Beispiel #25
0
        public ApplicationTestContext()
        {
            container = new Container();

            Commands    = new Mock <ICommandVerification>();
            Application = new Mock <IApplicationVerification <T> >();

            container.Register <ICommandVerification>(Commands.Object);
            container.Register <IApplicationVerification <T> >(Application.Object);
            Factory = new DefaultFactory(container);
        }
Beispiel #26
0
        public async Task DefaultFactoryTest()
        {
            DefaultFactory factory = new DefaultFactory("ec89b162d4a9922c8fa40769c2453d8b-cc1fb522857d46a08a90ef09730343a6", AccountType.practice, 4905675);
            RateEndpoints rateEndpoints = factory.GetEndpoint<RateEndpoints>();

            Assert.IsNotNull(rateEndpoints);

            List<Price> prices = await rateEndpoints.GetPrices("EUR_USD");
            Assert.IsNotNull(prices);
            Assert.IsTrue(prices.Count > 0);
        }
Beispiel #27
0
        public void ShouldCreateFileReader()
        {
            var factory = new DefaultFactory(cfg =>
            {
                cfg.Add <FileReaderConfiguration>(cfg => cfg.BufferSize = 0);
            });
            var fileReader = factory.CreateFileReader("./resources/whales/whales.txt", new CoreFileMetaData(coreFileType));

            Assert.IsAssignableFrom <IFileReader>(fileReader);
            //Since the BufferSize is 0 this should throw when it tries to open the file
            Assert.Throws <ArgumentOutOfRangeException>(() => fileReader.DataRows.First());
        }
Beispiel #28
0
        public async Task DefaultFactoryTest()
        {
            DefaultFactory factory       = new DefaultFactory("ec89b162d4a9922c8fa40769c2453d8b-cc1fb522857d46a08a90ef09730343a6", AccountType.practice, 4905675);
            RateEndpoints  rateEndpoints = factory.GetEndpoint <RateEndpoints>();

            Assert.IsNotNull(rateEndpoints);

            List <Price> prices = await rateEndpoints.GetPrices("EUR_USD");

            Assert.IsNotNull(prices);
            Assert.IsTrue(prices.Count > 0);
        }
        public bool LoadDirectories(IEnumerable <string> paths)
        {
            IsLoading               = false;
            MainDispatcher          = Dispatcher.CurrentDispatcher;
            cancellationTokenSource = new CancellationTokenSource();
            cancellationToken       = cancellationTokenSource.Token;

            cache        = DefaultFactory.GetDefaultThumbnailCache();
            userSettings = DefaultFactory.GetDefaultUserSettings();
            renderType   = (RenderAspectEnum)userSettings.GetSettingInt(UserSettingEnum.Thumbnails3DAspect);

            logger.Info("Loading paths: Received: [{0}]", string.Join("] [", paths));
            paths = paths.Where(p1 => !paths.Any(p2 => !p1.Equals(p2) && p1.Contains(p2))).ToArray(); // Remove selected subdirectories of other selected paths.
            logger.Info("Loading paths: After removed subdirs: [{0}]", string.Join("] [", paths));

            try
            {
                IEnumerable <string> pathsFound = new List <string>();
                for (int i = 0; i < SupportedExtensionsFilter.Length; i++)
                {
                    foreach (string path in paths)
                    {
                        pathsFound = pathsFound.Concat(UtilMethods.EnumerateFiles(path, SupportedExtensionsFilter[i], SearchOption.AllDirectories, cancellationToken));
                    }
                }
                pathsFound = pathsFound.ToArray();

                if (cancellationToken.IsCancellationRequested)
                {
                    return(false);
                }

                if (pathsFound.Count() > 0)
                {
                    CalculateThumnailSizes(pathsFound.Count());
                    InitializeFoundFilesObjects(pathsFound);
                    return(true);
                }
                else
                {
                    FilesFound = new ModelFileData[0];
                }
            }
            catch (Exception ex)
            {
                logger.Trace(ex, "Unable to load: {ex}", ex.Message);
            }
            return(false);
        }
Beispiel #30
0
        public override void WriteEndVersion(Process process, AbstractConnection input, Entity entity, bool force = false)
        {
            var logger = process.Logger;

            //default implementation for relational database
            if (entity.Inserts + entity.Updates > 0 || force)
            {
                using (var cn = GetConnection()) {
                    cn.Open();

                    var cmd = cn.CreateCommand();

                    if (!entity.CanDetectChanges(input.IsDatabase))
                    {
                        cmd.CommandText = @"
                            INSERT INTO TflBatch(TflBatchId, ProcessName, EntityName, TflUpdate, Inserts, Updates, Deletes)
                            VALUES(@TflBatchId, @ProcessName, @EntityName, @TflUpdate, @Inserts, @Updates, @Deletes);
                        ";
                    }
                    else
                    {
                        var field = entity.Version.SimpleType.Replace("rowversion", "Binary").Replace("byte[]", "Binary") + "Version";
                        cmd.CommandText = string.Format(@"
                            INSERT INTO TflBatch(TflBatchId, ProcessName, EntityName, {0}, TflUpdate, Inserts, Updates, Deletes)
                            VALUES(@TflBatchId, @ProcessName, @EntityName, @End, @TflUpdate, @Inserts, @Updates, @Deletes);
                        ", field);
                    }

                    cmd.CommandType = CommandType.Text;

                    AddParameter(cmd, "@TflBatchId", entity.TflBatchId);
                    AddParameter(cmd, "@ProcessName", entity.ProcessName);
                    AddParameter(cmd, "@EntityName", entity.Alias);
                    AddParameter(cmd, "@TflUpdate", DateTime.Now);
                    AddParameter(cmd, "@Inserts", entity.Inserts);
                    AddParameter(cmd, "@Updates", entity.Updates);
                    AddParameter(cmd, "@Deletes", entity.Deletes);

                    if (entity.CanDetectChanges(input.IsDatabase))
                    {
                        var end = new DefaultFactory(Logger).Convert(entity.End, entity.Version.SimpleType);
                        AddParameter(cmd, "@End", end);
                    }

                    logger.EntityDebug(entity.Name, cmd.CommandText);
                    cmd.ExecuteNonQuery();
                }
            }
        }
Beispiel #31
0
        static void Main(string[] args)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            DefaultFactory defaultFactory = LogManager.Use <DefaultFactory>();

            defaultFactory.Level(LogLevel.Error);

            var configuration = new EndpointConfiguration("Chocolate.Facility");

            configuration.UseTransport <MsmqTransport>();
            configuration.UsePersistence <InMemoryPersistence>();
            configuration.EnableInstallers();
            configuration.LimitMessageProcessingConcurrencyTo(Constants.MaxConcurrency);

            var bus = Endpoint.Start(configuration).GetAwaiter().GetResult();

            stopWatch.Stop();

            Console.WriteLine($"Initalizing the bus took { stopWatch.Elapsed.ToString("G")}");
            stopWatch.Reset();

            var destination = "Chocolate.Facility.Producer";

            stopWatch.Start();

            var tasks = new List <Task>();

            for (int i = 0; i < 8; i++)
            {
                var task = Task.Run(async() =>
                {
                    for (int j = 0; j < Constants.NumberOfMessages / 8; j++)
                    {
                        await bus.Send(destination, new ProduceChocolateBar {
                            LotNumber = j, MaxLotNumber = Constants.NumberOfMessages
                        }).ConfigureAwait(false);
                    }
                });
                tasks.Add(task);
            }

            Task.WhenAll(tasks).GetAwaiter().GetResult();
            stopWatch.Stop();
            Console.WriteLine($"Sending #{ Constants.NumberOfMessages } of msgs over the bus took { stopWatch.Elapsed.ToString("G")}");

            Console.ReadLine();
        }
        private static DiningSet AssembleSet(DefaultFactory factory)
        {
            List <Chair> chairs = new List <Chair>();

            for (int i = 0; i < 4; i++)
            {
                chairs.Add(factory.MakeChair());
            }

            return(new DiningSet()
            {
                Table = factory.MakeTable(),
                Chairs = chairs
            });
        }
        static void Main(string[] args)
        {
            IFactory factory = new DefaultFactory();

            factory.MakeBanner().ShowWhichUiIAm();
            factory.MakeMenu().ShowWhichUiIAm();
            factory.MakePopup().ShowWhichUiIAm();

            factory = new FestivalFactory();
            factory.MakeBanner().ShowWhichUiIAm();
            factory.MakeMenu().ShowWhichUiIAm();
            factory.MakePopup().ShowWhichUiIAm();

            Console.ReadLine();
        }
Beispiel #34
0
        static void Main()
        {
            var container = new Container();

            container.Register <ResourceManager>(Properties.Resources.ResourceManager).WithLifetime(Lifetime.Singleton);
            var objectFactory = new DefaultFactory(container);

            var program = ConsoleApplicationManager.For <Program>().UsingFactory(objectFactory).Run();

            PrintArgs(program.Arguments);
            if (program.Arguments != null && program.Arguments.Wait)
            {
                Console.WriteLine();
                program.WaitForEnter();
            }
        }
Beispiel #35
0
 public void Run(NetworkStream stream)
 {
     HostedMode.Host = new CallContextStorage();
     try {
         var session = new RemoteSession(stream, stream);
         var factory = new DefaultFactory();
         var bridge = new JsBridge(session, factory);
         HostedMode.Host = bridge;
         bridge.DispatchForever();
     }
     catch (Exception ex) {
         Debug.WriteLine(ex);
     }
     finally {
         stream.Close();
     }
 }
        public override void WriteEndVersion(Process process, AbstractConnection input, Entity entity, bool force = false) {
            //default implementation for relational database
            if (entity.Inserts + entity.Updates > 0 || force) {
                using (var cn = GetConnection()) {
                    cn.Open();

                    var cmd = cn.CreateCommand();

                    if (!entity.CanDetectChanges(input.IsDatabase)) {
                        cmd.CommandText = @"
                            INSERT INTO TflBatch(TflBatchId, ProcessName, EntityName, TflUpdate, Inserts, Updates, Deletes)
                            VALUES(@TflBatchId, @ProcessName, @EntityName, @TflUpdate, @Inserts, @Updates, @Deletes);
                        ";
                    } else {
                        var field = entity.Version.SimpleType.Replace("rowversion", "Binary").Replace("byte[]", "Binary") + "Version";
                        cmd.CommandText = string.Format(@"
                            INSERT INTO TflBatch(TflBatchId, ProcessName, EntityName, {0}, TflUpdate, Inserts, Updates, Deletes)
                            VALUES(@TflBatchId, @ProcessName, @EntityName, @End, @TflUpdate, @Inserts, @Updates, @Deletes);
                        ", field);
                    }

                    cmd.CommandType = CommandType.Text;

                    AddParameter(cmd, "@TflBatchId", entity.TflBatchId);
                    AddParameter(cmd, "@ProcessName", entity.ProcessName);
                    AddParameter(cmd, "@EntityName", entity.Alias);
                    AddParameter(cmd, "@TflUpdate", DateTime.Now);
                    AddParameter(cmd, "@Inserts", entity.Inserts);
                    AddParameter(cmd, "@Updates", entity.Updates);
                    AddParameter(cmd, "@Deletes", entity.Deletes);

                    if (entity.CanDetectChanges(input.IsDatabase)) {
                        var end = new DefaultFactory(Logger).Convert(entity.End, entity.Version.SimpleType);
                        AddParameter(cmd, "@End", end);
                    }

                    Logger.EntityDebug(entity.Name, cmd.CommandText);
                    cmd.ExecuteNonQuery();
                }
            }
        }