protected void LinkPorts(ComponentContext ctxFrom, ComponentContext ctxTo, IPortLinkGlyph portLink)
        {
            string fromPortName = portLink.FromPortName;
            string toPortName = portLink.ToPortName;

            IQPort portFrom = GetPort (ctxFrom, fromPortName);
            IQPort toPort = GetPort (ctxTo, toPortName);

            portFrom.QEvents += new QEventHandler(toPort.Receive);

            AddPortLinkToPortContext (portFrom, portLink);
        }
Esempio n. 2
0
        public void when_resolving_binding_then_resolves_type()
        {
            var config = new BindingConfiguration(typeof(GenerateCode))
            {
                Properties =
                {
                    new PropertyBindingConfiguration("TargetFileName")
                    {
                        ValueProvider = new BindingConfiguration(typeof(ExpressionValueProvider))
                        {
                            Properties =
                            {
                                new PropertyBindingConfiguration("Expression")
                                {
                                    ValueProvider = new BindingConfiguration(typeof(ExpressionValueProvider))
                                    {
                                        Properties =
                                        {
                                            new PropertyBindingConfiguration("Expression")
                                            {
                                                Value = "{Name}Controller",
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    new PropertyBindingConfiguration("TargetPath")
                    {
                        Value = "~",
                    },
                }
            };

            var context = new ComponentContext();
            var factory = new BindingFactory();
            var binding = factory.CreateBinding<GenerateCode>(context, config);

            var command = (GenerateCode)binding.Instance;

            binding.Refresh();

            Assert.Equal("~", command.TargetPath);
            Assert.Equal("{Name}Controller11", command.TargetFileName);

            binding.Refresh();

            Assert.Equal("~", command.TargetPath);

            Assert.Equal("{Name}Controller22", command.TargetFileName);
        }
Esempio n. 3
0
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.Register(typeof(SingletonComponent));
     _context.Register(typeof(TransientComponent));
 }
Esempio n. 4
0
 public static FluentLocalComponentConfig <T> ForComponent <T>(this ComponentContext context)
 {
     return(new FluentLocalComponentConfig <T>(context));
 }
Esempio n. 5
0
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.Register("anotherName", typeof(ComponentWithDefaultName));
     _context.Register("anotherName", typeof(ComponentWithoutName));
 }
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.RegisterAssembly(typeof(Aop.AssemblyPointer).Assembly);
     _classEmitter = _context.GetComponent <IClassEmitter>();
 }
Esempio n. 7
0
        public void StartWorkerService()
        {
            var workerService = ComponentContext.GetComponent <WorkerService>();

            workerService.StartAsync().GetAwaiter().GetResult();
        }
Esempio n. 8
0
 public static void ProcessCompositionXmlFromResource(this ComponentContext context, string configurationResourceName)
 {
     context.ProcessCompositionXmlFromResource(Assembly.GetCallingAssembly(), configurationResourceName);
 }
Esempio n. 9
0
 public BaseRepository()
 {
     context = new ComponentContext();
     dbSet   = context.Set <T>();
 }
Esempio n. 10
0
 public void RegisterJobQueue(Type jobQueue, string queueTypeName)
 {
     ComponentContext.Register(typeof(IJobStepSource <>), queueTypeName, jobQueue);
 }
 protected ComponentContextBuilder(ComponentContext context)
 {
     Context = context;
 }
Esempio n. 12
0
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.Register("someName", typeof(SampleComponent));
 }
Esempio n. 13
0
        static async Task Main(string[] args)
        {
            var books = new Dictionary <string, string> {
                { "Pride and Prejudice", "http://www.gutenberg.org/files/1342/1342-0.txt" },
                { "The War That Will End War", "http://www.gutenberg.org/files/57481/57481-0.txt" },
                { "Alice’s Adventures in Wonderland", "http://www.gutenberg.org/files/11/11-0.txt" },
                { "Dracula", "http://www.gutenberg.org/cache/epub/345/pg345.txt" },
                { "The Iliad of Homer", "http://www.gutenberg.org/cache/epub/6130/pg6130.txt" },
                { "Dubliners", "http://www.gutenberg.org/files/2814/2814-0.txt" },
                { "Gulliver's Travels", "http://www.gutenberg.org/files/829/829-0.txt" }
            };

            var wordcountContext = new ComponentContext("wordcount",
                                                        new ComponentResolverProductionStrategy(),
                                                        new ComponentResolverBinDirectoryStrategy()
                                                        );

            var mostcommonwordsContext = new ComponentContext("mostcommonwords",
                                                              new ComponentResolverProductionStrategy(),
                                                              new ComponentResolverBinDirectoryStrategy()
                                                              );

            var wordCountAsm       = wordcountContext.LoadAssemblyWithResolver("wordcount.dll");
            var mostcommonwordsAsm = mostcommonwordsContext.LoadAssemblyWithResolver("mostcommonwords.dll");

            var client = new HttpClient();

            foreach (var book in books)
            {
                var url = book.Value;
                using (var stream = await client.GetStreamAsync(url))
                    using (var reader = new StreamReader(stream))
                    {
                        var           wordCount       = (IProvider)wordCountAsm.CreateInstance("Lit.WordCount");
                        var           mostcommonwords = (IProvider)mostcommonwordsAsm.CreateInstance("Lit.MostCommonWords");
                        Task <string> line;
                        while (!reader.EndOfStream)
                        {
                            line = reader.ReadLineAsync();
                            try
                            {
                                var wordCountTask       = wordCount.ProcessTextAsync(line);
                                var mostcommonwordsTask = mostcommonwords.ProcessTextAsync(line);
                                await Task.WhenAll(wordCountTask, mostcommonwordsTask);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e.Message);
                                throw e;
                            }
                        }

                        var wordcountReport = wordCount.GetReport();
                        Console.WriteLine($"Book: {book.Key}; Word Count: {wordcountReport["count"]}");
                        Console.WriteLine("Most common words, with count:");
                        var mostcommonwordsReport  = mostcommonwords.GetReport();
                        var orderedMostcommonwords = (IOrderedEnumerable <KeyValuePair <string, int> >)mostcommonwordsReport["words"];
                        var mostcommonwordsCount   = (int)mostcommonwordsReport["count"];

                        var index = 0;
                        foreach (var word in orderedMostcommonwords)
                        {
                            if (index++ >= 10)
                            {
                                break;
                            }
                            Console.WriteLine($"{word.Key}; {word.Value}");
                        }
                    }
            }

            Console.WriteLine();
            foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
            {
                var context                  = AssemblyLoadContext.GetLoadContext(asm);
                var def                      = AssemblyLoadContext.Default;
                var isDefaultContext         = context == def;
                var isWordcountContext       = context == wordcountContext;
                var isMostcommonwordsContext = context == mostcommonwordsContext;

                if (asm.FullName.StartsWith("System") && isDefaultContext)
                {
                    continue;
                }

                Console.WriteLine($"{asm.FullName}  {asm.Location}");
                Console.WriteLine($"Default: {isDefaultContext}; WordCount: {isWordcountContext}; MostCommonWords: {isMostcommonwordsContext}");
            }
        }
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.SetVariableValue("variable", "variableValue");
 }
Esempio n. 15
0
 public ExampleViewComponent(ComponentContext context) : base(context)
 {
 }
 public FluentLocalComponentConfig(ComponentContext context)
     : base(context, new LocalComponentFactory(typeof(TComponent)))
 {
 }
Esempio n. 17
0
 public PongServant(ComponentContext context)
 {
     this.context = context;
 }
Esempio n. 18
0
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.Register((string)null, typeof(ComponentWithDefaultName));
     _context.Register((string)null, typeof(ComponentWithoutName));
 }
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.ProcessCompositionXmlFromResource(typeof(AssemblyPointer).Assembly,
                                                "ComposerCore.Tests.CompositionNotification.Xmls.Composition.xml");
 }
