// PUBLIC METHODS /////////////////////////////////////////////////// #region Factory Methods public static DomIndex Create <TIndex>(TIndex index) { var indexAsString = TypeConverter.Convert <string>(index); var domIndex = new DomIndex(indexAsString); return(domIndex); }
private static ApiObject CreateApiObjectFromDomIndex(DomIndex domIndex) { Contract.Requires(domIndex != null); var domAttributeCollection = domIndex.Nodes() .Cast <DomAttribute>() .ToList(); var apiObject = CreateApiObjectFromDomAttributeCollection(domAttributeCollection); return(apiObject); }
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)); } } }