public void IdentifierMember_HoldsIdentifier() { var requestingClass = MixinConfiguration.ActiveConfiguration.GetContext(typeof(ClassOverridingMixinMembers)); MixinDefinition mixinDefinition = DefinitionObjectMother.GetTargetClassDefinition(requestingClass).Mixins[typeof(MixinWithAbstractMembers)]; Assert.That(mixinDefinition, Is.Not.Null); Type generatedType = CodeGenerationTypeMother.GetGeneratedMixinType(requestingClass, typeof(MixinWithAbstractMembers)); var identifier = generatedType.GetField("__identifier").GetValue(null); Assert.That(identifier, Is.EqualTo(mixinDefinition.GetConcreteMixinTypeIdentifier())); }
public IMixinInfo GetMixinInfo(IProxyTypeAssemblyContext context, MixinDefinition mixin) { ArgumentUtility.CheckNotNull("context", context); ArgumentUtility.CheckNotNull("mixin", mixin); if (!mixin.NeedsDerivedMixinType()) { return(new RegularMixinInfo(mixin.Type)); } var concreteMixinTypeIdentifier = mixin.GetConcreteMixinTypeIdentifier(); return(GetOrGenerateConcreteMixinType(context, concreteMixinTypeIdentifier)); }
private static ConcreteMixinType GetGeneratedMixinTypeAndMetadata(ClassContext requestingClass, Type mixinType) { MixinDefinition mixinDefinition = TargetClassDefinitionFactory .CreateAndValidate(requestingClass) .GetMixinByConfiguredType(mixinType); Assert.That(mixinDefinition, Is.Not.Null); var mixinTypeIdentifier = mixinDefinition.GetConcreteMixinTypeIdentifier(); var pipeline = SafeServiceLocator.Current.GetInstance <IPipelineRegistry>().DefaultPipeline; var generatedMixinType = pipeline.ReflectionService.GetAdditionalType(mixinTypeIdentifier); return(new AttributeBasedMetadataImporter().GetMetadataForMixinType(generatedMixinType)); }
public void MixinTypeAttribute_CanBeUsedToGetIdentifier() { var requestingClass = MixinConfiguration.ActiveConfiguration.GetContext(typeof(ClassOverridingMixinMembers)); MixinDefinition mixinDefinition = DefinitionObjectMother.GetTargetClassDefinition(requestingClass).Mixins[typeof(MixinWithAbstractMembers)]; Assert.That(mixinDefinition, Is.Not.Null); Type generatedType = CodeGenerationTypeMother.GetGeneratedMixinType(requestingClass, typeof(MixinWithAbstractMembers)); Assert.That(generatedType.IsDefined(typeof(ConcreteMixinTypeAttribute), false), Is.True); var attributes = (ConcreteMixinTypeAttribute[])generatedType.GetCustomAttributes(typeof(ConcreteMixinTypeAttribute), false); Assert.That(attributes[0].GetIdentifier(), Is.EqualTo(mixinDefinition.GetConcreteMixinTypeIdentifier())); }