Можно было быть нацелены на конечную точку в настоящее время и Uri для нее путем выполнения:
OperationContext.Current.RequestContext.RequestMessage.Headers.To
то, которое я думаю, является тем же самым как:
OperationContext.Current.IncomingMessageHeaders.To
Это System.Uri
объект, и я полагаю, что можно просто добраться OriginalString
или PathAndQuery
, или безотносительно частей, которые Вы хотите от него.
Вы действительно соответствуете этому:
case task:Function0[Unit] => task()
Из-за стирания модуль не отображается во время выполнения. Если вам действительно не важен тип возвращаемого значения, вы можете сделать это в блоке реакции:
case task:Function0[_] => task()
This is complement to @Mitch Blevins's answer since his answer will get you through in this case.
See How do I get around type erasure on Scala? Or, why can’t I get the type parameter of my collections? You probably have to pass around a tuple of (Function0[T],Manifest[T])
to the actor. As you can see below, Scala is smart enough to deduce the type of T
even if you just write matchFunction(foo _)
.
scala> def foo = {Console.println("I am Foo")}
foo: Unit
scala> import scala.reflect.Manifest
import scala.reflect.Manifest
scala> def matchFunction[T](f: Function0[T])(implicit m : Manifest[T]) {
| (m,f) match {
| case (om: Manifest[_],of: Function0[_]) =>
| if(om <:< m) {
| of.asInstanceOf[Function0[T]]()
| }
| }
| }
matchFunction: [T](() => T)(implicit scala.reflect.Manifest[T])Unit
scala> matchFunction(foo _)
I am Foo