Force Types to Be the Same


hello,

i have following class:

    public treply send<treply>(query query) treply : reply, new() {          type type = typeof(iqueryhandler<,>).makegenerictype(query.gettype(), typeof(treply));        iqueryhandler handler = (iqueryhandler)objectfactory.getinstance(type);          try {          return (treply)handler.handle(query);        } catch (exception exception) {          ilogger logger = objectfactory.getinstance<ilogger>();          logger.error(loggername.plug, exception);          return new treply { exception = exception };        }        } // send

is possible throw exception if treply in send<treply> , (treply) in (treply)handler.handler(query) not of same type?

i know both implement reply ... mistake can this:

senduserverifysealreply reply = _dispatcher.send<senduserverifysealreply>(query);

but in handler return like:

return new senduserunlocksealreply();

both senduserverifysealreply , senduserunlocksealreply based on reply.

but when mistake happens throw exception.

is possible?

miguel

thank you

i'm not sure understand may wrong. if returned reference handler.handle cannot cast treply exception thrown think ask.


regards david r
---------------------------------------------------------------
great thing object oriented code can make small, simple problems large, complex ones.
object-oriented programming offers sustainable way write spaghetti code. - paul graham.
every program becomes rococo, , rubble. - alan perlis
valid measurement of code quality: wtfs/minute.



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'