Generic Extension Methods with Type Enum

Consider the following code: public static ErrorInfo GetErrorDetail(this ErrorInfo value) { //TODO: code here } Instead of repeating this code in multiple repositories, I want to move this to a common project and expose it as a nug...
more »

2017-01-11 10:01 (0) Answers

Generic NSPredicate

I'm trying to create a function which returns a NSPredicate. Currently I have: func predicate(value: String, op: String, predicate: String) -> [NSPredicate] { return [NSPredicate(format: "\(value) \(op) %@", predicate)] } func predicate(val...
more »

2017-01-11 09:01 (1) Answers

Calling Method on Generic Type Java 8

I have a function that accepts a parameter that has some generic type public < T extends SomeA > String foo(T t) {...} Now... SomeA contains a series of methods that can be called, like baz1(), baz2(), baz3(), etc... Now, here's the rub T...
more »

2017-01-10 21:01 (2) Answers

RxSwift extending Observable generic type issue

I'm having trouble writing some RxSwift utility function. I want to create a utility function maps multiple Observable<Bool> streams to a single Observable<Bool> stream, which checks if every source streams are true. It can be achieved by...
more »

2017-01-10 16:01 (1) Answers

How to solve generics error CS0311?

I have searched the web and stackoverflow and found many posts that deals with CS0311 error. None of the scenarios are close to mine. I have a generic class that inherits from a generic class. Please note that BusinessBase is a class in the CSLA fra...
more »

2017-01-10 15:01 (2) Answers

Ensure different types of generics

I am trying to create a generic converter interface, which will convert T objects to U objects by using the same method name, i.e. convert: public interface GenericConverter<T, U> { T convert(U fromObject); U convert(T fromObject); } Of ...
more »

2017-01-10 14:01 (3) Answers

Swift - Cannot specialize a non-generic definition

I have a function that is responsible for making the HTTP requests in the app. Basically, it sets up all the required headers, timeouts, etc... etc... Then, when the request is complete, I run 2 functions (provided by the developer): whenSuccess/when...
more »

2017-01-10 10:01 (1) Answers

Gson illegal type variable reference

I have a class defined as: public class Calls<T extends Object> Inside this class there is a method doRequest that creates a TypeToken (from for a Gson request. java.lang.reflect.Type type = new TypeToken<Handler...
more »

2017-01-09 19:01 (1) Answers

Multidimensional data type in Scala

I have a generic class, which is constructed from multi-dimensional data (i.e. n-dimensional Ararys or Vectors). In this case, I would like the class to be instantiated by one type only (e.g. Vector), aside from its dimensionality (Vector[Vector[T]] ...
more »

2017-01-09 17:01 (1) Answers

Using class method inside generic function

Situation: I want to write a generic function like the following: public <T> void do(T para){ para.something(); } Question: I want to give instances of two different classes to the do() function. Both classes are coming from an library, ...
more »

2017-01-09 14:01 (2) Answers