using System; using System.Collections; using System.Runtime.InteropServices; namespace System.Runtime.Serialization { /// Assists formatters in selection of the serialization surrogate to delegate the serialization or deserialization process to. // Token: 0x02000499 RID: 1177 [ComVisible(true)] public class SurrogateSelector : ISurrogateSelector { /// Adds a surrogate to the list of checked surrogates. /// The for which the surrogate is required. /// The context-specific data. /// The surrogate to call for this type. /// The or parameter is null. /// A surrogate already exists for this type and context. // Token: 0x06002C8F RID: 11407 RVA: 0x00092980 File Offset: 0x00090B80 public virtual void AddSurrogate(Type type, StreamingContext context, ISerializationSurrogate surrogate) { if (type == null || surrogate == null) { throw new ArgumentNullException("Null reference."); } string text = type.FullName + "#" + context.ToString(); if (this.Surrogates.ContainsKey(text)) { throw new ArgumentException("A surrogate for " + type.FullName + " already exists."); } this.Surrogates.Add(text, surrogate); } /// Adds the specified that can handle a particular object type to the list of surrogates. /// The surrogate selector to add. /// The parameter is null. /// The selector is already on the list of selectors. /// The caller does not have the required permission. // Token: 0x06002C90 RID: 11408 RVA: 0x000929FC File Offset: 0x00090BFC public virtual void ChainSelector(ISurrogateSelector selector) { if (selector == null) { throw new ArgumentNullException("Selector is null."); } if (this.nextSelector != null) { selector.ChainSelector(this.nextSelector); } this.nextSelector = selector; } /// Returns the next selector on the chain of selectors. /// The next on the chain of selectors. /// The caller does not have the required permission. // Token: 0x06002C91 RID: 11409 RVA: 0x00092A30 File Offset: 0x00090C30 public virtual ISurrogateSelector GetNextSelector() { return this.nextSelector; } /// Returns the surrogate for a particular type. /// The surrogate for a particular type. /// The for which the surrogate is requested. /// The streaming context. /// The surrogate to use. /// The parameter is null. /// The caller does not have the required permission. /// /// /// // Token: 0x06002C92 RID: 11410 RVA: 0x00092A38 File Offset: 0x00090C38 public virtual ISerializationSurrogate GetSurrogate(Type type, StreamingContext context, out ISurrogateSelector selector) { if (type == null) { throw new ArgumentNullException("type is null."); } string text = type.FullName + "#" + context.ToString(); ISerializationSurrogate serializationSurrogate = (ISerializationSurrogate)this.Surrogates[text]; if (serializationSurrogate != null) { selector = this; return serializationSurrogate; } if (this.nextSelector != null) { return this.nextSelector.GetSurrogate(type, context, out selector); } selector = null; return null; } /// Removes the surrogate associated with a given type. /// The for which to remove the surrogate. /// The for the current surrogate. /// The parameter is null. // Token: 0x06002C93 RID: 11411 RVA: 0x00092AB0 File Offset: 0x00090CB0 public virtual void RemoveSurrogate(Type type, StreamingContext context) { if (type == null) { throw new ArgumentNullException("type is null."); } string text = type.FullName + "#" + context.ToString(); this.Surrogates.Remove(text); } // Token: 0x04001146 RID: 4422 private Hashtable Surrogates = new Hashtable(); // Token: 0x04001147 RID: 4423 private ISurrogateSelector nextSelector; } }