private TupleType TupleTypeFromNative(System.Type type)
{
var tupleType = new TupleType();
// Get attributes
foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Instance))
tupleType.Attributes.Add(Name.FromNative(field.Name), TypeFromNative(field.FieldType));
// Get references
foreach (TupleReferenceAttribute r in type.GetCustomAttributes(typeof(TupleReferenceAttribute)))
tupleType.References.Add
(
Name.FromNative(r.Name),
new TupleReference
{
SourceAttributeNames = (from san in r.SourceAttributeNames select Name.FromNative(san)).ToArray(),
Target = Name.FromNative(r.Target),
TargetAttributeNames = (from tan in r.TargetAttributeNames select Name.FromNative(tan)).ToArray()
}
);
// Get keys
foreach (TupleKeyAttribute k in type.GetCustomAttributes(typeof(TupleKeyAttribute)))
tupleType.Keys.Add
(
new TupleKey { AttributeNames = (from n in k.AttributeNames select Name.FromNative(n)).ToArray() }
);
return tupleType;
}