本文整理汇总了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();
}
}