private void AssertMetadataItemDtoAreEqual(IMetadataItemDto expectedMetadataItemDto, IMetadataItemDto testedMetadataItemDto) { Assert.AreEqual(expectedMetadataItemDto.GetType(), testedMetadataItemDto.GetType()); if (expectedMetadataItemDto is RequiredMetadataItemDto) { Assert.AreEqual((expectedMetadataItemDto as RequiredMetadataItemDto).IsRequired, (testedMetadataItemDto as RequiredMetadataItemDto).IsRequired); } else if (expectedMetadataItemDto is ReadonlyMetadataItemDto) { Assert.AreEqual((expectedMetadataItemDto as ReadonlyMetadataItemDto).IsReadonly, (testedMetadataItemDto as ReadonlyMetadataItemDto).IsReadonly); } else if (expectedMetadataItemDto is HiddenMetadataItemDto) { Assert.AreEqual((expectedMetadataItemDto as HiddenMetadataItemDto).IsHidden, (testedMetadataItemDto as HiddenMetadataItemDto).IsHidden); } else if (expectedMetadataItemDto is DisplayNameMetadataItemDto) { Assert.AreEqual((expectedMetadataItemDto as DisplayNameMetadataItemDto).Name, (testedMetadataItemDto as DisplayNameMetadataItemDto).Name); } else { throw new NotSupportedException("Not supported yet."); } }
/// <summary> /// Gets the metadata item applicator. /// </summary> /// <param name="frameworkElement">The framework element.</param> /// <param name="metadataItem">The metadata item.</param> /// <returns>A <see cref="Rem.Ria.Infrastructure.View.Configuration.IMetadataItemApplicator"/></returns> public IMetadataItemApplicator GetMetadataItemApplicator(FrameworkElement frameworkElement, IMetadataItemDto metadataItem) { IMetadataItemApplicator metadataItemApplicator = null; var elementTypes = GetBaseTypes(frameworkElement.GetType()); foreach (var elementType in elementTypes) { var candidateElementType = elementType; var metadataItemApplicators = from applicator in _metadataItemApplicators where applicator.FrameworkElementType == candidateElementType && applicator.MetadataItemType == metadataItem.GetType() select applicator; metadataItemApplicator = metadataItemApplicators.SingleOrDefault(); if (metadataItemApplicator != null) { break; } } return(metadataItemApplicator); }
private void AssertMetadataItemDtoAreEqual(IMetadataItemDto expectedMetadataItemDto, IMetadataItemDto testedMetadataItemDto) { Assert.AreEqual(expectedMetadataItemDto.GetType(), testedMetadataItemDto.GetType()); if (expectedMetadataItemDto is RequiredMetadataItemDto) { Assert.AreEqual ( (expectedMetadataItemDto as RequiredMetadataItemDto).IsRequired, (testedMetadataItemDto as RequiredMetadataItemDto).IsRequired ); } else if (expectedMetadataItemDto is ReadonlyMetadataItemDto) { Assert.AreEqual((expectedMetadataItemDto as ReadonlyMetadataItemDto).IsReadonly, (testedMetadataItemDto as ReadonlyMetadataItemDto).IsReadonly); } else if (expectedMetadataItemDto is HiddenMetadataItemDto) { Assert.AreEqual((expectedMetadataItemDto as HiddenMetadataItemDto).IsHidden, (testedMetadataItemDto as HiddenMetadataItemDto).IsHidden); } else if (expectedMetadataItemDto is DisplayNameMetadataItemDto) { Assert.AreEqual((expectedMetadataItemDto as DisplayNameMetadataItemDto).Name, (testedMetadataItemDto as DisplayNameMetadataItemDto).Name); } else { throw new NotSupportedException ( "Not supported yet." ); } }
/// <summary> /// Gets the metadata item applicator. /// </summary> /// <param name="frameworkElement">The framework element.</param> /// <param name="metadataItem">The metadata item.</param> /// <returns>A <see cref="Rem.Ria.Infrastructure.View.Configuration.IMetadataItemApplicator"/></returns> public IMetadataItemApplicator GetMetadataItemApplicator( FrameworkElement frameworkElement, IMetadataItemDto metadataItem ) { IMetadataItemApplicator metadataItemApplicator = null; var elementTypes = GetBaseTypes ( frameworkElement.GetType () ); foreach ( var elementType in elementTypes ) { var candidateElementType = elementType; var metadataItemApplicators = from applicator in _metadataItemApplicators where applicator.FrameworkElementType == candidateElementType && applicator.MetadataItemType == metadataItem.GetType () select applicator; metadataItemApplicator = metadataItemApplicators.SingleOrDefault (); if ( metadataItemApplicator != null ) { break; } } return metadataItemApplicator; }