public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder spec) {
     var attr = type.GetCustomAttribute<NakedObjectsTypeAttribute>();
     if (attr == null) {
         RemoveExplicitlyIgnoredMembers(type, methodRemover);
     } else {
         switch (attr.ReflectionScope) {
             case ReflectOver.All:
                 RemoveExplicitlyIgnoredMembers(type, methodRemover);
             break;
             case ReflectOver.TypeOnlyNoMembers:
                 foreach (MethodInfo method in type.GetMethods()) {
                     methodRemover.RemoveMethod(method);
                 }
                 break;
             case ReflectOver.ExplicitlyIncludedMembersOnly:
                 foreach (MethodInfo method in type.GetMethods()) {
                     if (method.GetCustomAttribute<NakedObjectsIncludeAttribute>() == null) {
                         methodRemover.RemoveMethod(method);
                     }
                 }
                 break;
             case ReflectOver.None:
                 throw new ReflectionException("Attempting to introspect a class that has been marked with NakedObjectsType with ReflectOver.None");
             default:
                 throw new ReflectionException(String.Format("Unhandled value for ReflectOver: {0}", attr.ReflectionScope));
         }
     }
 }
コード例 #2
0
        public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
            IFacet facet = null;

            if (!type.IsInterface && typeof (IViewModel).IsAssignableFrom(type)) {
                MethodInfo deriveMethod = type.GetMethod("DeriveKeys", new Type[] {});
                MethodInfo populateMethod = type.GetMethod("PopulateUsingKeys", new[] {typeof (string[])});

                var toRemove = new List<MethodInfo> {deriveMethod, populateMethod};

                if (typeof (IViewModelEdit).IsAssignableFrom(type)) {
                    facet = new ViewModelEditFacetConvention(specification);
                }
                else if (typeof (IViewModelSwitchable).IsAssignableFrom(type)) {
                    MethodInfo isEditViewMethod = type.GetMethod("IsEditView");
                    toRemove.Add(isEditViewMethod);
                    facet = new ViewModelSwitchableFacetConvention(specification);
                }
                else {
                    facet = new ViewModelFacetConvention(specification);
                }
                methodRemover.RemoveMethods(toRemove.ToArray());
            }

            FacetUtils.AddFacet(facet);
        }
コード例 #3
0
 public override bool Process(PropertyInfo property, IMethodRemover methodRemover, IFacetHolder holder) {
     if (CollectionUtils.IsCollectionButNotArray(property.PropertyType)) {
         holder.AddFacet(new CollectionResetFacet(property, holder));
         return true;
     }
     return base.Process(property, methodRemover, holder);
 }
コード例 #4
0
 public override bool Process(Type type, IMethodRemover methodRemover, IFacetHolder holder) {
     Attribute attribute = type.GetCustomAttributeByReflection<RegularExpressionAttribute>();
     if (attribute == null) {
         attribute = type.GetCustomAttributeByReflection<RegExAttribute>();
     }
     return FacetUtils.AddFacet(Create(attribute, holder));
 }
 public override void Process(IReflector reflector, MethodInfo method, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     if ((method.ReturnType.IsPrimitive || TypeUtils.IsEnum(method.ReturnType)) && method.GetCustomAttribute<OptionallyAttribute>() != null) {
         Log.Warn("Ignoring Optionally annotation on primitive parameter on " + method.ReflectedType + "." + method.Name);
         return;
     }
     Process(method, specification);
 }
