internal static T GetField <T>(TripleStatement_Accessor accessor, string fieldName, int field_name_idx) { uint member_id; int field_divider_idx = fieldName.IndexOf('.', field_name_idx); if (-1 != field_divider_idx) { string member_name_string = fieldName.Substring(field_name_idx, field_divider_idx - field_name_idx); if (!FieldLookupTable_TripleStatement.TryGetValue(member_name_string, out member_id)) { Throw.undefined_field(); } switch (member_id) { default: Throw.member_access_on_non_struct__field(member_name_string); break; } } fieldName = fieldName.Substring(field_name_idx); if (!FieldLookupTable_TripleStatement.TryGetValue(fieldName, out member_id)) { Throw.undefined_field(); } switch (member_id) { case 0: return(TypeConverter <T> .ConvertFrom_Guid(accessor.RefId)); break; case 1: return(TypeConverter <T> .ConvertFrom_string(accessor.Subject)); break; case 2: return(TypeConverter <T> .ConvertFrom_string(accessor.Predicate)); break; case 3: return(TypeConverter <T> .ConvertFrom_string(accessor.Object)); break; } /* Should not reach here */ throw new Exception("Internal error T5008"); }
internal static void SetField <T>(TripleStatement_Accessor accessor, string fieldName, int field_name_idx, T value) { uint member_id; int field_divider_idx = fieldName.IndexOf('.', field_name_idx); if (-1 != field_divider_idx) { string member_name_string = fieldName.Substring(field_name_idx, field_divider_idx - field_name_idx); if (!FieldLookupTable_TripleStatement.TryGetValue(member_name_string, out member_id)) { Throw.undefined_field(); } switch (member_id) { default: Throw.member_access_on_non_struct__field(member_name_string); break; } return; } fieldName = fieldName.Substring(field_name_idx); if (!FieldLookupTable_TripleStatement.TryGetValue(fieldName, out member_id)) { Throw.undefined_field(); } switch (member_id) { case 0: { Guid conversion_result = TypeConverter <T> .ConvertTo_Guid(value); { accessor.RefId = conversion_result; } break; } case 1: { string conversion_result = TypeConverter <T> .ConvertTo_string(value); { accessor.Subject = conversion_result; } break; } case 2: { string conversion_result = TypeConverter <T> .ConvertTo_string(value); { accessor.Predicate = conversion_result; } break; } case 3: { string conversion_result = TypeConverter <T> .ConvertTo_string(value); { accessor.Object = conversion_result; } break; } } }