本文整理汇总了C#中HeaderHandler类的典型用法代码示例。如果您正苦于以下问题:C# HeaderHandler类的具体用法?C# HeaderHandler怎么用?C# HeaderHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HeaderHandler类属于命名空间,在下文中一共展示了HeaderHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
internal object Deserialize(HeaderHandler handler, BinaryParser serParser, bool fCheck)
{
if (serParser == null)
{
throw new ArgumentNullException(nameof(serParser));
}
_fullDeserialization = false;
TopObject = null;
_topId = 0;
_isSimpleAssembly = (_formatterEnums._assemblyFormat == FormatterAssemblyStyle.Simple);
_handler = handler;
if (_fullDeserialization)
{
// Reinitialize
_objectManager = new ObjectManager(_surrogates, _context, false, false);
_serObjectInfoInit = new SerObjectInfoInit();
}
// Will call back to ParseObject, ParseHeader for each object found
serParser.Run();
if (_fullDeserialization)
{
_objectManager.DoFixups();
}
if (TopObject == null)
{
throw new SerializationException(SR.Serialization_TopObject);
}
//if TopObject has a surrogate then the actual object may be changed during special fixup
//So refresh it using topID.
if (HasSurrogate(TopObject.GetType()) && _topId != 0)//Not yet resolved
{
TopObject = _objectManager.GetObject(_topId);
}
if (TopObject is IObjectReference)
{
TopObject = ((IObjectReference)TopObject).GetRealObject(_context);
}
if (_fullDeserialization)
{
_objectManager.RaiseDeserializationEvent(); // This will raise both IDeserialization and [OnDeserialized] events
}
// Return the headers if there is a handler
if (handler != null)
{
_handlerObject = handler(_headers);
}
return TopObject;
}
示例2: StateData
public StateData(HTTPMessage req, IPEndPoint d, object Tag, HeaderHandler HeaderCB)
{
this.Dest = d;
this.Request = req;
this.Tag = Tag;
this.HeaderCB = HeaderCB;
}
示例3: Deserialize
internal object Deserialize(Stream serializationStream, HeaderHandler handler, bool check)
{
if (serializationStream == null)
{
throw new ArgumentNullException(nameof(serializationStream));
}
if (serializationStream.CanSeek && (serializationStream.Length == 0))
{
throw new SerializationException(SR.Serialization_Stream);
}
var formatterEnums = new InternalFE()
{
_typeFormat = _typeFormat,
_serializerTypeEnum = InternalSerializerTypeE.Binary,
_assemblyFormat = _assemblyFormat,
_securityLevel = _securityLevel,
};
var reader = new ObjectReader(serializationStream, _surrogates, _context, formatterEnums, _binder)
{
_crossAppDomainArray = _crossAppDomainArray
};
var parser = new BinaryParser(serializationStream, reader);
return reader.Deserialize(handler, parser, check);
}
示例4: Deserialize
public object Deserialize(Stream serializationStream, HeaderHandler handler)
{
if (serializationStream == null)
{
throw new ArgumentNullException("serializationStream");
}
if (serializationStream.CanSeek && (serializationStream.Length == 0L))
{
throw new SerializationException(SoapUtil.GetResourceString("Serialization_Stream"));
}
InternalFE formatterEnums = new InternalFE {
FEtypeFormat = this.m_typeFormat,
FEtopObject = this.m_topObject,
FEserializerTypeEnum = InternalSerializerTypeE.Soap,
FEassemblyFormat = this.m_assemblyFormat,
FEsecurityLevel = this.m_securityLevel
};
ObjectReader objectReader = new ObjectReader(serializationStream, this.m_surrogates, this.m_context, formatterEnums, this.m_binder);
if ((this.soapParser == null) || (serializationStream != this.currentStream))
{
this.soapParser = new SoapParser(serializationStream);
this.currentStream = serializationStream;
}
this.soapParser.Init(objectReader);
return objectReader.Deserialize(handler, this.soapParser);
}
示例5: Deserialize
public object Deserialize(Stream serializationStream, HeaderHandler handler) {
object objReturn = null;
SoapReader soapReader = new SoapReader(_binder, _selector, _context);
CultureInfo savedCi = CultureInfo.CurrentCulture;
try {
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
objReturn = soapReader.Deserialize(serializationStream, _topObject);
}
finally {
Thread.CurrentThread.CurrentCulture = savedCi;
}
return objReturn;
}
示例6: Deserialize
public Object Deserialize(Stream serializationStream,
HeaderHandler handler)
{
// Validate the parameters.
if(serializationStream == null)
{
throw new ArgumentNullException("serializationStream");
}
// Wrap the stream in a binary reader.
using(BinaryReader reader =
new BinaryReader(serializationStream))
{
DeserializationContext context = new DeserializationContext(this, reader);
return BinaryValueReader.Deserialize(context);
}
}
示例7: Deserialize
internal object Deserialize(Stream serializationStream, HeaderHandler handler, bool fCheck, bool isCrossAppDomain, IMethodCallMessage methodCallMessage)
{
if (serializationStream == null)
{
throw new ArgumentNullException("serializationStream", Environment.GetResourceString("ArgumentNull_WithParamName", new object[] { serializationStream }));
}
if (serializationStream.CanSeek && (serializationStream.Length == 0L))
{
throw new SerializationException(Environment.GetResourceString("Serialization_Stream"));
}
InternalFE formatterEnums = new InternalFE {
FEtypeFormat = this.m_typeFormat,
FEserializerTypeEnum = InternalSerializerTypeE.Binary,
FEassemblyFormat = this.m_assemblyFormat,
FEsecurityLevel = this.m_securityLevel
};
ObjectReader objectReader = new ObjectReader(serializationStream, this.m_surrogates, this.m_context, formatterEnums, this.m_binder) {
crossAppDomainArray = this.m_crossAppDomainArray
};
return objectReader.Deserialize(handler, new __BinaryParser(serializationStream, objectReader), fCheck, isCrossAppDomain, methodCallMessage);
}
示例8: ReadMethodCall
public static object ReadMethodCall (BinaryReader reader, bool hasHeaders, HeaderHandler headerHandler, BinaryFormatter formatter)
{
BinaryElement elem = (BinaryElement)reader.ReadByte(); // The element code
return ReadMethodCall (elem, reader, hasHeaders, headerHandler, formatter);
}
示例9: ComponentSerializer
public ComponentSerializer()
{
this._formatter.Context = this._streamingCtx;
this._headerhandler = new HeaderHandler(this.TPHeaderHandler);
}
示例10: ParseHeader
void ParseHeader(string header, HeaderHandler handler)
{
if (handler == null)
throw new ArgumentNullException ("handler");
if (header == null) {
return;
} else if (header == "\r\n") {
handler (HeaderKind.BodyDelimiter, null, null);
return;
}
header = header.TrimEnd ('\r', '\n');
var colonOffset = header.IndexOf (':');
if (header.StartsWith ("HTTP/") && colonOffset < 0) {
handler (HeaderKind.Status, header, null);
return;
} else if (colonOffset > 0) {
handler (HeaderKind.KeyValue,
header.Substring (0, colonOffset).Trim (),
header.Substring (colonOffset + 1).Trim ()
);
}
}
示例11: Deserialize
// Deserialize the stream into an object graph.
internal Object Deserialize(HeaderHandler handler, __BinaryParser serParser, bool fCheck, IMethodCallMessage methodCallMessage)
{
SerTrace.Log( this, "Deserialize Entry handler", handler);
BCLDebug.Assert((IsCrossAppDomain() && (crossAppDomainArray != null))
|| (!IsCrossAppDomain()),
"[System.Runtime.Serialization.Formatters.BinaryObjectReader missing crossAppDomainArray]");
bFullDeserialization = false;
bMethodCall = false;
bMethodReturn = false;
bSimpleAssembly = (formatterEnums.FEassemblyFormat == FormatterAssemblyStyle.Simple);
if (serParser == null)
throw new ArgumentNullException("serParser", String.Format(Environment.GetResourceString("ArgumentNull_WithParamName"), serParser));
if (fCheck)
{
try{
CodeAccessPermission.DemandInternal(PermissionType.SecuritySerialization);
}catch(Exception e)
{
deserializationSecurityException = e;
}
}
this.handler = handler;
if (bFullDeserialization)
{
// Reinitialize
m_objectManager = new ObjectManager(m_surrogates, m_context, false);
serObjectInfoInit = new SerObjectInfoInit();
}
// Will call back to ParseObject, ParseHeader for each object found
serParser.Run();
SerTrace.Log( this, "Deserialize Finished Parsing DoFixups");
if (bFullDeserialization)
m_objectManager.DoFixups();
if (!bMethodCall && !bMethodReturn)
{
if (topObject == null)
throw new SerializationException(Environment.GetResourceString("Serialization_TopObject"));
if (topObject is IObjectReference)
{
topObject = ((IObjectReference)topObject).GetRealObject(m_context);
}
}
SerTrace.Log( this, "Deserialize Exit ",topObject);
if (bFullDeserialization)
m_objectManager.RaiseDeserializationEvent();
// Return the headers if there is a handler
if (handler != null)
{
handlerObject = handler(headers);
}
if (bMethodCall)
{
Object[] methodCallArray = topObject as Object[];
topObject = binaryMethodCall.ReadArray(methodCallArray, handlerObject);
}
else if (bMethodReturn)
{
Object[] methodReturnArray = topObject as Object[];
topObject = binaryMethodReturn.ReadArray(methodReturnArray, methodCallMessage, handlerObject);
}
return topObject;
}
示例12: Deserialize
// Deserialize the stream into an object graph.
internal Object Deserialize(Stream serializationStream, HeaderHandler handler, bool fCheck, bool isCrossAppDomain, IMethodCallMessage methodCallMessage) {
if (serializationStream==null)
{
throw new ArgumentNullException("serializationStream", String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentNull_WithParamName"),serializationStream));
}
if (serializationStream.CanSeek && (serializationStream.Length == 0))
throw new SerializationException(Environment.GetResourceString("Serialization_Stream"));
SerTrace.Log(this, "Deserialize Entry");
InternalFE formatterEnums = new InternalFE();
formatterEnums.FEtypeFormat = m_typeFormat;
formatterEnums.FEserializerTypeEnum = InternalSerializerTypeE.Binary;
formatterEnums.FEassemblyFormat = m_assemblyFormat;
formatterEnums.FEsecurityLevel = m_securityLevel;
ObjectReader sor = new ObjectReader(serializationStream, m_surrogates, m_context, formatterEnums, m_binder);
sor.crossAppDomainArray = m_crossAppDomainArray;
return sor.Deserialize(handler, new __BinaryParser(serializationStream, sor), fCheck, isCrossAppDomain, methodCallMessage);
}
示例13: UnsafeDeserializeMethodResponse
public Object UnsafeDeserializeMethodResponse(Stream serializationStream, HeaderHandler handler, IMethodCallMessage methodCallMessage) {
return Deserialize(serializationStream, handler, false, methodCallMessage);
}
示例14: Deserialize
internal object Deserialize(HeaderHandler handler, ISerParser serParser)
{
if (serParser == null)
{
throw new ArgumentNullException("serParser", string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("ArgumentNull_WithParamName"), new object[] { serParser }));
}
this.deserializationSecurityException = null;
try
{
serializationPermission.Demand();
}
catch (Exception exception)
{
this.deserializationSecurityException = exception;
}
this.handler = handler;
this.isTopObjectSecondPass = false;
this.isHeaderHandlerCalled = false;
if (handler != null)
{
this.IsFakeTopObject = true;
}
this.m_idGenerator = new ObjectIDGenerator();
this.m_objectManager = this.GetObjectManager();
this.serObjectInfoInit = new SerObjectInfoInit();
this.objectIdTable.Clear();
this.objectIds = 0L;
serParser.Run();
if (handler != null)
{
this.m_objectManager.DoFixups();
if (this.handlerObject == null)
{
this.handlerObject = handler(this.newheaders);
}
if ((this.soapFaultId > 0L) && (this.handlerObject != null))
{
this.topStack = new SerStack("Top ParseRecords");
ParseRecord record = new ParseRecord {
PRparseTypeEnum = InternalParseTypeE.Object,
PRobjectPositionEnum = InternalObjectPositionE.Top,
PRparseStateEnum = InternalParseStateE.Object,
PRname = "Response"
};
this.topStack.Push(record);
record = new ParseRecord {
PRparseTypeEnum = InternalParseTypeE.Member,
PRobjectPositionEnum = InternalObjectPositionE.Child,
PRmemberTypeEnum = InternalMemberTypeE.Field,
PRmemberValueEnum = InternalMemberValueE.Reference,
PRparseStateEnum = InternalParseStateE.Member,
PRname = "__fault",
PRidRef = this.soapFaultId
};
this.topStack.Push(record);
record = new ParseRecord {
PRparseTypeEnum = InternalParseTypeE.ObjectEnd,
PRobjectPositionEnum = InternalObjectPositionE.Top,
PRparseStateEnum = InternalParseStateE.Object,
PRname = "Response"
};
this.topStack.Push(record);
this.isTopObjectResolved = false;
}
}
if (!this.isTopObjectResolved)
{
this.isTopObjectSecondPass = true;
this.topStack.Reverse();
int num = this.topStack.Count();
ParseRecord pr = null;
for (int i = 0; i < num; i++)
{
pr = (ParseRecord) this.topStack.Pop();
this.Parse(pr);
}
}
this.m_objectManager.DoFixups();
if (this.topObject == null)
{
throw new SerializationException(SoapUtil.GetResourceString("Serialization_TopObject"));
}
if (this.HasSurrogate(this.topObject.GetType()) && (this.topId != 0L))
{
this.topObject = this.m_objectManager.GetObject(this.topId);
}
if (this.topObject is IObjectReference)
{
this.topObject = ((IObjectReference) this.topObject).GetRealObject(this.m_context);
}
this.m_objectManager.RaiseDeserializationEvent();
if ((this.formatterEnums.FEtopObject != null) && (this.topObject is InternalSoapMessage))
{
InternalSoapMessage topObject = (InternalSoapMessage) this.topObject;
ISoapMessage fEtopObject = this.formatterEnums.FEtopObject;
fEtopObject.MethodName = topObject.methodName;
fEtopObject.XmlNameSpace = topObject.xmlNameSpace;
fEtopObject.ParamNames = topObject.paramNames;
fEtopObject.ParamValues = topObject.paramValues;
fEtopObject.Headers = this.headers;
//.........这里部分代码省略.........
示例15: Deserialize
internal object Deserialize(HeaderHandler handler, __BinaryParser serParser, bool fCheck, bool isCrossAppDomain, IMethodCallMessage methodCallMessage)
{
if (serParser == null)
{
throw new ArgumentNullException("serParser", Environment.GetResourceString("ArgumentNull_WithParamName", new object[] { serParser }));
}
this.bFullDeserialization = false;
this.TopObject = null;
this.topId = 0L;
this.bMethodCall = false;
this.bMethodReturn = false;
this.bIsCrossAppDomain = isCrossAppDomain;
this.bSimpleAssembly = this.formatterEnums.FEassemblyFormat == FormatterAssemblyStyle.Simple;
if (fCheck)
{
CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
}
this.handler = handler;
if (this.bFullDeserialization)
{
this.m_objectManager = new ObjectManager(this.m_surrogates, this.m_context, false, this.bIsCrossAppDomain);
this.serObjectInfoInit = new SerObjectInfoInit();
}
serParser.Run();
if (this.bFullDeserialization)
{
this.m_objectManager.DoFixups();
}
if (!this.bMethodCall && !this.bMethodReturn)
{
if (this.TopObject == null)
{
throw new SerializationException(Environment.GetResourceString("Serialization_TopObject"));
}
if (this.HasSurrogate(this.TopObject.GetType()) && (this.topId != 0L))
{
this.TopObject = this.m_objectManager.GetObject(this.topId);
}
if (this.TopObject is IObjectReference)
{
this.TopObject = ((IObjectReference) this.TopObject).GetRealObject(this.m_context);
}
}
if (this.bFullDeserialization)
{
this.m_objectManager.RaiseDeserializationEvent();
}
if (handler != null)
{
this.handlerObject = handler(this.headers);
}
if (this.bMethodCall)
{
object[] topObject = this.TopObject as object[];
this.TopObject = this.binaryMethodCall.ReadArray(topObject, this.handlerObject);
}
else if (this.bMethodReturn)
{
object[] returnA = this.TopObject as object[];
this.TopObject = this.binaryMethodReturn.ReadArray(returnA, methodCallMessage, this.handlerObject);
}
return this.TopObject;
}