public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel) { var method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.IconNameMethod, typeof(string), Type.EmptyTypes); var attribute = type.GetCustomAttribute <IconNameAttribute>(); methodRemover.SafeRemoveMethod(method); if (method is not null) { FacetUtils.AddFacet(new IconFacetViaMethod(method, specification, attribute?.Value, Logger <IconFacetViaMethod>())); } else { FacetUtils.AddFacet(Create(attribute, specification)); } return(metamodel); }
public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, Type type, IMethodRemover remover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel) { var facets = new List <IFacet>(); var methods = new List <MethodInfo>(); var method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.CreatedMethod, typeof(void), Type.EmptyTypes); if (method is not null) { methods.Add(method); facets.Add(new CreatedCallbackFacetViaMethod(method, specification)); } else { facets.Add(new CreatedCallbackFacetNull(specification)); } method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.PersistingMethod, typeof(void), Type.EmptyTypes); if (method is not null) { methods.Add(method); facets.Add(new PersistingCallbackFacetViaMethod(method, specification)); } else { facets.Add(new PersistingCallbackFacetNull(specification)); } method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.PersistedMethod, typeof(void), Type.EmptyTypes); if (method is not null) { methods.Add(method); facets.Add(new PersistedCallbackFacetViaMethod(method, specification)); } else { facets.Add(new PersistedCallbackFacetNull(specification)); } method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.UpdatingMethod, typeof(void), Type.EmptyTypes); if (method is not null) { methods.Add(method); facets.Add(new UpdatingCallbackFacetViaMethod(method, specification)); } else { facets.Add(new UpdatingCallbackFacetNull(specification)); } method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.UpdatedMethod, typeof(void), Type.EmptyTypes); if (method is not null) { methods.Add(method); facets.Add(new UpdatedCallbackFacetViaMethod(method, specification)); } else { facets.Add(new UpdatedCallbackFacetNull(specification)); } method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.LoadingMethod, typeof(void), Type.EmptyTypes); if (method is not null) { methods.Add(method); facets.Add(new LoadingCallbackFacetViaMethod(method, specification)); } else { facets.Add(new LoadingCallbackFacetNull(specification)); } method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.LoadedMethod, typeof(void), Type.EmptyTypes); if (method is not null) { methods.Add(method); facets.Add(new LoadedCallbackFacetViaMethod(method, specification)); } else { facets.Add(new LoadedCallbackFacetNull(specification)); } method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.DeletingMethod, typeof(void), Type.EmptyTypes); if (method is not null) { methods.Add(method); facets.Add(new DeletingCallbackFacetViaMethod(method, specification)); } else { facets.Add(new DeletingCallbackFacetNull(specification)); } method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.DeletedMethod, typeof(void), Type.EmptyTypes); if (method is not null) { methods.Add(method); facets.Add(new DeletedCallbackFacetViaMethod(method, specification)); } else { facets.Add(new DeletedCallbackFacetNull(specification)); } method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.OnUpdatingErrorMethod, typeof(string), new[] { typeof(Exception) }); if (method is not null) { methods.Add(method); facets.Add(new OnUpdatingErrorCallbackFacetViaMethod(method, specification, Logger <OnUpdatingErrorCallbackFacetViaMethod>())); } else { facets.Add(new OnUpdatingErrorCallbackFacetNull(specification)); } method = MethodHelpers.FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.OnPersistingErrorMethod, typeof(string), new[] { typeof(Exception) }); if (method is not null) { methods.Add(method); facets.Add(new OnPersistingErrorCallbackFacetViaMethod(method, specification, Logger <OnPersistingErrorCallbackFacetViaMethod>())); } else { facets.Add(new OnPersistingErrorCallbackFacetNull(specification)); } remover.RemoveMethods(methods); FacetUtils.AddFacets(facets); return(metamodel); }