Generic constraints, where T : struct and where T : class

Constraints are not part of the signature, but parameters are. And constraints in parameters are enforced during overload resolution. So let’s put the constraint in a parameter. It’s ugly, but it works. class RequireStruct<T> where T : struct { } class RequireClass<T> where T : class { } static void Foo<T>(T a, RequireStruct<T> ignore = … Read more

Can there be constraints with the same name in a DB?

No – a constraint is a database object as well, and thus its name needs to be unique. Try adding e.g. the table name to your constraint, that way it’ll be unique. CREATE TABLE BankAccount ( BankAccountID INT PRIMARY KEY, EmployerCode VARCHAR(20) NOT NULL, Amount MONEY NOT NULL, CONSTRAINT FK_BankAccount_Employer FOREIGN KEY (EmployerCode) REFERENCES Employer … Read more

Auto Layout (Constraints) Center 2 side by side views in a parent view

Is this what you’re after? I did it by adding a view (named viewCenteredInLeftSection) within your leftSection, then adding the clock image and label as subviews with these constraints: Make viewCenteredInLeftSection‘s CenterX and CenterY equal to its superview’s (leftSection). Make clockImage‘s Top, Bottom, and Leading edges equal to its superview’s (viewCenteredInLeftSection). Make label‘s Trailing edge … Read more

Difference between NSLayoutAttributeLeft vs NSLayoutAttributeLeading

“Leading” does not always mean “Left”. For RTL-written languages (locales) leading edge of the object’s alignment rectangle will be located at the right side of the object. Quote from Auto Layout Guide: The attributes leading and trailing are the same as left and right for left-to-right languages such as English, but in a right-to-left environment … Read more

Annotations from javax.validation.constraints not working

For JSR-303 bean validation to work in Spring, you need several things: MVC namespace configuration for annotations: <mvc:annotation-driven /> The JSR-303 spec JAR: validation-api-1.0.0.GA.jar (looks like you already have that) An implementation of the spec, such as Hibernate Validation, which appears to be the most commonly used example: hibernate-validator-4.1.0.Final.jar In the bean to be validated, … Read more