public static void Register <T1, T2>(this IDataTypeRegistry registry, IDataType dataType) { registry.Register(new object[] { typeof(T1), typeof(T2) }, dataType); }
private static void RegisterDataTypes(IDataTypeRegistry registry, IODataObjectFactory oDataObjectFactory, IMetadataService metadataService) { // FACTON domain types with their own, complex domain values registry.Register <IUnitValueDomainType>(new UnitValueDataType(oDataObjectFactory)); registry.Register <ILocalizedLongTextDomainType>(new LocalizedTextDataType(oDataObjectFactory)); // FACTON domain types whose domain values can be mapped to CLR types registry.Register <AbstractDateTimeDomainType>(new ClrTypeReferencingDataType <DateValue, DateTimeOffset>( v => new DateTimeOffset(v.Date), v => new DateValue(v.DateTime.ToUniversalTime()))); registry.Register("Boolean", new ClrTypeReferencingDataType <BooleanValue, bool>(v => v.Value, v => v.ToBooleanValue())); registry.Register("Number", new ClrTypeReferencingDataType <NumberValue, decimal>(v => v.InternalNumber, v => new NumberValue(v))); registry.Register( new object[] { "Integer", "AutoIncrement" }, new ClrTypeReferencingDataType <IntegerValue, long>(v => v.Value, v => new IntegerValue(v))); registry.Register( new object[] { "Id", "ContextBoundId" }, new ClrTypeReferencingDataType <IId, string>(IdConverter.ConvertToString, IdConverter.ConvertToId)); registry.Register <IMetadataItemDomainType>(new MetadataItemDataType(metadataService)); // FACTON domain types whose values _are_ CLR types registry.Register("TimeSpan", ClrDataTypes.Duration); registry.Register("SimpleBoolean", ClrDataTypes.Boolean); registry.Register("SimpleInteger", ClrDataTypes.Int32); registry.Register("SimpleDecimal", ClrDataTypes.Decimal); registry.Register("SimpleLong", ClrDataTypes.Int64); registry.Register("SimpleString", ClrDataTypes.String); registry.Register("SimpleLongString", ClrDataTypes.String); // FACTON domain types whose values can be serialized/deserialized to strings, using the DomainType itself registry.Register <ILongTextDomainType, ICurrencyDomainType>(new SerializableDomainTypeDataType()); // other, non-domain types registry.Register <IId>(new ClrTypeReferencingDataType <IId, string>(IdConverter.ConvertToString, IdConverter.ConvertToId)); }
public static void Register <T>(this IDataTypeRegistry registry, IDataType dataType) { registry.Register(typeof(T), dataType); }