internal static ITypeWriter getWriter(object obj, IProtocolFormatter formatter) { if (obj == null || obj is DBNull) { return(nullWriter); } Type objectType = obj.GetType(); ITypeWriter writer = formatter.getCachedWriter(objectType); if (writer == null) { // none of the interfaces matched a writer. // perform a lookup for the object class hierarchy writer = getWriter(objectType, formatter, true); if (writer == null) { if (typeof(IEnumerable).IsInstanceOfType(obj)) { writer = enumerableWriter; } else { if (logSer) { Log.log(LoggingConstants.SERIALIZATION, "cannot find a writer for the object, will use default writer - " + defaultWriter); } writer = defaultWriter; } } formatter.addCachedWriter(objectType, writer); } ITypeWriter referenceWriter = writer.getReferenceWriter(); if (referenceWriter != null) { // if the return object implements IHTTPSessionObject // keep it in the http session. The same object will be retrieved // on the subsequent invocations #if (FULL_BUILD) if (obj is IHttpSessionObject) { IHttpSessionObject httpSessionObject = (IHttpSessionObject)obj; string id = httpSessionObject.getID(); object objectInSession = httpSessionObject.getObject(); if (Log.isLogging(LoggingConstants.DEBUG)) { Log.log(LoggingConstants.DEBUG, "placing object into HTTP session. ID - " + id + " object " + obj); } //TODO: check for acuracy of Add method here HttpSessionState session = (HttpSessionState)ThreadContext.currentSession(); if (session != null) { session.Add(id, objectInSession); } } #endif formatter.setContextWriter(writer); writer = referenceWriter; } // if a writer is found, use it, otherwise use the default writer return(writer); }