本文整理汇总了C#中ISurrogateSelector.GetSurrogate方法的典型用法代码示例。如果您正苦于以下问题:C# ISurrogateSelector.GetSurrogate方法的具体用法?C# ISurrogateSelector.GetSurrogate怎么用?C# ISurrogateSelector.GetSurrogate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISurrogateSelector
的用法示例。
在下文中一共展示了ISurrogateSelector.GetSurrogate方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitSerialize
// Write Constructor used for array types or null members
internal void InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder)
{
_objectType = objectType;
_context = context;
_serObjectInfoInit = serObjectInfoInit;
if (objectType.IsArray)
{
InitNoMembers();
return;
}
InvokeSerializationBinder(binder);
ISurrogateSelector surrogateSelectorTemp = null;
if (surrogateSelector != null)
{
_serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp);
}
if (_serializationSurrogate != null)
{
// surrogate does not have this problem since user has pass in through the BF's ctor
_si = new SerializationInfo(objectType, converter);
_cache = new SerObjectInfoCache(objectType);
_isSi = true;
}
else if (!ReferenceEquals(objectType, Converter.s_typeofObject) && Converter.s_typeofISerializable.IsAssignableFrom(objectType))
{
_si = new SerializationInfo(objectType, converter);
_cache = new SerObjectInfoCache(objectType);
CheckTypeForwardedFrom(_cache, objectType, _binderAssemblyString);
_isSi = true;
}
if (!_isSi)
{
InitMemberInfo();
CheckTypeForwardedFrom(_cache, objectType, _binderAssemblyString);
}
}
示例2: InitReadConstructor
private void InitReadConstructor(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context)
{
if (objectType.IsArray)
{
InitNoMembers();
return;
}
ISurrogateSelector surrogateSelectorTemp = null;
if (surrogateSelector != null)
{
_serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp);
}
if (_serializationSurrogate != null)
{
_isSi = true;
}
else if (!ReferenceEquals(objectType, Converter.s_typeofObject) && Converter.s_typeofISerializable.IsAssignableFrom(objectType))
{
_isSi = true;
}
if (_isSi)
{
InitSiRead();
}
else
{
InitMemberInfo();
}
}
示例3: InitSerialize
// Write constructor
internal void InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
{
SerTrace.Log( this, objectInfoId," Constructor 1 ",obj);
this.context = context;
this.obj = obj;
this.serObjectInfoInit = serObjectInfoInit;
ISurrogateSelector surrogateSelectorTemp;
if (RemotingServices.IsTransparentProxy(obj))
objectType = Converter.typeofMarshalByRefObject;
else
objectType = obj.GetType();
if (objectType.IsArray)
{
isArray = true;
InitNoMembers();
return;
}
SerTrace.Log( this, objectInfoId," Constructor 1 trace 2");
objectWriter.ObjectManager.RegisterObject(obj);
if (surrogateSelector != null && (serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp)) != null)
{
SerTrace.Log( this, objectInfoId," Constructor 1 trace 3");
si = new SerializationInfo(objectType, converter);
if (!objectType.IsPrimitive)
serializationSurrogate.GetObjectData(obj, si, context);
InitSiWrite();
}
else if (obj is ISerializable)
{
if (!objectType.IsSerializable) {
throw new SerializationException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Serialization_NonSerType"),
objectType.FullName, objectType.Assembly.FullName));
}
si = new SerializationInfo(objectType, converter);
((ISerializable)obj).GetObjectData(si, context);
SerTrace.Log( this, objectInfoId," Constructor 1 trace 4 ISerializable "+objectType);
InitSiWrite();
}
else
{
SerTrace.Log(this, objectInfoId," Constructor 1 trace 5");
InitMemberInfo();
}
}
示例4: InitReadConstructor
[System.Security.SecurityCritical] // auto-generated
private void InitReadConstructor(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context)
{
SerTrace.Log( this,objectInfoId," ", objectType," InitReadConstructor Entry ",objectType);
if (objectType.IsArray)
{
InitNoMembers();
return;
}
ISurrogateSelector surrogateSelectorTemp = null;
if (surrogateSelector!=null)
serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp);
if (serializationSurrogate != null)
{
isSi = true;
}
else if (Object.ReferenceEquals(objectType, Converter.typeofObject))
{
}
else if (Converter.typeofISerializable.IsAssignableFrom(objectType))
isSi = true;
if (isSi)
{
InitSiRead();
}
else
{
InitMemberInfo();
}
SerTrace.Log( this,objectInfoId," ", objectType," InitReadConstructor Exit ",isSi);
}
示例5: InitSerialize
internal void InitSerialize(object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
{
this.context = context;
this.obj = obj;
this.serObjectInfoInit = serObjectInfoInit;
if (RemotingServices.IsTransparentProxy(obj))
{
this.objectType = Converter.typeofMarshalByRefObject;
}
else
{
this.objectType = obj.GetType();
}
if (this.objectType.IsArray)
{
this.isArray = true;
this.InitNoMembers();
}
else
{
ISurrogateSelector selector;
this.InvokeSerializationBinder(binder);
objectWriter.ObjectManager.RegisterObject(obj);
if ((surrogateSelector != null) && ((this.serializationSurrogate = surrogateSelector.GetSurrogate(this.objectType, context, out selector)) != null))
{
this.si = new SerializationInfo(this.objectType, converter);
if (!this.objectType.IsPrimitive)
{
this.serializationSurrogate.GetObjectData(obj, this.si, context);
}
this.InitSiWrite();
}
else if (obj is ISerializable)
{
if (!this.objectType.IsSerializable)
{
throw new SerializationException(Environment.GetResourceString("Serialization_NonSerType", new object[] { this.objectType.FullName, this.objectType.Assembly.FullName }));
}
this.si = new SerializationInfo(this.objectType, converter, !FormatterServices.UnsafeTypeForwardersIsEnabled());
((ISerializable) obj).GetObjectData(this.si, context);
this.InitSiWrite();
CheckTypeForwardedFrom(this.cache, this.objectType, this.binderAssemblyString);
}
else
{
this.InitMemberInfo();
CheckTypeForwardedFrom(this.cache, this.objectType, this.binderAssemblyString);
}
}
}
示例6: InitSerialize
internal void InitSerialize(object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo, ObjectWriter objectWriter)
{
this.context = context;
this.obj = obj;
this.serObjectInfoInit = serObjectInfoInit;
this.parentMemberAttributeInfo = attributeInfo;
this.surrogateSelector = surrogateSelector;
this.converter = converter;
if (RemotingServices.IsTransparentProxy(obj))
{
this.objectType = Converter.typeofMarshalByRefObject;
}
else
{
this.objectType = obj.GetType();
}
if (this.objectType.IsArray)
{
this.arrayElemObjectInfo = Serialize(this.objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
this.typeAttributeInfo = this.GetTypeAttributeInfo();
this.isArray = true;
this.InitNoMembers();
}
else
{
ISurrogateSelector selector;
this.typeAttributeInfo = this.GetTypeAttributeInfo();
objectWriter.ObjectManager.RegisterObject(obj);
if ((surrogateSelector != null) && ((this.serializationSurrogate = surrogateSelector.GetSurrogate(this.objectType, context, out selector)) != null))
{
this.si = new SerializationInfo(this.objectType, converter);
if (!this.objectType.IsPrimitive)
{
this.serializationSurrogate.GetObjectData(obj, this.si, context);
}
this.InitSiWrite(objectWriter);
}
else if (obj is ISerializable)
{
if (!this.objectType.IsSerializable)
{
throw new SerializationException(string.Format(CultureInfo.CurrentCulture, SoapUtil.GetResourceString("Serialization_NonSerType"), new object[] { this.objectType.FullName, this.objectType.Module.Assembly.FullName }));
}
this.si = new SerializationInfo(this.objectType, converter);
((ISerializable) obj).GetObjectData(this.si, context);
this.InitSiWrite(objectWriter);
}
else
{
this.InitMemberInfo();
}
}
}
示例7: InitSerialize
[System.Security.SecurityCritical] // auto-generated
internal void InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter, SerializationBinder binder)
{
SerTrace.Log( this, objectInfoId," Constructor 1 ",obj);
this.context = context;
this.obj = obj;
this.serObjectInfoInit = serObjectInfoInit;
ISurrogateSelector surrogateSelectorTemp;
#if FEATURE_REMOTING
if (RemotingServices.IsTransparentProxy(obj))
objectType = Converter.typeofMarshalByRefObject;
else
#endif
objectType = obj.GetType();
if (objectType.IsArray)
{
isArray = true;
InitNoMembers();
return;
}
InvokeSerializationBinder(binder);
SerTrace.Log( this, objectInfoId," Constructor 1 trace 2");
objectWriter.ObjectManager.RegisterObject(obj);
if (surrogateSelector != null && (serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp)) != null)
{
SerTrace.Log( this, objectInfoId," Constructor 1 trace 3");
si = new SerializationInfo(objectType, converter);
if (!objectType.IsPrimitive)
serializationSurrogate.GetObjectData(obj, si, context);
InitSiWrite();
}
else if (obj is ISerializable)
{
if (!objectType.IsSerializable) {
throw new SerializationException(Environment.GetResourceString("Serialization_NonSerType",
objectType.FullName, objectType.Assembly.FullName));
}
si = new SerializationInfo(objectType, converter, !FormatterServices.UnsafeTypeForwardersIsEnabled());
#if FEATURE_SERIALIZATION
((ISerializable)obj).GetObjectData(si, context);
#endif
SerTrace.Log( this, objectInfoId," Constructor 1 trace 4 ISerializable "+objectType);
InitSiWrite();
CheckTypeForwardedFrom(cache, objectType, binderAssemblyString);
}
else
{
SerTrace.Log(this, objectInfoId," Constructor 1 trace 5");
InitMemberInfo();
CheckTypeForwardedFrom(cache, objectType, binderAssemblyString);
}
}
示例8: InitReadConstructor
private void InitReadConstructor(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, string assemblyName)
{
if (objectType.IsArray)
{
this.arrayElemObjectInfo = Create(objectType.GetElementType(), surrogateSelector, context, this.objectManager, this.serObjectInfoInit, this.formatterConverter, assemblyName);
this.typeAttributeInfo = this.GetTypeAttributeInfo();
this.InitNoMembers();
}
else
{
ISurrogateSelector selector = null;
if (surrogateSelector != null)
{
this.serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out selector);
}
if (this.serializationSurrogate != null)
{
this.isSi = true;
}
else if (!(objectType == Converter.typeofObject) && Converter.typeofISerializable.IsAssignableFrom(objectType))
{
this.isSi = true;
}
if (this.isSi)
{
this.si = new SerializationInfo(objectType, this.formatterConverter);
this.InitSiRead(assemblyName);
}
else
{
this.InitMemberInfo();
}
}
}
示例9: getSerializationSurrogate
private ISerializationSurrogate getSerializationSurrogate(Type type, out ISurrogateSelector selector, ISurrogateSelector startingSelector)
{
System.Diagnostics.Debug.Assert(null != type, "The 'type' argument cannot be null.");
System.Diagnostics.Debug.Assert(null != startingSelector, "The 'startingSelector' argument cannot be null.");
ISerializationSurrogate serializationSurrogate =
startingSelector.GetSurrogate(type, this.context, out selector);
if (null == serializationSurrogate && typeof(ISerializable).IsAssignableFrom(type))
serializationSurrogate = startingSelector.GetSurrogate(typeof(ISerializable), this.context, out selector);
if (null == serializationSurrogate)
serializationSurrogate = startingSelector.GetSurrogate(typeof(object), this.context, out selector);
return serializationSurrogate;
}
示例10: InitReadConstructor
private void InitReadConstructor(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context)
{
if (objectType.IsArray)
{
this.InitNoMembers();
}
else
{
ISurrogateSelector selector = null;
if (surrogateSelector != null)
{
this.serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out selector);
}
if (this.serializationSurrogate != null)
{
this.isSi = true;
}
else if (!object.ReferenceEquals(objectType, Converter.typeofObject) && Converter.typeofISerializable.IsAssignableFrom(objectType))
{
this.isSi = true;
}
if (this.isSi)
{
this.InitSiRead();
}
else
{
this.InitMemberInfo();
}
}
}
示例11: GetSurrogate
private static ISerializationSurrogate GetSurrogate(Type type, ISurrogateSelector surrogateSelector, StreamingContext context)
{
ISurrogateSelector selector;
return surrogateSelector.GetSurrogate(type, context, out selector);
}
示例12: InitSerialize
// Write constructor
internal void InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SoapAttributeInfo attributeInfo)
{
InternalST.Soap( this, objectInfoId," Constructor 1 ",obj);
this.context = context;
this.obj = obj;
this.serObjectInfoInit = serObjectInfoInit;
this.parentMemberAttributeInfo = attributeInfo;
this.surrogateSelector = surrogateSelector;
this.converter = converter;
ISurrogateSelector surrogateSelectorTemp;
if (RemotingServices.IsTransparentProxy(obj))
objectType = Converter.typeofMarshalByRefObject;
else
objectType = obj.GetType();
if (objectType.IsArray)
{
arrayElemObjectInfo = Serialize(objectType.GetElementType(), surrogateSelector, context, serObjectInfoInit, converter, null);
typeAttributeInfo = GetTypeAttributeInfo();
isArray = true;
InitNoMembers();
return;
}
InternalST.Soap( this, objectInfoId," Constructor 1 trace 2");
typeAttributeInfo = GetTypeAttributeInfo();
if (surrogateSelector != null && (serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp)) != null)
{
InternalST.Soap( this, objectInfoId," Constructor 1 trace 3");
si = new SerializationInfo(objectType, converter);
if (!objectType.IsPrimitive)
serializationSurrogate.GetObjectData(obj, si, context);
InitSiWrite();
}
else if (obj is ISerializable)
{
if (!objectType.IsSerializable)
{
throw new SerializationException(String.Format(SoapUtil.GetResourceString("Serialization_NonSerType"),
objectType.FullName, objectType.Module.Assembly.FullName));
}
si = new SerializationInfo(objectType, converter);
((ISerializable)obj).GetObjectData(si, context);
InternalST.Soap( this, objectInfoId," Constructor 1 trace 4 ISerializable "+objectType);
InitSiWrite();
}
else
{
InternalST.Soap(this, objectInfoId," Constructor 1 trace 5");
InitMemberInfo();
}
}
示例13: CheckSerializable
public static void CheckSerializable (Type type, ISurrogateSelector selector, StreamingContext context)
{
if (!type.IsSerializable && !type.IsInterface)
{
if (selector != null && selector.GetSurrogate (type, context, out selector) != null)
return;
throw new SerializationException ("Type " + type + " is not marked as Serializable.");
}
}
示例14: InitReadConstructor
private void InitReadConstructor(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, String assemblyName)
{
InternalST.Soap( this,objectInfoId," ", objectType," InitReadConstructor Entry ",objectType);
if (objectType.IsArray)
{
arrayElemObjectInfo = Create(objectType.GetElementType(), surrogateSelector, context, objectManager, serObjectInfoInit, formatterConverter, assemblyName);
typeAttributeInfo = GetTypeAttributeInfo();
InitNoMembers();
return;
}
ISurrogateSelector surrogateSelectorTemp = null;
if (surrogateSelector!=null)
serializationSurrogate = surrogateSelector.GetSurrogate(objectType, context, out surrogateSelectorTemp);
if (serializationSurrogate != null)
{
isSi = true;
}
else if (objectType == Converter.typeofObject)
{
}
else if (Converter.typeofISerializable.IsAssignableFrom(objectType))
isSi = true;
if (isSi)
{
si = new SerializationInfo(objectType, formatterConverter);
InitSiRead(assemblyName);
}
else
{
InitMemberInfo();
}
InternalST.Soap( this,objectInfoId," ", objectType," InitReadConstructor Exit ",isSi);
}