/// <summary> /// Gets the GffField derived object for the given schema. It will check /// the passed field dictionary for the field, if it is not found then it will /// create it and add it to the dictionary. /// </summary> /// <param name="schema">The field's schema</param> /// <param name="dict">The field dictionary to check</param> /// <returns>The GffField derived object for the field.</returns> protected GffField GetField(GffFieldSchema schema, GffFieldDictionary dict) { // Look up the field for the label. If we cannot look it up then // it has not been added to the module info file, we need to add // it ourselves. GffField field = dict[schema.Tag]; if (null == field) { field = schema.CreateField(); dict.Add(schema.Tag, field); } return field; }
public static GffFieldDictionary GetFieldStruct(RawGffData.RawGffStruct gstruct, RawGffData rawData) { // Loop through all of the fields in the struct adding them to the // collection. GffFieldDictionary fields = new GffFieldDictionary(); for (int i = 0; i < gstruct.FieldCount; i++) { // Get the index of the current field. If the structure has 1 // member then the offset is in DataOrDataOffset directly, if not // then DataOrDataOffset points to an array of DWORD indeces in // the raw field indeces block. uint fieldIndex = 1 == gstruct.FieldCount ? gstruct.DataOrDataOffset : rawData.GetFieldIndex((uint) (gstruct.DataOrDataOffset + (i * 4))); // Get the data label. RawGffData.RawGffField rawField = rawData.GetField(fieldIndex); string label = rawData.GetLabel(rawField.LabelIndex); // Create a GffField object for the field and add it to the // dictionary, using the label as the key. GffField field = GffFieldFactory.CreateField(rawField, rawData); fields.Add(label, field); } return fields; }