private static void AddCollectionOfComplexTypeAttributes(IServiceModel serviceModel, IAttributeInfo attributeInfo, DomAttribute domAttribute) { Contract.Requires(serviceModel != null); Contract.Requires(attributeInfo != null); Contract.Requires(domAttribute != null); var clrAttribute = domAttribute.ClrAttribute; if (clrAttribute == null) { return; } var clrCollectionItemType = attributeInfo.ClrCollectionItemType; var complexType = serviceModel.GetComplexType(clrCollectionItemType); var complexTypeAttributesInfo = complexType.AttributesInfo; var complexTypeAttributesInfoCollection = complexTypeAttributesInfo.Collection; var index = 0; var clrCollection = (IEnumerable <object>)clrAttribute; foreach (var clrCollectionItem in clrCollection.EmptyIfNull()) { // Add indexed complex object to index node. var localClrObject = clrCollectionItem; if (localClrObject == null) { continue; } // Add an index node. var domIndex = domAttribute.CreateAndAddNode(() => DomIndex.Create(index++)); // ReSharper disable once PossibleMultipleEnumeration foreach (var complexTypeAttributeInfo in complexTypeAttributesInfoCollection) { var localAttributeInfo = complexTypeAttributeInfo; domIndex.CreateAndAddNode(() => DomAttribute.CreateFromClrResource(serviceModel, localAttributeInfo, localClrObject)); } } }
private static void AddComplexTypeAttributes(IServiceModel serviceModel, IPropertyInfo attributeInfo, DomAttribute domAttribute) { Contract.Requires(serviceModel != null); Contract.Requires(attributeInfo != null); Contract.Requires(domAttribute != null); var clrPropertyType = attributeInfo.ClrPropertyType; var clrAttribute = domAttribute.ClrAttribute; if (clrAttribute == null) { return; } var complexType = serviceModel.GetComplexType(clrPropertyType); var complexTypeAttributesInfo = complexType.AttributesInfo; var complexTypeAttributesInfoCollection = complexTypeAttributesInfo.Collection; foreach (var complexTypeAttributeInfo in complexTypeAttributesInfoCollection) { var localAttributeInfo = complexTypeAttributeInfo; domAttribute.CreateAndAddNode(() => DomAttribute.CreateFromClrResource(serviceModel, localAttributeInfo, clrAttribute)); } }