コード例 #1
0
        private IEnumerable<Violation> VerifyNotSettingProperty(VerificationContext context, TypeNode typeNode)
        {
            var violatingMethods = from method in typeNode.InboundFrom<MethodNode, ContainedInLink>()
                                   where method.OutboundLinks.OfType<SetPropertyLink>().Any()
                                   select method;

            foreach (var method in violatingMethods)
            {
                yield return new ImmutableTypeSetsPropertyOutsideOfConstructorViolation(typeNode, method);
            }
        }
コード例 #2
0
        private IEnumerable<Violation> VerifyNoWritableFields(VerificationContext context, TypeNode typeNode)
        {
            var violatingFields = from field in typeNode.InboundFrom<FieldNode, ContainedInLink>()
                                  where !field.Field.IsInitOnly
                                  select field;

            foreach (var field in violatingFields)
            {
               yield return new ImmutableTypeHasWritableFieldViolation(typeNode, field);
            }
        }
コード例 #3
0
        private IEnumerable<Violation> VerifyNoNotPrivatePropertySetters(VerificationContext context, TypeNode typeNode)
        {
            var violatingProperties = from property in typeNode.InboundFrom<PropertyNode, ContainedInLink>()
                                      where property.Property.CanWrite && !property.Property.SetMethod.IsPrivate
                                      select property;

            foreach (var property in violatingProperties)
            {
                yield return new ImmutableTypeHasNonPrivateSetterViolation(typeNode, property);
            }
        }
 public ImmutableTypeSetsPropertyOutsideOfConstructorViolation(TypeNode violatingType, MethodNode violatingMethod)
 {
     this.Node = violatingType;
     this.ViolatingMethod = violatingMethod;
 }
コード例 #5
0
 public bool IsImmutableType(TypeNode node)
 {
     return node.Type.GetCustomAttribute<ImmutableAttribute>() != null;
 }
 public ImmutableTypeHasWritableFieldViolation(TypeNode violatingType, FieldNode violatingField)
 {
     this.Node = violatingType;
     this.ViolatingField = violatingField;
 }
        public ImmutableTypeHasNonPrivateSetterViolation(TypeNode violatingType, PropertyNode violatingProperty)
        {
            this.Node = violatingType;

            ViolatingProperty = violatingProperty;
        }
コード例 #8
0
 public bool IsQuery(TypeNode node)
 {
     return node.Type.GetInterfaces().Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IQuery<>));
 }
コード例 #9
0
 public bool IsCommand(TypeNode node)
 {
     return typeof (ICommand).IsAssignableFrom(node.Type);
 }
コード例 #10
0
 public bool ShouldInlineImplementationsFor(TypeNode interfaceNode)
 {
     return true;
 }
コード例 #11
0
 public bool IsEntity(TypeNode node)
 {
     return typeof(EntityBase).IsAssignableFrom(node.Type) && !typeof(IAggregate).IsAssignableFrom(node.Type);
 }