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 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));
            }
        }