public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) { var facets = new List <IFacet>(); var namedFacet = specification.GetFacet <INamedFacet>(); if (namedFacet == null) { string inferredName = NameUtils.NaturalName(ShortName(type)); namedFacet = new NamedFacetInferred(inferredName, specification); facets.Add(namedFacet); Log.InfoFormat("No name facet found inferring name {0}", inferredName); } var pluralFacet = specification.GetFacet <IPluralFacet>(); if (pluralFacet == null) { string pluralName = NameUtils.PluralName(namedFacet.Value); pluralFacet = new PluralFacetInferred(pluralName, specification); facets.Add(pluralFacet); Log.InfoFormat("No plural facet found inferring name {0}", pluralName); } FacetUtils.AddFacets(facets); }
public void TestDisplayNameAnnotationOnPropertyMarksDuplicate() { PropertyInfo property = FindProperty(typeof(Customer16), "NumberOfOrders"); PropertyInfo property1 = FindProperty(typeof(Customer16), "NumberOfOrders1"); facetFactory.Process(Reflector, property, MethodRemover, Specification); facetFactory.Process(Reflector, property1, MethodRemover, facetHolder1); IFacet facet = Specification.GetFacet(typeof(INamedFacet)); Assert.IsNotNull(facet); Assert.IsTrue(facet is NamedFacetAbstract); var namedFacetAbstract = (NamedFacetAbstract)facet; Assert.AreEqual("some name", namedFacetAbstract.Value); AssertNoMethodsRemoved(); facet = facetHolder1.GetFacet(typeof(INamedFacet)); Assert.IsNotNull(facet); Assert.IsTrue(facet is NamedFacetAbstract); namedFacetAbstract = (NamedFacetAbstract)facet; Assert.AreEqual("some name", namedFacetAbstract.Value); AssertNoMethodsRemoved(); //Assert.Contains("Duplicate name: some name found on type: NakedObjects.Reflector.DotNet.Facets.Naming.Named.NamedAnnotationFacetFactoryTest+Customer16", NakedObjectsContext.InitialisationWarnings); }
public void TestDisplayNameAnnotationOnPropertyMarksDuplicate() { IImmutableDictionary <string, ITypeSpecBuilder> metamodel = new Dictionary <string, ITypeSpecBuilder>().ToImmutableDictionary(); var property = FindProperty(typeof(Customer16), "NumberOfOrders"); var property1 = FindProperty(typeof(Customer16), "NumberOfOrders1"); metamodel = facetFactory.Process(Reflector, property, MethodRemover, Specification, metamodel); Assert.IsNotNull(metamodel); metamodel = facetFactory.Process(Reflector, property1, MethodRemover, facetHolder1, metamodel); var facet = Specification.GetFacet(typeof(INamedFacet)); Assert.IsNotNull(facet); Assert.IsTrue(facet is NamedFacetAbstract); var namedFacetAbstract = (NamedFacetAbstract)facet; Assert.AreEqual("some name", namedFacetAbstract.Value); AssertNoMethodsRemoved(); Assert.IsNotNull(metamodel); facet = facetHolder1.GetFacet(typeof(INamedFacet)); Assert.IsNotNull(facet); Assert.IsTrue(facet is NamedFacetAbstract); namedFacetAbstract = (NamedFacetAbstract)facet; Assert.AreEqual("some name", namedFacetAbstract.Value); AssertNoMethodsRemoved(); }
public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) { var namedFacet = specification.GetFacet <INamedFacet>() ?? new NamedFacetInferred(type.Name, specification); IFacet pluralFacet = specification.GetFacet <IPluralFacet>() ?? new PluralFacetInferred(NameUtils.PluralName(namedFacet.NaturalName), specification); var facets = new[] { namedFacet, pluralFacet }; FacetUtils.AddFacets(facets); }
public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) { var facets = new List<IFacet>(); var namedFacet = specification.GetFacet<INamedFacet>(); if (namedFacet == null) { namedFacet = new NamedFacetInferred(type.Name, specification); facets.Add(namedFacet); } var pluralFacet = specification.GetFacet<IPluralFacet>(); if (pluralFacet == null) { string pluralName = NameUtils.PluralName(namedFacet.NaturalName); pluralFacet = new PluralFacetInferred(pluralName, specification); facets.Add(pluralFacet); } FacetUtils.AddFacets(facets); }
public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) { var facets = new List <IFacet>(); var namedFacet = specification.GetFacet <INamedFacet>(); if (namedFacet == null) { namedFacet = new NamedFacetInferred(type.Name, specification); facets.Add(namedFacet); } var pluralFacet = specification.GetFacet <IPluralFacet>(); if (pluralFacet == null) { string pluralName = NameUtils.PluralName(namedFacet.NaturalName); pluralFacet = new PluralFacetInferred(pluralName, specification); facets.Add(pluralFacet); } FacetUtils.AddFacets(facets); }
public void TestDisplayNameAnnotationOnPropertyMarksDuplicate() { var property = FindProperty(typeof(Customer16), "NumberOfOrders"); var property1 = FindProperty(typeof(Customer16), "NumberOfOrders1"); facetFactory.Process(Reflector, property, MethodRemover, Specification); facetFactory.Process(Reflector, property1, MethodRemover, facetHolder1); var facet = Specification.GetFacet(typeof(INamedFacet)); Assert.IsNotNull(facet); Assert.IsTrue(facet is NamedFacetAbstract); var namedFacetAbstract = (NamedFacetAbstract)facet; Assert.AreEqual("some name", namedFacetAbstract.Value); AssertNoMethodsRemoved(); facet = facetHolder1.GetFacet(typeof(INamedFacet)); Assert.IsNotNull(facet); Assert.IsTrue(facet is NamedFacetAbstract); namedFacetAbstract = (NamedFacetAbstract)facet; Assert.AreEqual("some name", namedFacetAbstract.Value); AssertNoMethodsRemoved(); }
public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel) { var facets = new List <IFacet>(); var namedFacet = specification.GetFacet <INamedFacet>(); if (namedFacet == null) { namedFacet = new NamedFacetInferred(type.Name, specification); facets.Add(namedFacet); } var pluralFacet = specification.GetFacet <IPluralFacet>(); if (pluralFacet == null) { string pluralName = NameUtils.PluralName(namedFacet.NaturalName); pluralFacet = new PluralFacetInferred(pluralName, specification); facets.Add(pluralFacet); } FacetUtils.AddFacets(facets); return(metamodel); }