コード例 #6
0
 public override bool Process(MethodInfo method, IMethodRemover methodRemover, IFacetHolder holder) {
     if ((method.ReturnType.IsPrimitive || TypeUtils.IsEnum(method.ReturnType)) && method.GetCustomAttribute<OptionallyAttribute>() != null) {
         Log.Warn("Ignoring Optionally annotation on primitive parameter on " + method.ReflectedType + "." + method.Name);
         return false;
     }
     return Process(method, holder);
 }
 public override void Process(IReflector reflector, PropertyInfo method, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     if (method.PropertyType.IsAssignableFrom(typeof(ContactType))) {
         FacetUtils.AddFacet(new NotNavigableFacet(specification));
     }
     if (method.PropertyType.IsAssignableFrom(typeof(AddressType))) {
         FacetUtils.AddFacet(new NotNavigableFacet(specification));
     }
     if (method.PropertyType.IsAssignableFrom(typeof(ContactType))) {
         FacetUtils.AddFacet(new NotNavigableFacet(specification));
     }
     if (method.PropertyType.IsAssignableFrom(typeof(Culture))) {
         FacetUtils.AddFacet(new NotNavigableFacet(specification));
     }
     if (method.PropertyType.IsAssignableFrom(typeof(SalesReason))) {
         FacetUtils.AddFacet(new NotNavigableFacet(specification));
     }
     if (method.PropertyType.IsAssignableFrom(typeof(UnitMeasure))) {
         FacetUtils.AddFacet(new NotNavigableFacet(specification));
     }
     if (method.PropertyType.IsAssignableFrom(typeof(ScrapReason))) {
         FacetUtils.AddFacet(new NotNavigableFacet(specification));
     }
     if (method.PropertyType.IsAssignableFrom(typeof(ProductSubcategory))) {
         FacetUtils.AddFacet(new NotNavigableFacet(specification));
     }
     if (method.PropertyType.IsAssignableFrom(typeof(ProductCategory))) {
         FacetUtils.AddFacet(new NotNavigableFacet(specification));
     }
 }
コード例 #8
0
 public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     if (typeof (IEnumerable).IsAssignableFrom(type) && !TypeUtils.IsSystem(type)) {
         MethodInfo method = FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.GetEnumeratorMethod, null, Type.EmptyTypes);
         if (method != null) {
             methodRemover.RemoveMethod(method);
         }
     }
 }
コード例 #9
0
 public override bool Process(Type type, IMethodRemover methodRemover, IFacetHolder holder) {
     return FacetUtils.AddFacets(
         new IFacet[] {
             new DescribedAsFacetNone(holder),  
             new ImmutableFacetNever(holder),
             new TitleFacetNone(holder),
         });
 }
コード例 #10
0
 public override void Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     if (CollectionUtils.IsCollectionButNotArray(property.PropertyType)) {
         specification.AddFacet(new CollectionResetFacet(property, specification));
     }
     else {
         base.Process(reflector, property, methodRemover, specification);
     }
 }
コード例 #11
0
 public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     FacetUtils.AddFacets(
         new IFacet[] {
             new DescribedAsFacetNone(specification),
             new ImmutableFacetNever(specification),
             new TitleFacetNone(specification)
         });
 }
コード例 #12
0
 public void ProcessSystemType(Type type, IMethodRemover methodRemover, IFacetHolder holder) {
     InitForType(type);
     foreach (MethodInfo method in typeToMethods[type]) {
         if (methodRemover != null && method != null) {
             methodRemover.RemoveMethod(method);
         }
     }
 }
 public override void Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     if ((property.PropertyType.IsPrimitive || TypeUtils.IsEnum(property.PropertyType)) && property.GetCustomAttribute<OptionallyAttribute>() != null) {
         Log.Warn("Ignoring Optionally annotation on primitive or un-readable parameter on " + property.ReflectedType + "." + property.Name);
         return;
     }
     if (property.GetGetMethod() != null && !property.PropertyType.IsPrimitive) {
         Process(property, specification);
     }
 }
