本文整理汇总了C#中D3TypeDescriptor.FieldDescriptor类的典型用法代码示例。如果您正苦于以下问题:C# FieldDescriptor类的具体用法?C# FieldDescriptor怎么用?C# FieldDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldDescriptor类属于D3TypeDescriptor命名空间,在下文中一共展示了FieldDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateFieldFileRead
public override void GenerateFieldFileRead(StringBuilder b, int pad, FieldDescriptor f, string bitBufferName, string fieldname, FieldDescriptor[] fields)
{
b.Append(' ', pad); b.Append(fieldname + " = ");
b.Append(bitBufferName + ".ReadValueS32()");
b.AppendLine(";");
}
示例2: GenerateAsTextField
public override void GenerateAsTextField(StringBuilder b, int pad, FieldDescriptor f, string fieldname)
{
b.Append(' ', pad); b.AppendLine("for(int loop" + pad + " = 0;loop" + pad + " < _" + fieldname + ".Length;loop" + pad + "++)");
b.Append(' ', pad); b.AppendLine("{");
f.SubType.GenerateAsTextField(b, pad, f, "_" + fieldname + "[loop" + pad + "]");
b.Append(' ', pad); b.AppendLine("}");
}
示例3: GenerateParseBitBuffer
public override void GenerateParseBitBuffer(StringBuilder b, int pad, FieldDescriptor f, string bitBufferName, string fieldname)
{
if (f.HasMinMax)
throw new NotImplementedException();
b.Append(' ', pad); b.AppendLine(fieldname + " = (ushort)" + bitBufferName + ".ReadInt(" + f.EncodedBits + ");");
}
示例4: GenerateFieldFileRead
public override void GenerateFieldFileRead(StringBuilder b, int pad, FieldDescriptor f, string bitBufferName, string fieldname, FieldDescriptor[] fields)
{
b.Append(' ', pad); b.AppendLine("//still checking variablearrays");
b.Append(' ', pad); b.AppendLine(fieldname + " = new List<" + f.SubType.Name + ">();");
var ser = fields.First((w) => w.Offset == f.Offset + f.VariableOffset);
var tfield = "temp" + pad + "_" + fieldname;
int subfieldsize = 1;
if (f.SubType is StructureTypeDescriptor)
{
subfieldsize = (f.SubType as StructureTypeDescriptor).Fields.Last().Offset;
}
else
{
subfieldsize = (f.SubType as BasicTypeDescriptor).TypeSize;
}
b.Append(' ', pad); b.AppendLine("for(int i = 0; i < (int)(" + ser.Name + ".Field1 / "+subfieldsize.ToString()+"); i++)");
b.Append(' ', pad); b.AppendLine("{");
b.Append(' ', pad); b.AppendLine(bitBufferName + ".Position = " + ser.Name + ".Field0 + 16 + (" + subfieldsize.ToString()+ "*i) ;");
b.Append(' ', pad + 4); b.AppendLine(f.SubType.Name + " " + tfield + ";");
f.SubType.GenerateFieldFileRead(b, pad + 4, f, bitBufferName, tfield, fields);
b.Append(' ', pad + 4); b.AppendLine("_" + fieldname + ".Add(" + tfield + ");");
b.Append(' ', pad); b.AppendLine("}");
}
示例5: GenerateEncodeBitBuffer
public override void GenerateEncodeBitBuffer(StringBuilder b, int pad, FieldDescriptor f, string bitBufferName)
{
if (f.HasMinMax)
throw new NotImplementedException();
b.Append(' ', pad);
b.AppendLine(bitBufferName + ".WriteInt64(" + f.EncodedBits + ", " + f.GetFieldName() + ");");
}
示例6: GenerateEncodeBitBuffer
public override void GenerateEncodeBitBuffer(StringBuilder b, int pad, FieldDescriptor f, string bitBufferName, string fieldname)
{
b.Append(' ', pad); b.AppendLine("//still checking variablearrays");
b.Append(' ', pad); b.AppendLine(bitBufferName + ".WriteInt(0, _"+ fieldname+".Count);");
b.Append(' ', pad); b.AppendLine("for(int loop" + pad + " = 0; loop" + pad + " < _" + fieldname + ".Count; loop" + pad + "++)");
b.Append(' ', pad); b.AppendLine("{");
f.SubType.GenerateEncodeBitBuffer(b, pad + 4, f, bitBufferName, "_" + fieldname + "[loop" + pad + "]");
b.Append(' ', pad); b.AppendLine("}");
}
示例7: GenerateAsTextField
public override void GenerateAsTextField(StringBuilder b, int pad, FieldDescriptor f, string fieldname)
{
b.Append(' ', pad); b.AppendLine("for(int loop" + pad + " = 0; loop" + pad + " < _" + fieldname + ".Count; loop" + pad + "++)");
b.Append(' ', pad); b.AppendLine("{");
b.Append(' ', pad + 4);
var fname = "_" + fieldname + "[loop" + pad + "]";
b.AppendLine("b.Append(' ', pad); b.AppendLine(\"" + "_" + fieldname + "[loop" + pad + "]" + ":\" + " + fname + ".ToString() );");
b.Append(' ', pad); b.AppendLine("}");
}
示例8: LoadFields
public override void LoadFields(FieldDescriptor[] fields)
{
if (fields.Length != 3 ||
fields[0].Type.Name != "DT_OPTIONAL" || fields[0].SubType.Name != "DT_INT" ||
fields[1].Type.Name != "DT_INT" ||
fields[2].Type != null)
throw new Exception("Unexpected fields in NetAttributeKeyValue structure.");
fields[1].Type = AttributeFieldType.Instance;
base.LoadFields(fields);
}
示例9: LoadFields
public override void LoadFields(FieldDescriptor[] fields)
{
if(fields[0].Type.Name != "RequiredMessageHeader")
throw new Exception("Expected RequiredMessageHeader.");
fields = fields.Skip(1).ToArray();
for (int i = 0; i < fields.Length; i++)
fields[i].Index = i;
base.LoadFields(fields);
}
示例10: GenerateParseBitBuffer
public override void GenerateParseBitBuffer(StringBuilder b, int pad, FieldDescriptor f, string bitBufferName)
{
if (f.HasMinMax)
throw new NotImplementedException();
if (f.Float16Encoding)
throw new NotImplementedException();
if (f.EncodedBits != 32)
throw new NotImplementedException();
b.Append(' ', pad);
b.AppendLine(f.GetFieldName() + " = " + bitBufferName + ".ReadFloat32();");
}
示例11: GenerateOptionalEncodeBitBuffer
public override void GenerateOptionalEncodeBitBuffer(StringBuilder b, int pad, FieldDescriptor f, string bitBufferName)
{
if (f.HasMinMax)
throw new NotImplementedException();
if (f.Float16Encoding)
throw new NotImplementedException();
if (f.EncodedBits != 32)
throw new NotImplementedException();
var fieldName = f.GetFieldName();
b.Append(' ', pad); b.AppendLine("if(" + fieldName + ".HasValue)");
b.Append(' ', pad+4); b.AppendLine(bitBufferName + ".WriteFloat32(" + f.GetFieldName() + ".Value);");
}
示例12: GenerateFieldFileRead
public override void GenerateFieldFileRead(StringBuilder b, int pad, FieldDescriptor f, string bitBufferName, string fieldname, FieldDescriptor[] fields)
{
b.Append(' ', pad); b.AppendLine(fieldname + " = new " + f.SubType.Name + "["+f.ArrayLength+"];");
var tfield = "temp" + pad + "_" + fieldname;
var lname = "loop"+pad.ToString();
b.Append(' ', pad); b.AppendLine("for(int " + lname + "=0; " + lname + " < " + f.ArrayLength + "; " + lname + "++ )");
b.Append(' ', pad); b.AppendLine("{");
b.Append(' ', pad + 4); b.AppendLine(f.SubType.Name + " " + tfield + ";");
f.SubType.GenerateFieldFileRead(b, pad + 4, f, bitBufferName, tfield, fields);
b.Append(' ', pad + 4); b.AppendLine("_" + fieldname + "[" + lname + "] = " + tfield + ";");
b.Append(' ', pad); b.AppendLine("}");
}
示例13: GenerateFixedArrayEncodeBitBuffer
public override void GenerateFixedArrayEncodeBitBuffer(StringBuilder b, int pad, FieldDescriptor f, string bitBufferName, string fieldname)
{
b.Append(' ', pad); b.AppendLine("//still checking fixedarrays on basictypes");
if (f.HasArrayLengthOffset)
{
b.Append(' ', pad);
b.AppendLine(bitBufferName + ".WriteInt(" + f.EncodedBits2 + ", " + fieldname + ".Length);");
}
b.Append(' ', pad); b.AppendLine("for(int loop" + pad + " = 0;loop" + pad + " < _" + fieldname + ".Length;loop" + pad + "++)");
b.Append(' ', pad); b.AppendLine("{");
f.SubType.GenerateEncodeBitBuffer(b, pad, f, bitBufferName, "_" + fieldname + "[loop" + pad + "]");
b.Append(' ', pad); b.AppendLine("}");
}
示例14: GenerateFieldFileRead
public override void GenerateFieldFileRead(StringBuilder b, int pad, FieldDescriptor f, string bitBufferName, string fieldname, FieldDescriptor[] fields)
{
b.Append(' ', pad); b.AppendLine("//still checking variablearrays");
b.Append(' ', pad); b.AppendLine(fieldname + " = new List<byte>();");
var ser = fields.First((w) => w.Offset == f.Offset + f.VariableOffset);
var tfield = "temp" + pad + "_" + fieldname;
int subfieldsize = 1;
b.Append(' ', pad); b.AppendLine("for(int i = 0; i < (int)(" + ser.GetFieldName() + ".Field1 / " + subfieldsize.ToString() + "); i++)");
b.Append(' ', pad); b.AppendLine("{");
b.Append(' ', pad + 4); b.AppendLine(bitBufferName + ".Position = " + ser.GetFieldName() + ".Field0 + 16 + (" + subfieldsize.ToString() + "*i) ;");
b.Append(' ', pad + 4); b.AppendLine("byte " + tfield + ";");
b.Append(' ', pad + 4); b.AppendLine(tfield + " = (byte)stream.ReadByte();");
b.Append(' ', pad + 4); b.AppendLine("_" + fieldname + ".Add(" + tfield + ");");
b.Append(' ', pad); b.AppendLine("}");
}
示例15: GenerateEncodeBitBuffer
public override void GenerateEncodeBitBuffer(StringBuilder b, int pad, FieldDescriptor f, string bitBufferName, string fieldname)
{
if (f.HasMinMax)
{
b.Append(' ', pad);
b.AppendLine("minmax is still unsupported on floats.");
}
if (
(f.Float16Encoding) ||
(f.EncodedBits != 32)
)
{
b.Append(' ', pad); b.AppendLine(bitBufferName + ".WriteFloat(" + fieldname + "," + f.EncodedBits.ToString() + ");");
}
if (f.EncodedBits == 32)
{
b.Append(' ', pad); b.AppendLine(bitBufferName + ".WriteFloat32(" + fieldname + ");");
}
}