本文整理汇总了C#中Field.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# Field.Reset方法的具体用法?C# Field.Reset怎么用?C# Field.Reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Field
的用法示例。
在下文中一共展示了Field.Reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteFieldsRecursive
static void WriteFieldsRecursive(IO.EndianWriter stream, Compiler comp, List<Import.Field> fields)
{
Field temp = new Field();
foreach (Import.Field f in fields)
{
if (f.TypeIndex == comp.TypeIndexStruct)
{
var import = comp.OwnerState.Importer as Import;
Import.TagStruct ts;
// Assert that the field references a valid definition
if (import.Structs.TryGetValue(f.Definition, out ts))
WriteFieldsRecursive(stream, comp, ts.Fields.Fields);
else
Debug.Assert.If(false, "Field '{0}' references an undefined tag struct '{1}'",
comp.Strings[f.Name], f.ToString());
}
else
{
// StringId support is a hack based on tag_reference fields
// We internally define the tag reference definition, so we must internally add it
if (f.TypeIndex == comp.TypeIndexStringId)
f.ChangeDefinition(Import.kStringIdFieldDefinitionName);
temp.Reset(f);
temp.Write(stream);
// While the initial part of the StringId hack is based on a tag_reference field,
// we use an additional 32 bits for the string_id handle (instead of playing with
// the tag_reference's tag_index member). This is seen as padding by the editor
if (f.TypeIndex == comp.TypeIndexStringId)
{
temp.Reset((comp.OwnerState.Importer as Halo1.CheApe.Import).StringIdFieldHandlePadding);
temp.Write(stream);
}
}
}
}
示例2: Write
public override void Write(IO.EndianWriter stream)
{
Compiler comp = stream.Owner as Compiler;
#region Fields
#region Byte swap codes
/*
uint fieldBSCodesAddress = stream.PositionUnsigned;
stream.Write(comp.OwnerState.Definition.FieldTypes[comp.TypeIndexArrayStart].ByteSwapCodes[0]);
stream.Write((int)1); // array count
foreach (Import.Field f in fieldSet.Fields)
{
if (f.TypeIndex == comp.TypeIndexUselessPad) continue;
else if (f.TypeIndex == comp.TypeIndexPad || f.TypeIndex == comp.TypeIndexSkip)
stream.Write(f.ToInt());
else
foreach (int x in comp.OwnerState.Definition.FieldTypes[f.TypeIndex].ByteSwapCodes)
if (x != 0)
stream.Write(x);
}
stream.Write(comp.OwnerState.Definition.FieldTypes[comp.TypeIndexArrayEnd].ByteSwapCodes[0]);
*/
#endregion
uint fieldsAddress = stream.PositionUnsigned;
Field temp = new Field();
foreach (Import.Field f in fieldSet.Fields)
{
temp.Reset(f);
temp.Write(stream);
}
stream.Write(comp.TypeIndexTerminator); stream.Write((int)0); stream.Write((int)0); stream.Write((int)0);
#endregion
int field_set_size = fieldSet.CalculateSize(comp.OwnerState);
stream.WritePointer(fieldsAddress);
stream.Write((int)0);
stream.Write((int)0);
stream.Write((int)0);
stream.Write(uint.MaxValue);
stream.Write(field_set_size);
stream.Write((int)0);
stream.Write((int)0);
stream.WritePointer(fieldsAddress);
stream.Write(comp.Strings.GetNull());
stream.Write(comp.Strings.GetNull());
stream.Write(field_set_size);
stream.Write((int)0);//stream.WritePointer(fieldBSCodesAddress);
MiscGroups.bysw.Write(stream);
stream.Write((int)0/*1*/);
stream.Write((int)0);
stream.Write((int)0);
stream.Write((int)0);
stream.Write((int)0);
}