//------------------------------------------------------------------------------------------------------------------------------------------------- #region Overrides of ImplementationConvention protected override void OnInspectDeclaration(ObjectFactoryContext context) { context.ClassFullName = ( context.TypeKey.PrimaryInterface.Namespace + "." + "ApiContractOf_" + context.TypeKey.PrimaryInterface.Name); }
//----------------------------------------------------------------------------------------------------------------------------------------------------- protected override void OnInspectDeclaration(ObjectFactoryContext context) { if ( ConfigurationSectionAttribute.From(context.TypeKey.PrimaryInterface) == null ) { throw new ContractConventionException(this, context.TypeKey.PrimaryInterface, "Missing ConfigurationSection attribute."); } context.BaseType = typeof(ConfigurationSectionBase); }
public void Apply_SameContextPropagated() { //-- Arrange var containedConventions = new[] { new TestConvention(shouldApply: true), new TestConvention(shouldApply: true) }; var context = new ObjectFactoryContext(factory: null, typeKey: new TypeKey()); //-- Act var composite = new CompositeConvention(containedConventions); composite.Apply(context); //-- Assert Assert.That(containedConventions[0].ApplyContext, Is.SameAs(context)); Assert.That(containedConventions[1].ApplyContext, Is.SameAs(context)); }
//------------------------------------------------------------------------------------------------------------------------------------------------- protected override bool ShouldApply(ObjectFactoryContext context) { return( context.TypeKey.PrimaryInterface != null && TypeMemberCache.Of(context.TypeKey.PrimaryInterface).ImplementableProperties.Any()); }
//------------------------------------------------------------------------------------------------------------------------------------------------- protected override void OnInspectDeclaration(ObjectFactoryContext context) { context.BaseType = m_BaseType; }
//------------------------------------------------------------------------------------------------------------------------------------------------- protected override void OnInspectDeclaration(ObjectFactoryContext context) { context.ClassFullName = m_ClassFullName; }
//------------------------------------------------------------------------------------------------------------------------------------------------- protected override void OnInspectDeclaration(ObjectFactoryContext context) { var modelTypeKey = (EdmModelTypeKey) context.TypeKey; context.ClassFullName = modelTypeKey.Model.GetGeneratedContextClassFullName(); }
//------------------------------------------------------------------------------------------------------------------------------------------------- public void Apply(ObjectFactoryContext context) { ApplyContext = context; WasApplied = true; }
//------------------------------------------------------------------------------------------------------------------------------------------------- #region IObjectFactoryConvention Members public bool ShouldApply(ObjectFactoryContext context) { ShouldApplyContext = context; return(m_ShouldApply); }
//------------------------------------------------------------------------------------------------------------------------------------------------- protected override void OnInspectDeclaration(ObjectFactoryContext context) { var entityKey = (EdmEntityTypeKey)context.TypeKey; context.ClassFullName = entityKey.EntityType.FullTypeName(); }