public LayerArchitecture GetOrCreateLayer(String name) { ArgumentValidator.ValidateNotNull("Layer name", name); LayerArchitectureImpl result = null; if (!this._allLayers.CQ.TryGetValue(name, out result)) { ListProxy <LayerArchitectureImpl> usageInfo = this.CollectionsFactory.NewListProxy <LayerArchitectureImpl>(); result = new LayerArchitectureImpl(this, this.UsesContainer.Query, this._compositeIDGenerator, this.ModelTypeSupport, name, layers => { foreach (var layer in layers) { if (!Object.ReferenceEquals(this, layer.Architecture)) { throw new ArgumentException("Given layer " + layer + " is not from this architecture."); } else { usageInfo.Add((LayerArchitectureImpl)layer); } } }); this._allLayers.Add(name, result); this._usageInfos.Add(result, usageInfo); } return(result); }
private Boolean NewGenericTypeBinding( CollectionsFactory collectionsFactory, CompositeModel compositeModel, Type memberType, Type memberTypeDeclaringType, ListProxy <ListProxy <AbstractGenericTypeBinding> > currentBindings, IDictionary <Type, TypeBindingInformationState> privateComposites ) { var result = !memberType.IsGenericType(); if (!result) { result = !memberType.IsGenericParameter; if (result) { // First, try to find from public types var pt = FindImplementingTypeFrom(memberTypeDeclaringType, compositeModel.PublicTypes); result = pt != null; ListProxy <AbstractGenericTypeBinding> list; if (result) { if (this.ProcessGenericTypeBindingFromPublicComposite(compositeModel, collectionsFactory, pt, memberType, out list)) { currentBindings.Add(list); } } else { result = !memberType.ContainsGenericParameters(); if (result) { result = this.ProcessGenericTypeBindingFromPublicComposite(compositeModel, collectionsFactory, Tuple.Create <Type, Type>(memberTypeDeclaringType, null), memberType, out list); if (result) { currentBindings.Add(list); } } else { // Otherwise, try to find from existing private composite bindings pt = FindImplementingTypeFrom(memberTypeDeclaringType, privateComposites.Keys); result = pt != null; if (result) { var eBindings = privateComposites[pt.Item2].Bindings.CQ; var array = eBindings.Select(b => { var success = this.ProcessGenericTypeBindingFromPrivateComposite(compositeModel, collectionsFactory, pt.Item1, memberType, b.CQ, out list); return(Tuple.Create(success, list)); }).ToArray(); if (array.Count(tuple => tuple.Item1) == eBindings.Count) { currentBindings.AddRange(array.Select(tuple => tuple.Item2)); } } } } } } return(result); }