コード例 #14
0
 public override bool Process(Type type, IMethodRemover methodRemover, IFacetHolder holder) {
     if (typeof (IEnumerable).IsAssignableFrom(type) && !TypeUtils.IsSystem(type)) {
         MethodInfo method = FindMethod(type, MethodType.Object, PrefixesAndRecognisedMethods.GetEnumeratorMethod, null, Type.EmptyTypes);
         if (method != null) {
             methodRemover.RemoveMethod(method);
         }
     }
     return false;
 }
 public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     if (IsDynamicProxyType(type)) {
         foreach (MethodInfo method in type.GetMethods().Join(MethodsToRemove, mi => mi.Name, s => s, (mi, s) => mi)) {
             if (methodRemover != null && method != null) {
                 methodRemover.RemoveMethod(method);
             }
         }
     }
 }
 public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     Type currentType = type;
     while (currentType != null) {
         if (TypeUtils.IsSystem(currentType)) {
             ProcessSystemType(currentType, methodRemover, specification);
         }
         currentType = currentType.BaseType;
     }
 }
コード例 #17
0
 public override bool Process(PropertyInfo property, IMethodRemover methodRemover, IFacetHolder holder) {
     if ((property.PropertyType.IsPrimitive || TypeUtils.IsEnum(property.PropertyType)) && property.GetCustomAttribute<OptionallyAttribute>() != null) {
         Log.Warn("Ignoring Optionally annotation on primitive or un-readable parameter on " + property.ReflectedType + "." + property.Name);
         return false;
     }
     if (property.GetGetMethod() != null && !property.PropertyType.IsPrimitive) {
         return Process(property, holder);
     }
     return false;
 }
コード例 #18
0
        private void FindAndRemoveEventHandlerMethods(Type type, IMethodRemover methodRemover) {
            foreach (EventInfo eInfo in type.GetEvents()) {
                RemoveMethod(methodRemover, eInfo.GetAddMethod());
                RemoveMethod(methodRemover, eInfo.GetRaiseMethod());
                RemoveMethod(methodRemover, eInfo.GetRemoveMethod());
                RemoveMethod(methodRemover, eInfo.GetAddMethod());

                eInfo.GetOtherMethods().ForEach(mi => RemoveMethod(methodRemover, mi));
            }
        }
コード例 #19
0
 public override bool Process(Type type, IMethodRemover methodRemover, IFacetHolder holder) {
     Type currentType = type;
     while (currentType != null) {
         if (TypeUtils.IsSystem(currentType)) {
             ProcessSystemType(currentType, methodRemover, holder);
         }
         currentType = currentType.BaseType;
     }
     return false;
 }
コード例 #20
0
        public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
            if (typeof (Enum).IsAssignableFrom(type)) {
                Type semanticsProviderType = typeof (EnumValueSemanticsProvider<>).MakeGenericType(type);
                var spec = reflector.LoadSpecification<IObjectSpecImmutable>(type);
                object semanticsProvider = Activator.CreateInstance(semanticsProviderType, spec, specification);

                MethodInfo method = typeof (ValueUsingValueSemanticsProviderFacetFactory).GetMethod("AddValueFacets", BindingFlags.Static | BindingFlags.Public).MakeGenericMethod(type);
                method.Invoke(null, new[] {semanticsProvider, specification});
            }
        }
        public override bool Process(PropertyInfo property, IMethodRemover methodRemover, IFacetHolder holder) {
            var classAttribute = property.DeclaringType.GetCustomAttributeByReflection<AuthorizePropertyAttribute>();
            var propertyAttribute = property.GetCustomAttribute<AuthorizePropertyAttribute>();

            if (classAttribute != null && propertyAttribute != null) {
                Log.WarnFormat("Class and property level AuthorizeAttributes applied to class {0} - ignoring attribute on property {1}", property.DeclaringType.FullName, property.Name);
            }

            return Create(classAttribute ?? propertyAttribute, holder);
        }
コード例 #22
0
 public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     MethodInfo method = FindMethod(reflector, type, MethodType.Class, RecognisedMethodsAndPrefixes.MenuMethod, null, null);
     if (method != null) {
         RemoveMethod(methodRemover, method);
         FacetUtils.AddFacet(new MenuFacetViaMethod(method, specification));
     }
     else {
         FacetUtils.AddFacet(new MenuFacetDefault(specification));
     }
 }
