public INakedObjectReflector CreateReflector() { var reflector = new DotNetReflector(); var facetDecoratorSet = new FacetDecoratorSet(); reflector.FacetDecorator = facetDecoratorSet; if (enhancements.Count == 0) { Log.Debug("No enhancements set up"); } else { AddEnhancement(facetDecoratorSet); } reflector.Init(); if (OptionalByDefault) { ((FacetFactorySetImpl) reflector.IntrospectionControlParameters.FacetFactorySet).ReplaceAndRegisterFactory(typeof (MandatoryDefaultFacetFactory), new OptionalDefaultFacetFactory()); } return reflector; }
private void AddEnhancement(FacetDecoratorSet facetDecoratorSet) { foreach (IReflectionDecoratorInstaller installer in enhancements.Where(x => x is IReflectionDecoratorInstaller)) { installer.CreateDecorators().ForEach(facetDecoratorSet.Add); } }
public override void Introspect(FacetDecoratorSet decorator) { // do nothing }
private static void DecorateAction(FacetDecoratorSet decorator, INakedObjectAction action) { decorator.DecorateAllHoldersFacets(action); foreach (INakedObjectActionParameter parm in action.Parameters) { decorator.DecorateAllHoldersFacets(parm); } if (action.ActionType == NakedObjectActionType.Set) { action.Actions.ForEach(a => DecorateAction(decorator, a)); } }
private void DecorateAllFacets(FacetDecoratorSet decorator) { decorator.DecorateAllHoldersFacets(this); foreach (INakedObjectAssociation field in fields) { decorator.DecorateAllHoldersFacets(field); } foreach (INakedObjectAction action in objectActions) { DecorateAction(decorator, action); } }
public override void Introspect(FacetDecoratorSet decorator) { if (introspector == null) { throw new ReflectionException("Introspection already taken place, cannot introspect again"); } introspector.IntrospectClass(); Type = introspector.IntrospectedType; fullName = introspector.FullName; shortName = introspector.ShortName; var namedFacet = GetFacet<INamedFacet>(); if (namedFacet == null) { namedFacet = new NamedFacetInferred(NameUtils.NaturalName(shortName), this); AddFacet(namedFacet); } var pluralFacet = GetFacet<IPluralFacet>(); if (pluralFacet == null) { pluralFacet = new PluralFacetInferred(NameUtils.PluralName(namedFacet.Value), this); AddFacet(pluralFacet); } whetherAbstract = introspector.IsAbstract; whetherInterface = introspector.IsInterface; whetherSealed = introspector.IsSealed; whetherVoid = introspector.IsVoid; string superclassName = introspector.SuperclassName; string[] interfaceNames = introspector.InterfacesNames; INakedObjectReflector reflector = NakedObjectsContext.Reflector; if (superclassName != null && !TypeUtils.IsSystem(superclassName)) { superClassSpecification = reflector.LoadSpecification(superclassName); if (superClassSpecification != null) { Log.DebugFormat("Superclass {0}", superclassName); superClassSpecification.AddSubclass(this); } } else if (Type != typeof (object)) { // always root in object (unless this is object!) superClassSpecification = reflector.LoadSpecification(typeof (object)); if (superClassSpecification != null) { Log.DebugFormat("Superclass {0}", typeof (object).Name); superClassSpecification.AddSubclass(this); } } var interfaceList = new List<INakedObjectSpecification>(); foreach (string interfaceName in interfaceNames) { INakedObjectSpecification interfaceSpec = reflector.LoadSpecification(interfaceName); interfaceSpec.AddSubclass(this); interfaceList.Add(interfaceSpec); } interfaces = interfaceList.ToArray(); introspector.IntrospectPropertiesAndCollections(); fields = OrderFields(introspector.Fields); validationMethods = introspector.IntrospectObjectValidationMethods(); introspector.IntrospectActions(); objectActions = OrderActions(introspector.ObjectActions); introspector = null; DecorateAllFacets(decorator); iconFacet = GetFacet<IIconFacet>(); }
public abstract void Introspect(FacetDecoratorSet decoratorSet);