• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ISerializationSurrogate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ISerializationSurrogate的典型用法代码示例。如果您正苦于以下问题:C# ISerializationSurrogate类的具体用法?C# ISerializationSurrogate怎么用?C# ISerializationSurrogate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ISerializationSurrogate类属于命名空间,在下文中一共展示了ISerializationSurrogate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:26,代码来源:ObjectHolder.cs


示例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.
     }
开发者ID:ArildF,项目名称:masters,代码行数:13,代码来源:surrogateselector.cs


示例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;
        }
开发者ID:Boxxxx,项目名称:clicker,代码行数:25,代码来源:DictionarySurrogateSelector.cs


示例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);
		}
开发者ID:jack-pappas,项目名称:mono,代码行数:14,代码来源:SurrogateSelector.cs


示例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;
        }
开发者ID:t0rx,项目名称:Fudge-CSharp,代码行数:21,代码来源:DotNetSeializationSurrogateSurrogate.cs


示例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);
        }
开发者ID:osmanzeki,项目名称:bmachine,代码行数:18,代码来源:SerializationUtility.cs


示例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));
		}
开发者ID:codetuner,项目名称:Arebis.Common,代码行数:21,代码来源:SurrogatesRegister.cs


示例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);
     }
 }
开发者ID:randomize,项目名称:VimConfig,代码行数:19,代码来源:ObjectHolder.cs


示例10: GetSurrogateForCyclicalReference

 public static ISerializationSurrogate GetSurrogateForCyclicalReference(ISerializationSurrogate innerSurrogate)
 {
     if (innerSurrogate == null)
     {
         throw new ArgumentNullException(nameof(innerSurrogate));
     }
     return new SurrogateForCyclicalReference(innerSurrogate);
 }
开发者ID:geoffkizer,项目名称:corefx,代码行数:8,代码来源:FormatterServices.cs


示例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;
            }
        }
开发者ID:ArildF,项目名称:masters,代码行数:25,代码来源:objectmanager.cs


示例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;
        }
开发者ID:vc3,项目名称:Amnesia,代码行数:21,代码来源:SerializationUtil.cs


示例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);
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:14,代码来源:SurrogateSelector.cs


示例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));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:SurrogateDataContract.cs


示例15: SurrogateDataContract

 internal SurrogateDataContract(Type type, ISerializationSurrogate serializationSurrogate) : base(new SurrogateDataContractCriticalHelper(type, serializationSurrogate))
 {
     this.helper = base.Helper as SurrogateDataContractCriticalHelper;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:4,代码来源:SurrogateDataContract.cs


示例16: AddSurrogate

 public virtual new void AddSurrogate(Type type, StreamingContext context, ISerializationSurrogate surrogate)
 {
 }
开发者ID:asvishnyakov,项目名称:CodeContracts,代码行数:3,代码来源:System.Runtime.Serialization.SurrogateSelector.cs


示例17: GetSurrogateForCyclicalReference

		public static ISerializationSurrogate GetSurrogateForCyclicalReference (ISerializationSurrogate innerSurrogate)
		{
			return innerSurrogate;
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:4,代码来源:FormatterServices.cs


示例18: AddFrameworkSurrogate

		/// <summary>
		/// Adds a surrogate to the framework surrogate selector.
		/// </summary>
		/// <param name="type">The <see cref="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>
		/// <remarks>
		/// Surrogates that are added in this way will be used by the piccolo framework for cloning
		/// operations.  For example, if several custom nodes reference a type that is not serializable,
		/// you might want to add a surrogate here for that type.  Alternatively, you could override
		/// <see cref="PNode.GetObjectData"/> in each custom node and specify how to serialize the type
		/// there. 
		/// </remarks>
		public static void AddFrameworkSurrogate(Type type, StreamingContext context, ISerializationSurrogate surrogate) {
			FrameworkSurrogateSelector.AddSurrogate(type, context, surrogate);
		}
开发者ID:malacandrian,项目名称:Piccolo.NET,代码行数:16,代码来源:PUtil.cs


示例19: UpdateData

        /*==================================UpdateData==================================
        **Action: Update the data in the object holder.  This should be called when the object
        **        is finally registered.  Presumably the ObjectHolder was created to track 
        **        some dependencies or preregistered fixups and we now need to actually record the
        **        object and other associated data.  We take this opportunity to set the flags
        **        so that we can do some faster processing in the future.
        **Returns: void
        **Arguments: obj -- The object being held by this object holder. (This should no longer be null).
        **           info --The SerializationInfo associated with this object, only required if we're doing delayed fixups.
        **           surrogate -- The surrogate handling this object.  May be null.
        **           idOfContainer -- The id of the object containing this one if this is a valuetype.
        **           member -- the MemberInfo of this object's position in it's container if this is a valuetype.
        **           manager -- the ObjectManager being used to track these ObjectHolders.
        **Exceptions: None. Asserts only.
        ==============================================================================*/
        internal virtual void UpdateData(Object obj, SerializationInfo info, ISerializationSurrogate surrogate, long idOfContainer, FieldInfo field, int[] arrayIndex, ObjectManager manager) {
            BCLDebug.Assert(obj!=null,"obj!=null");
            BCLDebug.Assert(m_id>0,"m_id>0");
    
            //Record the fields that we can.
            SetObjectValue(obj, manager);
            m_serInfo = info;
            m_surrogate = surrogate;

            if (idOfContainer!=0 && ((field!=null && field.FieldType.IsValueType) || arrayIndex!=null)) {
                if (idOfContainer == m_id) {
                    throw new SerializationException(Environment.GetResourceString("Serialization_ParentChildIdentical"));
                }
                m_valueFixup = new ValueTypeFixupInfo(idOfContainer, field, arrayIndex);
            }

            SetFlags();
            
            if (RequiresValueTypeFixup) {
                UpdateDescendentDependencyChain(m_missingElementsRemaining, manager);
            }
        }
开发者ID:ArildF,项目名称:masters,代码行数:37,代码来源:objectmanager.cs


示例20: SurrogateForCyclicalReference

 internal SurrogateForCyclicalReference(ISerializationSurrogate innerSurrogate)
 {
     Debug.Assert(innerSurrogate != null);
     _innerSurrogate = innerSurrogate;
 }
开发者ID:geoffkizer,项目名称:corefx,代码行数:5,代码来源:FormatterServices.cs



注:本文中的ISerializationSurrogate类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ISerialize类代码示例发布时间:2022-05-24
下一篇:
C# ISerializationContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap