亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? undoablebase.cs

?? C# 版本的一個三層商業(yè)架構(gòu)
?? CS
字號:
using System;
using System.Collections;
using System.Reflection;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace CSLA.Core
{
  /// <summary>
  /// Implements n-level undo capabilities.
  /// </summary>
  /// <remarks>
  /// You should not directly derive from this class. Your
  /// business classes should derive from 
  /// <see cref="CSLA.BusinessBase" />.
  /// </remarks>
  [Serializable()]
  abstract public class UndoableBase : CSLA.Core.BindableBase
  {
    // keep a stack of object state values
    [NotUndoable()]
    Stack _stateStack = new Stack();

    /// <summary>
    /// Returns the current edit level of the object.
    /// </summary>
    protected int EditLevel
    {
      get
      {
        return _stateStack.Count;
      }
    }

    /// <summary>
    /// Copies the state of the object and places the copy
    /// onto the state stack.
    /// </summary>
    protected internal void CopyState()
    {
      Type currentType = this.GetType();
      Hashtable state = new Hashtable();
      FieldInfo[] fields;
      string fieldName;

      do
      {
        // get the list of fields in this type
        fields = currentType.GetFields( 
          BindingFlags.NonPublic | 
          BindingFlags.Instance | 
          BindingFlags.Public);

        foreach(FieldInfo field in fields)
        {
          // make sure we process only our variables
          if(field.DeclaringType == currentType)
          {
            // see if this field is marked as not undoable
            if(!NotUndoableField(field))
            {
              // the field is undoable, so it needs to be processed
              object value = field.GetValue(this);

              if(field.FieldType.IsSubclassOf(typeof(BusinessCollectionBase)))
              {
                // make sure the variable has a value
                if(!(value == null))
                {
                  // this is a child collection, cascade the call
                  BusinessCollectionBase tmp = (BusinessCollectionBase)value;
                  tmp.CopyState();
                  Serialization.SerializationNotification.OnSerializing(tmp);
                }
              }
              else
              {
                if(field.FieldType.IsSubclassOf(typeof(BusinessBase)))
                {
                  // make sure the variable has a value
                  if(!(value == null))
                  {
                    // this is a child object, cascade the call
                    BusinessBase tmp = (BusinessBase)value;
                    tmp.CopyState();
                    Serialization.SerializationNotification.OnSerializing(tmp);
                  }
                }
                else
                {
                  // this is a normal field, simply trap the value
                  fieldName = field.DeclaringType.Name + "." + field.Name;
                  state.Add(fieldName, value);
                }
              }
            }
          }
        }
        currentType = currentType.BaseType;
      } while(currentType != typeof(UndoableBase));

      // tell child objects they're about to be serialized
      foreach(object child in state)
      {
        Serialization.SerializationNotification.OnSerializing(child);
      }

      // serialize the state and stack it
      MemoryStream buffer = new MemoryStream();
      BinaryFormatter formatter = new BinaryFormatter();
      formatter.Serialize(buffer, state);
      _stateStack.Push(buffer.ToArray());

      // tell child objects they've been serialized
      foreach(object child in state)
      {
        Serialization.SerializationNotification.OnSerialized(child);
      }

      currentType = this.GetType();
      do
      {
        // get the list of fields in this type
        fields = currentType.GetFields( 
          BindingFlags.NonPublic | 
          BindingFlags.Instance | 
          BindingFlags.Public);

        foreach(FieldInfo field in fields)
        {
          // make sure we process only our variables
          if(field.DeclaringType == currentType)
          {
            // see if this field is marked as not undoable
            if(!NotUndoableField(field))
            {
              // the field is undoable, so it needs to be processed
              object value = field.GetValue(this);

              if(field.FieldType.IsSubclassOf(typeof(BusinessCollectionBase)))
              {
                // make sure the variable has a value
                if(!(value == null))
                {
                  // this is a child collection, cascade the call
                  Serialization.SerializationNotification.OnSerialized(value);
                }
              }
              else
              {
                if(field.FieldType.IsSubclassOf(typeof(BusinessBase)))
                {
                  // make sure the variable has a value
                  if(!(value == null))
                  {
                    // this is a child object, cascade the call
                    Serialization.SerializationNotification.OnSerialized(value);
                  }
                }
              }
            }
          }
        }
        currentType = currentType.BaseType;
      } while(currentType != typeof(UndoableBase));
    }

    /// <summary>
    /// Restores the object's state to the most recently
    /// copied values from the state stack.
    /// </summary>
    /// <remarks>
    /// Restores the state of the object to its
    /// previous value by taking the data out of 
    /// the stack and restoring it into the fields
    /// of the object.
    /// </remarks>
    protected internal void UndoChanges()
    {
      // if we are a child object we might be asked to
      // undo below the level where we stacked states,
      // so just do nothing in that case
      if(EditLevel > 0)
      {
        MemoryStream buffer = new MemoryStream((byte[])_stateStack.Pop());
        buffer.Position = 0;
        BinaryFormatter formatter = new BinaryFormatter();
        Hashtable state = (Hashtable)(formatter.Deserialize(buffer));

        // tell child objects they've been deserialized
        foreach(object child in state)
        {
          Serialization.SerializationNotification.OnDeserialized(child);
        }

        Type currentType = this.GetType();
        FieldInfo[] fields;
        string fieldName;

        do
        {
          // get the list of fields in this type
          fields = currentType.GetFields( 
            BindingFlags.NonPublic | 
            BindingFlags.Instance | 
            BindingFlags.Public);

          foreach(FieldInfo field in fields)
          {
            if(field.DeclaringType == currentType)
            {
              // see if the field is undoable or not
              if(!NotUndoableField(field))
              {
                // the field is undoable, so restore its value
                object value = field.GetValue(this);

                if(field.FieldType.IsSubclassOf(typeof(BusinessCollectionBase)))
                {
                  // make sure the variable has a value
                  if(!(value == null))
                  {
                    // this is a child collection, cascade the call
                    BusinessCollectionBase tmp = (BusinessCollectionBase)value;
                    tmp.UndoChanges();
                    Serialization.SerializationNotification.OnDeserialized(tmp);
                  }
                }
                else
                {
                  if(field.FieldType.IsSubclassOf(typeof(BusinessBase)))
                  {
                    // make sure the variable has a value
                    if(!(value == null))
                    {
                      // this is a child object, cascade the call
                      BusinessBase tmp = (BusinessBase)value;
                      tmp.UndoChanges();
                      Serialization.SerializationNotification.OnDeserialized(tmp);
                    }
                  }
                  else
                  {
                    // this is a regular field, restore its value
                    fieldName = field.DeclaringType.Name + "." + field.Name;
                    field.SetValue(this, state[fieldName]);
                  }
                }
              }
            }
          }
          currentType = currentType.BaseType;
        } while(currentType != typeof(UndoableBase));
      }
    }

    /// <summary>
    /// Accepts any changes made to the object since the last
    /// state copy was made.
    /// </summary>
    /// <remarks>
    /// The most recent state copy is removed from the state
    /// stack and discarded, thus committing any changes made
    /// to the object's state.
    /// </remarks>
    protected internal void AcceptChanges()
    {
      if(EditLevel > 0)
      {
        _stateStack.Pop();

        Type currentType = this.GetType();
        FieldInfo[] fields;

        do
        {
          // get the list of fields in this type
          fields = currentType.GetFields( 
            BindingFlags.NonPublic | 
            BindingFlags.Instance | 
            BindingFlags.Public);

          foreach(FieldInfo field in fields)
          {
            if(field.DeclaringType == currentType)
            {
              // see if the field is undoable or not
              if(!NotUndoableField(field))
              {
                object value = field.GetValue(this);

                // the field is undoable so see if it is a collection
                if(field.FieldType.IsSubclassOf(typeof(BusinessCollectionBase)))
                {
                  // make sure the variable has a value
                  if(!(value == null))
                  {
                    // it is a collection so cascade the call
                    BusinessCollectionBase tmp = (BusinessCollectionBase)value;
                    tmp.AcceptChanges();
                  }
                }
                else
                {
                  if(field.FieldType.IsSubclassOf(typeof(BusinessBase)))
                  {
                    // make sure the variable has a value
                    if(!(value == null))
                    {
                      // it is a child object so cascade the call
                      BusinessBase tmp = (BusinessBase)value;
                      tmp.AcceptChanges();
                    }
                  }
                }
              }
            }
          }
          currentType = currentType.BaseType;
        } 
        while(currentType != typeof(UndoableBase));
      }
    }

    #region Helper Functions

    private bool NotUndoableField(FieldInfo field)
    {
      return Attribute.IsDefined(field, typeof(NotUndoableAttribute));
    }

    #endregion

  }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天天色图综合网| 日韩理论片网站| 精品一区二区免费| 欧美一区二区三区四区久久| 欧美bbbbb| 精品精品国产高清一毛片一天堂| 激情成人综合网| 久久精品视频在线免费观看| 成人小视频免费在线观看| ㊣最新国产の精品bt伙计久久| 色天使久久综合网天天| 亚洲一区二区三区四区在线观看| 色av综合在线| 日本伊人午夜精品| 久久久久久麻豆| 北岛玲一区二区三区四区| 成人免费小视频| 欧美日韩免费观看一区二区三区| 日本视频在线一区| 中文字幕乱码日本亚洲一区二区| 色综合久久久久久久久| 免费在线欧美视频| 国产亚洲成aⅴ人片在线观看 | 欧美极品另类videosde| www.亚洲精品| 婷婷开心激情综合| 欧美激情综合五月色丁香| 欧美午夜不卡视频| 国内国产精品久久| 亚洲精品成人悠悠色影视| 日韩女同互慰一区二区| 成人sese在线| 美国精品在线观看| 亚洲日本在线天堂| 欧美电影免费观看高清完整版在 | 久久精品人人做人人爽人人| 色噜噜狠狠色综合中国| 久久国产精品99精品国产| 成人欧美一区二区三区小说 | 欧美一级二级在线观看| 成人av网站在线| 日韩高清在线一区| 亚洲色大成网站www久久九九| 7777女厕盗摄久久久| av高清不卡在线| 国产在线国偷精品产拍免费yy| 亚洲卡通动漫在线| 国产清纯白嫩初高生在线观看91| 欧美精品久久一区二区三区| 成人av电影在线播放| 久久99精品国产91久久来源| 一区二区三区鲁丝不卡| 中文字幕乱码日本亚洲一区二区 | 久久国产尿小便嘘嘘| 亚洲综合在线电影| 中文字幕日本乱码精品影院| 久久久国际精品| 日韩欧美国产综合在线一区二区三区| 色婷婷香蕉在线一区二区| 国产一区二区三区免费播放| 欧美aⅴ一区二区三区视频| 一区二区三区自拍| 中文字幕在线一区| 久久精品人人爽人人爽| 日韩欧美视频在线| 91麻豆精品国产91久久久久| 欧美日韩国产影片| 欧美三级日韩三级国产三级| 色老头久久综合| 91在线观看地址| av资源网一区| av成人动漫在线观看| 国产成a人亚洲| 福利电影一区二区| 国产一区二区在线观看免费 | 亚洲国产精品影院| 亚洲小说春色综合另类电影| 亚洲午夜精品在线| 亚洲第一二三四区| 亚洲成人av电影| 日韩电影在线观看电影| 男男gaygay亚洲| 久久国产精品99久久人人澡| 韩国成人福利片在线播放| 国产精品一区二区久久不卡| 国产乱码精品一区二区三区五月婷| 国产麻豆视频一区二区| 国产一区二区主播在线| 国产不卡免费视频| av不卡在线播放| 欧洲亚洲国产日韩| 欧美日韩中字一区| 日韩欧美中文字幕一区| 精品国产91久久久久久久妲己 | 中文字幕av一区二区三区高| 国产精品嫩草影院com| 国产精品久久久久久久久免费丝袜| 亚洲欧洲日韩女同| 亚洲一二三区在线观看| 日本aⅴ精品一区二区三区| 激情综合网最新| 高清免费成人av| 色先锋aa成人| 欧美一区二区成人6969| 久久女同精品一区二区| 亚洲视频免费在线观看| 亚瑟在线精品视频| 国产精品一区专区| 色综合久久天天综合网| 日韩一区二区三区在线| 久久久久久久久久久久久夜| 亚洲欧美日韩久久| 三级不卡在线观看| 国产一区二区三区日韩| 99re成人在线| 91精品久久久久久久99蜜桃| 国产婷婷一区二区| 一个色综合网站| 久久99久久99| 一本色道久久综合精品竹菊| 日韩精品中文字幕一区| 亚洲三级在线观看| 九九**精品视频免费播放| 91在线视频播放| 日韩精品综合一本久道在线视频| 中文字幕乱码一区二区免费| 天天色 色综合| 国产jizzjizz一区二区| 欧美男生操女生| 国产精品家庭影院| 日韩av网站在线观看| 91在线观看免费视频| 2014亚洲片线观看视频免费| 亚洲午夜在线电影| 国产精品一卡二| 5月丁香婷婷综合| 亚洲欧洲日本在线| 精品在线亚洲视频| 欧美亚洲国产bt| 国产精品丝袜在线| 韩国精品在线观看| 在线综合+亚洲+欧美中文字幕| 亚洲欧美日韩国产综合| 国产成人精品影视| 日韩欧美一区二区免费| 亚洲成人综合视频| 91同城在线观看| 国产欧美一区在线| 国精产品一区一区三区mba视频| 欧美自拍偷拍午夜视频| 亚洲欧洲av一区二区三区久久| 久久精品久久综合| 在线播放日韩导航| 亚洲综合精品久久| 一本一道久久a久久精品| 中文在线资源观看网站视频免费不卡| 久久成人精品无人区| 91精品国产日韩91久久久久久| 亚洲影视在线播放| 91精品福利在线| 日韩美女视频一区| k8久久久一区二区三区| 欧美国产日本韩| 高清不卡一区二区| 中文字幕va一区二区三区| 国产suv精品一区二区6| 国产视频一区二区在线| 国产一区二区三区黄视频| 久久一二三国产| 国产中文字幕精品| wwwwxxxxx欧美| 国产成人午夜片在线观看高清观看| 日韩欧美亚洲国产另类| 精品一区二区成人精品| 欧美成人精品1314www| 久久电影网电视剧免费观看| 欧美xxxxx牲另类人与| 黄色成人免费在线| 久久久.com| 成人性视频网站| 中文字幕制服丝袜一区二区三区| 99精品桃花视频在线观看| 一区二区三区在线播放| 欧美日韩不卡视频| 久久精品国产亚洲高清剧情介绍| 欧美va亚洲va香蕉在线 | 成人av网站大全| 最新成人av在线| 欧美视频在线一区二区三区 | 99re这里都是精品| 亚洲国产日韩在线一区模特| 欧美久久久久免费| 激情偷乱视频一区二区三区| 国产欧美一区二区三区在线看蜜臀| 成人永久免费视频| 亚洲图片自拍偷拍| 日韩视频国产视频| 成人18精品视频| 亚洲高清中文字幕| 久久这里只精品最新地址|