コード例 #23
0
        public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
            var facets = new List<IFacet> {
                new TypeIsAbstractFacet(specification, IsAbstract(type)),
                new TypeIsInterfaceFacet(specification, IsInterface(type)),
                new TypeIsSealedFacet(specification, IsSealed(type)),
                new TypeIsVoidFacet(specification, IsVoid(type))
            };

            FacetUtils.AddFacets(facets);
        }
        public override bool Process(MethodInfo method, IMethodRemover methodRemover, IFacetHolder holder) {
            var classAttribute = method.DeclaringType.GetCustomAttributeByReflection<AuthorizeActionAttribute>();
            var methodAttribute = method.GetCustomAttribute<AuthorizeActionAttribute>();

            if (classAttribute != null && methodAttribute != null) {
                Log.WarnFormat("Class and method level AuthorizeAttributes applied to class {0} - ignoring attribute on method {1}", method.DeclaringType.FullName, method.Name);
            }

            return Create(classAttribute ?? methodAttribute, holder);
        }
コード例 #25
0
        public override bool Process(Type type, IMethodRemover methodRemover, IFacetHolder facetHolder) {
            MethodInfo method = FindMethod(type, MethodType.Object, PrefixesAndRecognisedMethods.IconNameMethod, typeof (string), Type.EmptyTypes);
            var attribute = type.GetCustomAttributeByReflection<IconNameAttribute>();
            if (method != null) {
                RemoveMethod(methodRemover, method);
                return FacetUtils.AddFacet(new IconFacetViaMethod(method, facetHolder, attribute == null ? null : attribute.Value));
            }

            return FacetUtils.AddFacet(Create(attribute, facetHolder));
        }
コード例 #26
0
 public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     MethodInfo method = FindMethod(reflector, type, MethodType.Object, RecognisedMethodsAndPrefixes.IconNameMethod, typeof (string), Type.EmptyTypes);
     var attribute = type.GetCustomAttribute<IconNameAttribute>();
     if (method != null) {
         RemoveMethod(methodRemover, method);
         FacetUtils.AddFacet(new IconFacetViaMethod(method, specification, attribute == null ? null : attribute.Value));
     }
     else {
         FacetUtils.AddFacet(Create(attribute, specification));
     }
 }
コード例 #27
0
 public override bool Process(Type type, IMethodRemover methodRemover, IFacetHolder holder) {
     if (typeof (Enum).IsAssignableFrom(type)) {
         Type semanticsProviderType = typeof (EnumValueSemanticsProvider<>).MakeGenericType(type);
         object semanticsProvider = Activator.CreateInstance(semanticsProviderType, holder);
         Type facetType = typeof (ValueFacetUsingSemanticsProvider<>).MakeGenericType(type);
         var facet = (IFacet) Activator.CreateInstance(facetType, semanticsProvider, semanticsProvider);
         FacetUtils.AddFacet(facet);
         return true;
     }
     return false;
 }
