transparentpersistenceattribute.cs

来自「Perst开源实时数据库」· CS 代码 · 共 33 行

CS
33 行
字号
using System;
using Perst.Impl;
using System.Runtime.Remoting.Contexts;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Activation;
  

namespace Perst
{
    /// <summary>
    /// Attribute providing transparent persistency for context bound objects.
    /// It should be used for classes derived from PeristentContext class.
    /// Objects of these classes automatically on demand load their 
    /// content from the database and also automatically detect object modification.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public class TransparentPersistenceAttribute : ContextAttribute, IContributeObjectSink
    {
        public TransparentPersistenceAttribute() : base("PerstMOP")
        {
        }
   
        public override bool IsContextOK(Context ctx, IConstructionCallMessage ctor) 
        {
            return false;
        }
        public IMessageSink GetObjectSink(MarshalByRefObject target, IMessageSink next) 
        {
            return new PerstSink((PersistentContext)target, next);
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?