本文整理汇总了C#中ISerializationSurrogate类的典型用法代码示例。如果您正苦于以下问题:C# ISerializationSurrogate类的具体用法?C# ISerializationSurrogate怎么用?C# ISerializationSurrogate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISerializationSurrogate类属于命名空间,在下文中一共展示了ISerializationSurrogate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ObjectHolder
internal ObjectHolder(object obj, long objID, System.Runtime.Serialization.SerializationInfo info, ISerializationSurrogate surrogate, long idOfContainingObj, FieldInfo field, int[] arrayIndex)
{
this.m_object = obj;
this.m_id = objID;
this.m_flags = 0;
this.m_missingElementsRemaining = 0;
this.m_missingDecendents = 0;
this.m_dependentObjects = null;
this.m_next = null;
this.m_serInfo = info;
this.m_surrogate = surrogate;
this.m_markForFixupWhenAvailable = false;
if (obj is TypeLoadExceptionHolder)
{
this.m_typeLoad = (TypeLoadExceptionHolder) obj;
}
if ((idOfContainingObj != 0L) && (((field != null) && field.FieldType.IsValueType) || (arrayIndex != null)))
{
if (idOfContainingObj == objID)
{
throw new SerializationException(Environment.GetResourceString("Serialization_ParentChildIdentical"));
}
this.m_valueFixup = new ValueTypeFixupInfo(idOfContainingObj, field, arrayIndex);
}
this.SetFlags();
}
示例2: SurrogateForCyclicalReference
internal SurrogateForCyclicalReference(ISerializationSurrogate innerSurrogate)
{
if (innerSurrogate == null)
{
throw new ArgumentNullException("innerSurrogate");
}
this.innerSurrogate = innerSurrogate;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:SurrogateForCyclicalReference.cs
示例3: AddSurrogate
// Adds a surrogate to the list of surrogates checked.
/// <include file='doc\SurrogateSelector.uex' path='docs/doc[@for="SurrogateSelector.AddSurrogate"]/*' />
public virtual void AddSurrogate(Type type, StreamingContext context, ISerializationSurrogate surrogate) {
if (type==null) {
throw new ArgumentNullException("type");
}
if (surrogate==null) {
throw new ArgumentNullException("surrogate");
}
SurrogateKey key = new SurrogateKey(type, context);
m_surrogates.Add(key, surrogate); // Hashtable does duplicate checking.
}
示例4: AddSurrogate
/// <summary>
/// Adds a surrogate to the list of checked surrogates.
/// </summary>
/// <param name="type">The <see cref="T:System.Type"/> for which the surrogate is
/// required.</param>
/// <param name="context">The context-specific data.</param>
/// <param name="surrogate">The surrogate to call for this type.</param>
/// <exception cref="T:System.ArgumentNullException">The
/// <paramref name="type"/>or
/// <paramref name="surrogate"/>parameter is null.</exception>
/// <exception cref="T:System.ArgumentException">A surrogate already exists for this type
/// and context.</exception>
public virtual void AddSurrogate(Type type, StreamingContext context, ISerializationSurrogate surrogate) {
if (type == null || surrogate == null)
throw new ArgumentNullException("Null reference.");
if (_surrogates.ContainsKey(type)) {
throw new ArgumentException("A surrogate for " + type + " already exists.");
}
if (_surrogates.ContainsKey(type) == false) {
_surrogates[type] = new Dictionary<StreamingContextStates, ISerializationSurrogate>();
}
_surrogates[type][context.State] = surrogate;
}
示例5: AddSurrogate
// Methods
public virtual void AddSurrogate (Type type,
StreamingContext context, ISerializationSurrogate surrogate)
{
if (type == null || surrogate == null)
throw new ArgumentNullException ("Null reference.");
string currentKey = type.FullName + "#" + context.ToString ();
if (Surrogates.ContainsKey (currentKey))
throw new ArgumentException ("A surrogate for " + type.FullName + " already exists.");
Surrogates.Add (currentKey, surrogate);
}
示例6: DotNetSerializationSurrogateSurrogate
/// <summary>
/// Constructs a new <see cref="DotNetSerializationSurrogateSurrogate"/>.
/// </summary>
/// <param name="context"><see cref="FudgeContext"/> to use.</param>
/// <param name="typeData"><see cref="TypeData"/> for the type for this surrogate.</param>
/// <param name="surrogate">Surrogate that maps the object to or from a <see cref="SerializationInfo"/>.</param>
/// <param name="selector">Selector that produced the surrogate.</param>
public DotNetSerializationSurrogateSurrogate(FudgeContext context, TypeData typeData, ISerializationSurrogate surrogate, ISurrogateSelector selector)
{
if (context == null)
throw new ArgumentNullException("context");
if (typeData == null)
throw new ArgumentNullException("typeData");
if (surrogate == null)
throw new ArgumentNullException("surrogate");
// Don't care if selector is null
this.helper = new SerializationInfoMixin(context, typeData.Type, new BeforeAfterSerializationMixin(context, typeData));
this.surrogate = surrogate;
this.selector = selector;
}
示例7: AddSurrogate
public static void AddSurrogate(Type type,ISerializationSurrogate surrogate)
{
if(__surrogateSelector==null){
__surrogateSelector=new SurrogateSelector();
__streamingContext=new StreamingContext();
}
ISurrogateSelector surrogateExist=null;
__surrogateSelector.GetSurrogate (type, __streamingContext,out surrogateExist);
if(surrogateExist==null)
__surrogateSelector.AddSurrogate(type,__streamingContext, surrogate);
}
示例8: RegisterSurrogate
/// <summary>
/// Registers a surrogate for a given type, from a given recording version on.
/// </summary>
public void RegisterSurrogate(double version, Type targetType, ISerializationSurrogate surrogate)
{
#region Check preconditions
if (targetType == null) throw new ArgumentNullException("targetType");
if (surrogate == null) throw new ArgumentNullException("surrogate");
#endregion Check preconditions
// Check that no surrogate conflicts:
foreach (Registration reg in register)
{
if (reg.MatchesTypeAndVersion(targetType, version))
{
throw new InvalidOperationException("The SerializationSurrogate conflicts with an already registered surrogate for same version and target type.");
}
}
// Register surrogate:
register.Add(new Registration(version, targetType, surrogate));
}
示例9: UpdateData
internal void UpdateData(object obj, System.Runtime.Serialization.SerializationInfo info, ISerializationSurrogate surrogate, long idOfContainer, FieldInfo field, int[] arrayIndex, ObjectManager manager)
{
this.SetObjectValue(obj, manager);
this.m_serInfo = info;
this.m_surrogate = surrogate;
if ((idOfContainer != 0L) && (((field != null) && field.FieldType.IsValueType) || (arrayIndex != null)))
{
if (idOfContainer == this.m_id)
{
throw new SerializationException(Environment.GetResourceString("Serialization_ParentChildIdentical"));
}
this.m_valueFixup = new ValueTypeFixupInfo(idOfContainer, field, arrayIndex);
}
this.SetFlags();
if (this.RequiresValueTypeFixup)
{
this.UpdateDescendentDependencyChain(this.m_missingElementsRemaining, manager);
}
}
示例10: GetSurrogateForCyclicalReference
public static ISerializationSurrogate GetSurrogateForCyclicalReference(ISerializationSurrogate innerSurrogate)
{
if (innerSurrogate == null)
{
throw new ArgumentNullException(nameof(innerSurrogate));
}
return new SurrogateForCyclicalReference(innerSurrogate);
}
示例11: ObjectHolder
internal ObjectHolder(String obj, long objID, SerializationInfo info,
ISerializationSurrogate surrogate, long idOfContainingObj, FieldInfo field, int[] arrayIndex) {
BCLDebug.Assert(objID>=0,"objID>=0");
m_object=obj; //May be null;
m_id=objID;
m_flags=0;
m_missingElementsRemaining=0;
m_missingDecendents = 0;
m_dependentObjects=null;
m_next=null;
m_serInfo = info;
m_surrogate = surrogate;
m_markForFixupWhenAvailable = false;
if (idOfContainingObj!=0 && arrayIndex!=null) {
m_valueFixup = new ValueTypeFixupInfo(idOfContainingObj, field, arrayIndex);
}
if (m_valueFixup!=null) {
m_flags|=REQUIRES_VALUETYPE_FIXUP;
}
}
示例12: EnableCyclicalReferences
/// <summary>
/// Wraps an ISerializationSurrogate surrogate with special one to enable cyclical references during serialization
/// if hotfix http://support.microsoft.com/kb/931634, or later is installed. Wrapping the surrogate
/// should fix the "The object with ID X was referenced in a fixup but does not exist." error that occurs during
/// deserialization.
/// </summary>
public static ISerializationSurrogate EnableCyclicalReferences(ISerializationSurrogate surrogate)
{
// Look for the FormatterServices.GetSurrogateForCyclicalReference() method
// This method cannot be called directly because it may not exist in all environments and currently
// only exists on the Server-version of Windows.
foreach (MethodInfo method in typeof(FormatterServices).GetMethods(BindingFlags.Public | BindingFlags.Static))
{
if (method.Name == "GetSurrogateForCyclicalReference")
{
return (ISerializationSurrogate)method.Invoke(null, new object[] { surrogate });
}
}
return surrogate;
}
示例13: AddSurrogate
// Add a surrogate for a specific type.
public virtual void AddSurrogate(Type type, StreamingContext context,
ISerializationSurrogate surrogate)
{
if(type == null)
{
throw new ArgumentNullException("type");
}
if(surrogate == null)
{
throw new ArgumentNullException("surrogate");
}
table.Add(new KeyInfo(type, context), surrogate);
}
示例14: SurrogateDataContractCriticalHelper
internal SurrogateDataContractCriticalHelper(Type type, ISerializationSurrogate serializationSurrogate) : base(type)
{
string str;
string str2;
this.serializationSurrogate = serializationSurrogate;
DataContract.GetDefaultStableName(DataContract.GetClrTypeFullName(type), out str, out str2);
base.SetDataContractName(DataContract.CreateQualifiedName(str, str2));
}
示例15: SurrogateDataContract
internal SurrogateDataContract(Type type, ISerializationSurrogate serializationSurrogate) : base(new SurrogateDataContractCriticalHelper(type, serializationSurrogate))
{
this.helper = base.Helper as SurrogateDataContractCriticalHelper;
}