コード例 #28
0
        /// <summary>
        ///     If no title or ToString can be used then will use Facets provided by
        ///     <see cref="FallbackFacetFactory" /> instead.
        /// </summary>
        public override bool Process(Type type, IMethodRemover methodRemover, IFacetHolder facetHolder) {
            IList<MethodInfo> attributedMethods = new List<MethodInfo>();
            foreach (PropertyInfo propertyInfo in type.GetProperties(BindingFlags.Public | BindingFlags.Instance)) {
                if (propertyInfo.GetCustomAttribute<TitleAttribute>() != null) {
                    if (attributedMethods.Count > 0) {
                        Log.Warn("Title annotation is used more than once in " + type.Name + ", this time on property " + propertyInfo.Name + "; this will be ignored");
                    }
                    attributedMethods.Add(propertyInfo.GetGetMethod());
                }
            }

            if (attributedMethods.Count > 0) {
                return FacetUtils.AddFacet(new TitleFacetViaProperty(attributedMethods.First(), facetHolder));
            }

            try {
                MethodInfo titleMethod = FindMethod(type, MethodType.Object, PrefixesAndRecognisedMethods.TitleMethod, typeof (string), Type.EmptyTypes);
                IFacet titleFacet = null;

                if (titleMethod != null) {
                    methodRemover.RemoveMethod(titleMethod);
                    titleFacet = new TitleFacetViaTitleMethod(titleMethod, facetHolder);
                }

                MethodInfo toStringMethod = FindMethod(type, MethodType.Object, PrefixesAndRecognisedMethods.ToStringMethod, typeof (string), Type.EmptyTypes);
                if (toStringMethod != null && !toStringMethod.DeclaringType.Equals(typeof (object))) {
                    methodRemover.RemoveMethod(toStringMethod);
                }
                else {
                    // on object do not use 
                    toStringMethod = null;
                }

                MethodInfo maskMethod = FindMethod(type, MethodType.Object, PrefixesAndRecognisedMethods.ToStringMethod, typeof (string), new[] {typeof (string)});

                if (maskMethod != null) {
                    methodRemover.RemoveMethod(maskMethod);
                }

                if (titleFacet == null && toStringMethod == null) {
                    // nothing to use 
                    return false;
                }

                if (titleFacet == null) {
                    titleFacet = new TitleFacetViaToStringMethod(toStringMethod, maskMethod, facetHolder);
                }

                return FacetUtils.AddFacet(titleFacet);
            }
            catch {
                return false;
            }
        }
コード例 #29
0
 public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     if (CollectionUtils.IsGenericEnumerable(type)) {
         ProcessGenericEnumerable(type, specification);
     }
     else if (type.IsArray) {
         ProcessArray(reflector, type, specification);
     }
     else if (CollectionUtils.IsCollectionButNotArray(type)) {
         ProcessCollection(reflector, specification);
     }
 }
コード例 #30
0
        public override bool Process(Type type, IMethodRemover methodRemover, IFacetHolder holder) {
            if (IsDynamicProxyType(type)) {
                foreach (MethodInfo method in type.GetMethods().Join(methodsToRemove, mi => mi.Name, s => s, (mi, s) => mi)) {
                    if (methodRemover != null && method != null) {
                        methodRemover.RemoveMethod(method);
                    }
                }
            }

            return false;
        }
 public override void Process(IReflector reflector, MethodInfo method, IMethodRemover methodRemover, ISpecificationBuilder specification)
 {
     Process(method, specification);
 }
コード例 #32
0
        public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            if (!typeof(Enum).IsAssignableFrom(type))
            {
                return(metamodel);
            }

            var semanticsProviderType = typeof(EnumValueSemanticsProvider <>).MakeGenericType(type);

            var(oSpec, mm) = reflector.LoadSpecification <IObjectSpecImmutable>(type, metamodel);
            var semanticsProvider = Activator.CreateInstance(semanticsProviderType, oSpec, specification);
            var method            = typeof(ValueUsingValueSemanticsProviderFacetFactory).GetMethod("AddValueFacets", BindingFlags.Static | BindingFlags.Public).MakeGenericMethod(type);

            method.Invoke(null, new[] { semanticsProvider, specification });
            return(mm);
        }
        public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            Attribute attribute = property.GetCustomAttribute <ConcurrencyCheckAttribute>();

            FacetUtils.AddFacet(Create(reflector, attribute, specification));
            return(metamodel);
        }
 public override void Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder specification)
 {
     Process(property, specification);
 }
コード例 #35
0
        public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            if (IsDynamicProxyType(type))
            {
                foreach (MethodInfo method in type.GetMethods().Join(MethodsToRemove, mi => mi.Name, s => s, (mi, s) => mi))
                {
                    if (methodRemover != null && method != null)
                    {
                        methodRemover.RemoveMethod(method);
                    }
                }
            }

            return(metamodel);
        }
