当前位置: 首页>>代码示例>>C#>>正文


C# PType.ToPObject方法代码示例

本文整理汇总了C#中PType.ToPObject方法的典型用法代码示例。如果您正苦于以下问题:C# PType.ToPObject方法的具体用法?C# PType.ToPObject怎么用?C# PType.ToPObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PType的用法示例。


在下文中一共展示了PType.ToPObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PCell

        private PType typ; // 32L

        #endregion Fields

        #region Constructors

        public PCell(PType typ, bool isFixed, string filePath, bool readOnly)
        {
            FilePath = filePath;
            this.isFixed = isFixed;
            this.readOnly = readOnly;
            this.typ = typ;
            var obj_typ = typ.ToPObject(4);
            if (!File.Exists(filePath))
            {
                if (readOnly) throw new Exception("Can't create file in ReadOnly mode");
                this.filestream = new FileStream(filePath, FileMode.OpenOrCreate,
                    readOnly ? FileAccess.Read : FileAccess.ReadWrite,
                    FileShare.Read);
                this.fs = this.filestream;

                    //File.Open(filePath, System.IO.FileMode.Create);
                this.bw = new BinaryWriter(this.fs);
                this.bw.Write(isFixed ? security_cod_pxc : security_cod_pac);
                this.bw.Write(-1L); // Это вместо DataStart
                this.bw.Write(-1L); // Это вместо freespace
                this.bw.Write(isFixed); for (int i=0; i<7; i++) this.bw.Write((byte)0);
                //
                //TODO: Пока блокирую запись типа в ячейку, но надо будет это исправить
                //this.Append(PType.TType, obj_typ);
                this.dataStart = fs.Position;
                this.freespace = this.dataStart;
                fs.Position = 8L;
                this.bw.Write(this.dataStart);
                this.bw.Write(this.freespace);
                fs.Position = this.dataStart;
            }
            else
            {
                long code = 0L;
                try
                {
                    this.fs = File.Open(filePath, System.IO.FileMode.Open);
                    this.br = new BinaryReader(this.fs);
                    if (!readOnly) this.bw = new BinaryWriter(this.fs);
                    code = this.br.ReadInt64();
                }
                catch (Exception ex)
                {
                    throw new Exception("File is not PolarDB file. Message: " + ex.Message);
                }
                if (isFixed && code == security_cod_pxc || !isFixed && code == security_cod_pac) { } // ok
                else throw new Exception("File is not PolarDB file");
                this.dataStart = this.br.ReadInt64();
                this.freespace = this.br.ReadInt64();
                //TODO: Пока тип не сохраняется и не проверяется
                //// Попробуем прочитать тип
                //this.fs.Position = 32L;
                //object vvv = ScanObject(PType.TType);
                //if (!Objects.Equvalent(obj_typ, vvv))
                //{
                //    throw new Exception("previous and current types are not equivalent");
                //}
            }
            if (br == null) this.br = new BinaryReader(this.fs);
            if (!readOnly && bw == null) this.bw = new BinaryWriter(this.fs);
            // Сформируем значение nElements
            if (typ.Vid == PTypeEnumeration.sequence && !this.IsEmpty)
            {
                this.SetOffset(this.dataStart);
                this.nElements = br.ReadInt64();
            }
        }
开发者ID:agmarchuk,项目名称:Polar,代码行数:73,代码来源:PCell.cs


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