public static RestHandler Create(RestHandlerType type, object value) { return(new RestHandler() { Type = type, Value = value }); }
public void SetValue(object value, RestHandlerType type = RestHandlerType.Unknown) { if (type == RestHandlerType.Unknown) // Handler type is not given type = HandlerTypeFromInstance(value); if (type != RestHandlerType.Unknown) // If handler type given or just found. Value = value; }
public void SetValue(object value, RestHandlerType type = RestHandlerType.Unknown) { if (type == RestHandlerType.Unknown) // Handler type is not given { type = HandlerTypeFromInstance(value); } if (type != RestHandlerType.Unknown) // If handler type given or just found. { Value = value; } }
private RestHandlerType HandlerTypeFromInstance(object value) { RestHandlerType type = RestHandlerType.Unknown; if (value is Action <RestListenerContext> ) { type = RestHandlerType.HttpListenerContextAction; } else if (value is Func <RestListenerContext, Task> ) { type = RestHandlerType.HttpListenerContextTaskFunc; } else if (value is string) { type = RestHandlerType.String; } return(type); }
public static RestHandler Create(RestHandlerType type, object value) { return new RestHandler() { Type = type, Value = value }; }