コード例 #36
0
 public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
 {
     FacetUtils.AddFacets(
         new IFacet[] {
         new DescribedAsFacetNone(specification),
         new ImmutableFacetNever(specification),
         new TitleFacetNone(specification)
     });
     return(metamodel);
 }
        public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            if (UIntValueSemanticsProvider.IsAdaptedType(type))
            {
                var result = reflector.LoadSpecification(UIntValueSemanticsProvider.AdaptedType, metamodel);

                metamodel = result.Item2;
                var spec = result.Item1 as IObjectSpecImmutable;
                AddValueFacets(new UIntValueSemanticsProvider(spec, specification), specification);
            }
            return(metamodel);
        }
コード例 #38
0
        public override void Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification)
        {
            var attribute = type.GetCustomAttribute <MaskAttribute>();

            FacetUtils.AddFacet(Create(attribute, specification));
        }
コード例 #39
0
        public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            if (IsDynamicProxyType(property.DeclaringType) && property.Name.Equals("RelationshipManager", StringComparison.Ordinal))
            {
                FacetUtils.AddFacet(new HiddenFacet(WhenTo.Always, specification));
            }

            return(metamodel);
        }
        public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, Type type, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            if (!ColorValueSemanticsProvider.IsAdaptedType(type))
            {
                return(metamodel);
            }

            var(oSpec, mm) = reflector.LoadSpecification <IObjectSpecImmutable>(ColorValueSemanticsProvider.AdaptedType, metamodel);
            AddValueFacets(new ColorValueSemanticsProvider(oSpec, specification), specification);
            return(mm);
        }
 public override void Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder specification)
 {
     FacetUtils.AddFacet(Create(specification));
 }
コード例 #42
0
        public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder collection, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
        {
            var capitalizedName = property.Name;
            var type            = property.DeclaringType;

            var facets = new List <IFacet> {
                new PropertyAccessorFacet(property, collection)
            };

            AddSetFacet(facets, property, collection);

            AddHideForSessionFacetNone(facets, collection);
            AddDisableFacetAlways(facets, collection);
            FindDefaultHideMethod(reflector, facets, methodRemover, property.DeclaringType, MethodType.Object, "PropertyDefault", collection);
            FindAndRemoveHideMethod(reflector, facets, methodRemover, type, MethodType.Object, capitalizedName, collection);
            FacetUtils.AddFacets(facets);
            return(metamodel);
        }
コード例 #43
0
 public override IImmutableDictionary <string, ITypeSpecBuilder> Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder specification, IImmutableDictionary <string, ITypeSpecBuilder> metamodel)
 {
     Process(specification);
     return(metamodel);
 }
コード例 #44
0
        public override void Process(IReflector reflector, PropertyInfo property, IMethodRemover methodRemover, ISpecificationBuilder specification)
        {
            Attribute attribute = property.GetCustomAttribute <ConcurrencyCheckAttribute>();

            FacetUtils.AddFacet(Create(reflector, attribute, specification));
        }
