public static void MapClrAttributesToDomResource(this IResourceType resourceType, DomReadWriteResource domResource, object clrResource, Func <string, string, bool> attributePredicate) { Contract.Requires(resourceType != null); Contract.Requires(domResource != null); if (clrResource == null) { return; } var serviceModel = domResource.GetServiceModel(); var domAttributes = domResource.CreateAndAddNode(() => DomAttributes.Create()); var apiType = resourceType.ResourceIdentityInfo.ApiType; var attributeInfoCollection = resourceType.AttributesInfo.Collection; foreach (var attributeInfo in attributeInfoCollection) { var apiField = attributeInfo.ApiPropertyName; if (attributePredicate != null && attributePredicate(apiType, apiField) == false) { // Skip adding this attribute. continue; } var localAttributeInfo = attributeInfo; domAttributes.CreateAndAddNode(() => DomAttribute.CreateFromClrResource(serviceModel, localAttributeInfo, clrResource)); } }
// PUBLIC METHODS /////////////////////////////////////////////////// #region Extensions Methods public static void MapClrTypeToDomResource(this IResourceType resourceType, DomReadWriteResource domResource) { Contract.Requires(resourceType != null); Contract.Requires(domResource != null); domResource.CreateAndAddNode(() => DomType.CreateFromResourceType(resourceType)); }
public static void MapClrIdToDomResource(this IResourceType resourceType, DomReadWriteResource domResource, object clrResource) { Contract.Requires(resourceType != null); Contract.Requires(domResource != null); if (clrResource == null) { return; } domResource.CreateAndAddNode(() => DomId.CreateFromClrResource(resourceType, clrResource)); }
public static void MapClrAttributesToDomResource(this IResourceType resourceType, DomReadWriteResource domResource, object clrResource) { Contract.Requires(resourceType != null); Contract.Requires(domResource != null); if (clrResource == null) { return; } var serviceModel = domResource.GetServiceModel(); var domAttributes = domResource.CreateAndAddNode(() => DomAttributes.Create()); var attributeInfoCollection = resourceType.AttributesInfo.Collection; foreach (var attributeInfo in attributeInfoCollection) { var localAttributeInfo = attributeInfo; domAttributes.CreateAndAddNode(() => DomAttribute.CreateFromClrResource(serviceModel, localAttributeInfo, clrResource)); } }