Esempio n. 20
0
 public IJobManager GetJobManager()
 {
     return(ComponentContext.GetComponent <IJobManager>());
 }
 public FluentPreInitializedComponentConfig(ComponentContext context, object componentInstance)
 {
     _context = context;
     _factory = new PreInitializedComponentFactory(componentInstance);
 }
Esempio n. 22
0
        public void RegisterJobProcessor(Type processor, Type stepType)
        {
            var contract = typeof(IJobProcessor <>).MakeGenericType(stepType);

            ComponentContext.Register(contract, processor);
        }
 IQPort GetPort(ComponentContext ctx, string portName)
 {
     Type type = ctx.Hsm.GetType ();
     System.Reflection.PropertyInfo propInfo = type.GetProperty (portName);
     if (propInfo == null)
     {
         throw new NullReferenceException ("Port [" + portName + "] not found on Component " + ctx.ComponentName + " - " + ctx.Hsm);
     }
     object port = propInfo.GetValue (ctx.Hsm, null);
     IQPort qport = port as IQPort;
     return qport;
 }
Esempio n. 24
0
 public ComponentRepository(ComponentContext context)
 {
     _context = context;
 }
 public void TestInitialize()
 {
     _context = new ComponentContext();
 }
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.ProcessCompositionXmlFromResource("Appson.Composer.UnitTests.InitializePlugs.Xmls.Composition.xml");
 }
Esempio n. 27
0
 public void TestInitialize()
 {
     _context      = new ComponentContext();
     _classEmitter = _context.GetComponent <IClassEmitter>();
 }