コード例 #45
0
        public override void Process(IReflector reflector, Type type, IMethodRemover remover, ISpecificationBuilder specification)
        {
            var facets  = new List <IFacet>();
            var methods = new List <MethodInfo>();

            MethodInfo method = FindMethod(reflector, type, MethodType.Object, PrefixesAndRecognisedMethods.CreatedMethod, typeof(void), Type.EmptyTypes);

            if (method != null)
            {
                methods.Add(method);
                facets.Add(new CreatedCallbackFacetViaMethod(method, specification));
            }
            else
            {
                facets.Add(new CreatedCallbackFacetNull(specification));
            }

            method = FindMethod(reflector, type, MethodType.Object, PrefixesAndRecognisedMethods.PersistingMethod, typeof(void), Type.EmptyTypes);

            if (method != null)
            {
                methods.Add(method);
                facets.Add(new PersistingCallbackFacetViaMethod(method, specification));
            }
            else
            {
                facets.Add(new PersistingCallbackFacetNull(specification));
            }

            method = FindMethod(reflector, type, MethodType.Object, PrefixesAndRecognisedMethods.PersistedMethod, typeof(void), Type.EmptyTypes);

            if (method != null)
            {
                methods.Add(method);
                facets.Add(new PersistedCallbackFacetViaMethod(method, specification));
            }
            else
            {
                facets.Add(new PersistedCallbackFacetNull(specification));
            }

            method = FindMethod(reflector, type, MethodType.Object, PrefixesAndRecognisedMethods.UpdatingMethod, typeof(void), Type.EmptyTypes);
            if (method != null)
            {
                methods.Add(method);
                facets.Add(new UpdatingCallbackFacetViaMethod(method, specification));
            }
            else
            {
                facets.Add(new UpdatingCallbackFacetNull(specification));
            }

            method = FindMethod(reflector, type, MethodType.Object, PrefixesAndRecognisedMethods.UpdatedMethod, typeof(void), Type.EmptyTypes);
            if (method != null)
            {
                methods.Add(method);
                facets.Add(new UpdatedCallbackFacetViaMethod(method, specification));
            }
            else
            {
                facets.Add(new UpdatedCallbackFacetNull(specification));
            }

            method = FindMethod(reflector, type, MethodType.Object, PrefixesAndRecognisedMethods.LoadingMethod, typeof(void), Type.EmptyTypes);
            if (method != null)
            {
                methods.Add(method);
                facets.Add(new LoadingCallbackFacetViaMethod(method, specification));
            }
            else
            {
                facets.Add(new LoadingCallbackFacetNull(specification));
            }

            method = FindMethod(reflector, type, MethodType.Object, PrefixesAndRecognisedMethods.LoadedMethod, typeof(void), Type.EmptyTypes);
            if (method != null)
            {
                methods.Add(method);
                facets.Add(new LoadedCallbackFacetViaMethod(method, specification));
            }
            else
            {
                facets.Add(new LoadedCallbackFacetNull(specification));
            }

            method = FindMethod(reflector, type, MethodType.Object, PrefixesAndRecognisedMethods.DeletingMethod, typeof(void), Type.EmptyTypes);
            if (method != null)
            {
                methods.Add(method);
                facets.Add(new DeletingCallbackFacetViaMethod(method, specification));
            }
            else
            {
                facets.Add(new DeletingCallbackFacetNull(specification));
            }

            method = FindMethod(reflector, type, MethodType.Object, PrefixesAndRecognisedMethods.DeletedMethod, typeof(void), Type.EmptyTypes);
            if (method != null)
            {
                methods.Add(method);
                facets.Add(new DeletedCallbackFacetViaMethod(method, specification));
            }
            else
            {
                facets.Add(new DeletedCallbackFacetNull(specification));
            }

            method = FindMethod(reflector, type, MethodType.Object, PrefixesAndRecognisedMethods.OnUpdatingErrorMethod, typeof(string), new[] { typeof(Exception) });
            if (method != null)
            {
                methods.Add(method);
                facets.Add(new OnUpdatingErrorCallbackFacetViaMethod(method, specification));
            }
            else
            {
                facets.Add(new OnUpdatingErrorCallbackFacetNull(specification));
            }

            method = FindMethod(reflector, type, MethodType.Object, PrefixesAndRecognisedMethods.OnPersistingErrorMethod, typeof(string), new[] { typeof(Exception) });
            if (method != null)
            {
                methods.Add(method);
                facets.Add(new OnPersistingErrorCallbackFacetViaMethod(method, specification));
            }
            else
            {
                facets.Add(new OnPersistingErrorCallbackFacetNull(specification));
            }

            remover.RemoveMethods(methods);
            FacetUtils.AddFacets(facets);
        }