示例#1
0
        public DataBlockWrapper(
            byte[] dataSource,
            int dataoffset,
            IDataBlock blocksource,
            Action <IDataBlock> writeCallback = null)
        {
            DataSource    = dataSource;
            DataOffset    = dataoffset;
            DataBlock     = blocksource;
            WriteCallback = writeCallback;

            if (blocksource is SeatDataBlock)
            {
                SeatDataBlock.NamesChanged += () =>
                {
                    EnumDataBlock block = blocksource as EnumDataBlock;
                    OnPropertyChanged("EnumData");
                    block.Enum.ForEach
                        (pair =>
                    {
                        if (_enumData.ContainsKey(pair.Key))
                        {
                            _enumData[pair.Key].Value = pair.Value;
                        }
                        else
                        {
                            _enumData.Add(pair.Key,
                                          new EnumValuePair
                            {
                                EnumName = block.EnumName,
                                Value    = pair.Value
                            });
                        }
                    });
                }
            }
            ;

            if (blocksource is EnumDataBlock)
            {
                EnumDataBlock block = blocksource as EnumDataBlock;
                _enumData = block.Enum.ToDictionary(pair => pair.Key,
                                                    pair => new EnumValuePair
                {
                    EnumName = block.EnumName,
                    Value    = pair.Value
                });
            }
        }
示例#2
0
        public void Dispose()
        {
            if (IsDisposed)
            {
                return;
            }
            IsDisposed = true;
            if (DataBlock is SeatDataBlock)
            {
                return;
            }
            EnumDataBlock enumBlock = DataBlock as EnumDataBlock;

            if (enumBlock != null)
            {
                _enumData.Clear();
                enumBlock.Enum.Clear();
            }
            //throw new NotImplementedException();
        }