Esempio n. 28
0
 public HelloServant(ComponentContext context)
 {
     this.context = context;
 }
Esempio n. 29
0
        public static async Task Run(
            [QueueTrigger("munt-journey-queue", Connection = "AzureWebJobsStorage")]
            string message,
            [Blob("journeys", FileAccess.Read, Connection = "AzureWebJobsStorage")]
            CloudBlobContainer journeysContainer,
            [Queue("munt-component-queue"), StorageAccount("AzureWebJobsStorage")]
            ICollector <string> componentQueue,
            [Queue("munt-email-queue"), StorageAccount("AzureWebJobsStorage")]
            ICollector <string> emailQueue,
            ILogger log)
        {
            log.LogInformation($@"Journey triggered with message {message}");

            var journeyMessage           = DeserializeJourneyMessage(message);
            var journey                  = journeyMessage.Journey;
            var amountForCalculationArea = journeyMessage.AmountForCalculationArea;
            var intermediateResult       = amountForCalculationArea;
            var calculationResults       = journeyMessage.CalculationResults ?? new System.Collections.Generic.List <CalculationResult>();

            foreach (var area in journeyMessage.Journey.Areas.OrderBy(a => a.Order))
            {
                // This component has been processed, increase the intermediate result for the calculation area here
                intermediateResult +=
                    calculationResults
                    .Where(c => c.CalculationArea == area.Order)
                    .Sum(c => c.Value);

                foreach (var component in area.Components.OrderBy(c => c.Order))
                {
                    if (IsProcessed(component, journey.BreadCrumbs))
                    {
                        continue;
                    }

                    var componentContext = new ComponentContext
                    {
                        CalculationAreaOrder = area.Order,
                        Order = component.Order,
                        AmountForCalculationArea = amountForCalculationArea,
                        IntermediateResult       = intermediateResult,
                        CalculationResults       = calculationResults
                    };

                    componentQueue.Add(JsonConvert.SerializeObject(new ComponentMessage
                    {
                        MuntContext      = journeyMessage.Context,
                        ComponentContext = componentContext,
                        ComponentType    = component.Type,
                        ComponentVersion = component.Version,
                        Journey          = journey
                    }));
                    return; // stop function execution, wait for the component to re-queue a journey message
                }

                // This area has been processed, increase the amount for the calculation area here
                amountForCalculationArea =
                    calculationResults.Where(c => c.CalculationArea == area.Order)
                    .Sum(c => c.Value);
                // reset the intermediateResult for the next area
                intermediateResult = amountForCalculationArea;
            }

            // At the end, send an email with the results
            emailQueue.Add(JsonConvert.SerializeObject(new EmailMessage
            {
                Employee           = $"{journeyMessage.Context.EmployeeInformation.FirstName} {journeyMessage.Context.EmployeeInformation.LastName}",
                StartDate          = journeyMessage.Context.CalculationInformation.StartDate.Date,
                EndDate            = journeyMessage.Context.CalculationInformation.EndDate.Date,
                EmailAddress       = journeyMessage.Context.EmployeeInformation.Email,
                CalculationResults = calculationResults.ToArray(),
            }));
        }
	public ComponentContext component() {
		ComponentContext _localctx = new ComponentContext(Context, State);
		EnterRule(_localctx, 18, RULE_component);
		try {
			State = 866;
			switch ( Interpreter.AdaptivePredict(TokenStream,12,Context) ) {
			case 1:
				EnterOuterAlt(_localctx, 1);
				{
				State = 859; eventc();
				}
				break;
			case 2:
				EnterOuterAlt(_localctx, 2);
				{
				State = 860; todoc();
				}
				break;
			case 3:
				EnterOuterAlt(_localctx, 3);
				{
				State = 861; journalc();
				}
				break;
			case 4:
				EnterOuterAlt(_localctx, 4);
				{
				State = 862; freebusyc();
				}
				break;
			case 5:
				EnterOuterAlt(_localctx, 5);
				{
				State = 863; timezonec();
				}
				break;
			case 6:
				EnterOuterAlt(_localctx, 6);
				{
				State = 864; iana_comp();
				}
				break;
			case 7:
				EnterOuterAlt(_localctx, 7);
				{
				State = 865; x_comp();
				}
				break;
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}
Esempio n. 31
0
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.Configuration.DisableAttributeChecking = true;
 }
Esempio n. 32
0
 public void TestInitialize()
 {
     _context = new ComponentContext();
     _context.Register(typeof(SampleComponentOne));
 }
Esempio n. 33
0
 public static FluentPreInitializedComponentConfig ForObject(this ComponentContext context, object componentInstance)
 {
     return(new FluentPreInitializedComponentConfig(context, componentInstance));
 }