Ejemplo n.º 1
0
        protected ModuleModelMutable NewModuleModel(DictionaryQuery <CompositeModelType, CompositeModelTypeModelScopeSupport> compositeModelTypeSupport, DictionaryProxy <Int32, CompositeModel> models, LayerModelMutable owningLayer, ModuleArchitectureImpl module)
        {
            var state     = new ModuleModelState(this.CollectionsFactory);
            var immutable = new ModuleModelImmutable(state);
            var result    = new ModuleModelMutable(state, immutable);

            state.ModuleName = module.Name;
            state.LayerModel = owningLayer;
            state.Assembler  = module.LayeredCompositeAssembler;

            foreach (var modelType in this.ModelTypeSupport.Keys)
            {
                IDictionary <CompositeModel, Visibility> visibilities = null;
                if (!state.CompositeVisibilities.TryGetValue(modelType, out visibilities))
                {
                    visibilities = new Dictionary <CompositeModel, Visibility>(ReferenceEqualityComparer <CompositeModel> .ReferenceBasedComparer);
                    state.CompositeVisibilities.Add(modelType, visibilities);
                }
                foreach (LayeredCompositeAssemblyInfo info in module.LayeredCompositeAssembler.GetInfos(modelType).Cast <LayeredCompositeAssemblyInfo>())
                {
                    var cModel = this.NewCompositeModel(compositeModelTypeSupport, owningLayer.IQ.ApplicationModel, info, owningLayer.IQ.LayerName + "-" + module.Name);
                    models.Add(cModel.CompositeModelID, cModel);
                    state.CompositeModels.Add(cModel);
                    visibilities.Add(cModel, info.Visibility);
                }
            }

            return(result);
        }
        private void ProcessLayers(ApplicationValidationResultIQ validationResult, DictionaryQuery <CompositeModel, PublicCompositeTypeGenerationResult> loadingResults, DictionaryProxy <LayerModel, LayerImpl> layers, LayerModel layerModel)
        {
            if (!layers.CQ.ContainsKey(layerModel))
            {
                layers.Add(layerModel, new LayerImpl(validationResult, loadingResults, this, layerModel));
            }

            foreach (LayerModel used in layerModel.UsedLayerModels)
            {
                this.ProcessLayers(validationResult, loadingResults, layers, used);
            }
        }
Ejemplo n.º 3
0
        protected DictionaryQuery <Type, InstancePoolInfo <TInvocation> > CreatePoolDictionary <TTypeGen, TInvocation>(Type[] gArgs, IEnumerable <TTypeGen> typeGenResults, CollectionsFactory collectionsFactory)
            where TTypeGen : TypeGenerationResult
        {
            DictionaryProxy <Type, InstancePoolInfo <TInvocation> > result = collectionsFactory.NewDictionaryProxy <Type, InstancePoolInfo <TInvocation> >();

            foreach (var genResult in typeGenResults)
            {
                var genType = genResult.GeneratedType;
                if (gArgs != null)
                {
                    genType = genType.MakeGenericType(gArgs);
                }
                else if (genType.ContainsGenericParameters())
                {
                    throw new InternalException("Could not find generic arguments for " + genResult.DeclaredType + ".");
                }
                result.Add(genType, new InstancePoolInfoImpl <TInvocation>(new InstancePool <TInvocation>(), genType, genResult));
            }
            return(result.CQ);
        }
Ejemplo n.º 4
0
		public void ApplicationConfigurationSerializationRountripTest()
		{
			ApplicationConfiguration config = new ApplicationConfiguration();
			config.Name = "MyApplication";
			config.Description = "A test application for TDD HIE";

			{
				// Receive
				PortConfiguration port = new PortConfiguration();
				config.Ports.Add(port);

				EndpointConfiguration endpoint = new EndpointConfiguration();
				endpoint.TypeInfo = typeof (EndpointMock).GetTypeInfo().AssemblyQualifiedName;
				port.Endpoint = endpoint;

				PipelineComponentConfiguration encoder = new PipelineComponentConfiguration();
				encoder.TypeInfo = typeof (PipelineComponentMock).GetTypeInfo().AssemblyQualifiedName;
				port.Encoders.Add(encoder);

				PipelineComponentConfiguration assembler = new PipelineComponentConfiguration();
				assembler.TypeInfo = typeof (PipelineComponentMock).GetTypeInfo().AssemblyQualifiedName;
				port.Assemblers.Add(assembler);
			}

			{
				// Send
				EndpointConfiguration endpoint = new EndpointConfiguration();
				var typeInfo = typeof (EndpointMock).GetTypeInfo();
				endpoint.TypeInfo = typeInfo.AssemblyQualifiedName;
				PortConfiguration port = new PortConfiguration();
				port.Endpoint = endpoint;
				config.Ports.Add(port);
			}

			{
				ChannelConfiguration channel = new ChannelConfiguration();
				channel.Name = "Test channel";
				channel.Description = "A test channel";
				config.Channels.Add(channel);

				SourceConfiguration source = new SourceConfiguration();
				channel.Source = source;

				{
					FilterConfiguration filter = new FilterConfiguration();
					var typeInfo = typeof (DelegateFilter).GetTypeInfo();
					filter.TypeInfo = typeInfo.AssemblyQualifiedName;
					DictionaryProxy options = new DictionaryProxy(new Dictionary<string, string>());
					options.Add("property1", "value1&");
					options.Add("property2", "value2\n\nvalue2");
					options.Add("property3", "value3");
					filter.Options = options;
					source.Filters.Add(filter);
				}
				{
					TransformerConfiguration transformer = new TransformerConfiguration();
					var typeInfo = typeof (JavaScriptTransformer).GetTypeInfo();
					transformer.TypeInfo = typeInfo.AssemblyQualifiedName;
					DictionaryProxy options = new DictionaryProxy(new Dictionary<string, string>());
					options.Add("Script", "true");
					transformer.Options = options;

					source.Transformers.Add(transformer);
				}

				DestinationConfiguration destination = new DestinationConfiguration();
				channel.Destinations.Add(destination);
				{
					FilterConfiguration filter = new FilterConfiguration();
					var typeInfo = typeof (DelegateFilter).GetTypeInfo();
					filter.TypeInfo = typeInfo.AssemblyQualifiedName;
					destination.Filters.Add(filter);
				}
				{
					TransformerConfiguration transformer = new TransformerConfiguration();
					var typeInfo = typeof (DelegateTransformer).GetTypeInfo();
					transformer.TypeInfo = typeInfo.AssemblyQualifiedName;
					destination.Transformers.Add(transformer);
				}
			}

			config.Save("CreateConfigurationTest-output.xml");

			//NOTE: EXPORT XML SCHEMA
			config.SaveSchema("CreateConfigurationTest-output.xsd");

			// Read and assert

			ApplicationConfiguration resultConfig = ApplicationConfiguration.Load("CreateConfigurationTest-output.xml");

			Assert.IsNotNull(resultConfig);

			Assert.IsNotNull(resultConfig.Ports);
			Assert.AreEqual(2, resultConfig.Ports.Count());
			Assert.IsNotNull(resultConfig.Ports.First().Endpoint);
			Assert.IsNotNull(resultConfig.Ports.First().Encoders);
			Assert.AreEqual(1, resultConfig.Ports.First().Encoders.Count());
			Assert.IsNotNull(resultConfig.Ports.First().Assemblers);
			Assert.AreEqual(1, resultConfig.Ports.First().Assemblers.Count());

			Assert.IsNotNull(resultConfig.Channels);
			Assert.AreEqual(1, resultConfig.Channels.Count());

			Assert.IsNotNull(resultConfig.Channels.First().Destinations);
			Assert.AreEqual(1, resultConfig.Channels.First().Destinations.Count());
			Assert.IsNotNull(resultConfig.Channels.First().Destinations.First().Transformers);
			Assert.AreEqual(1, resultConfig.Channels.First().Destinations.First().Transformers.Count());
			Assert.IsNotNull(resultConfig.Channels.First().Destinations.First().Filters);
			Assert.AreEqual(1, resultConfig.Channels.First().Destinations.First().Filters.Count());

			Assert.IsNotNull(resultConfig.Channels.First().Source);
			Assert.IsNotNull(resultConfig.Channels.First().Source.Filters);
			Assert.AreEqual(1, resultConfig.Channels.First().Source.Filters.Count());
			Assert.IsNotNull(resultConfig.Channels.First().Source.Transformers);
			Assert.AreEqual(1, resultConfig.Channels.First().Source.Transformers.Count());

			// Options
			Assert.IsNotNull(resultConfig.Channels.First().Source.Filters.First().Options);
			Dictionary<string, string> deserializedProperties = resultConfig.Channels.First().Source.Filters.First().Options.ToDictionary();
			Assert.IsNotNull(deserializedProperties);
			Assert.AreEqual(3, deserializedProperties.Count());
			Assert.AreEqual("value1&", deserializedProperties["property1"]);

			deserializedProperties = resultConfig.Channels.First().Source.Transformers.First().Options.ToDictionary();
			Assert.IsNotNull(deserializedProperties);
			Assert.AreEqual(1, deserializedProperties.Count());
			Assert.AreEqual("true", deserializedProperties["Script"]);
		}