public Type BasicType(string name) { name = name ?? ""; if (name.EndsWith("?")) { var t = BasicType(name.Substring(0, name.Length - 1)); if (t == null) { return(null); } var st = typeof(Nullable <>); return(st.MakeGenericType(t)); } if (BasicTypes.TryGetValue(name, out var tt)) { return(tt); } if (name.StartsWith("Nullable<")) { var(_, tts) = GenericType(name); if (tts == null) { return(null); } var st = typeof(Nullable <>); return(st.MakeGenericType(tts)); } return(Type.GetType($"System.{name}")); }
public void ShouldSerializeBasicTypeMembers() { var expected = new BasicTypes { Character = 'a', Int = 3, Short = 2, Byte = 1, Long = 6, Double = 4.4, Float = 3.2f, UShort = 2, ULong = 3, UInt = 4, Decimal = 44, SByte = 3, Bool = false, String = "test" }; byte[] serialized = _serializer.Serialize(expected); var actual = _serializer.Deserialize <BasicTypes>(serialized); AssertProperties(expected, actual); }
private static ParamInfo[] PrecomputeTypes(ParameterInfo[] parameterInfos) { var precomputed = new ParamInfo[parameterInfos.Length]; bool foundTail = false; for (int i = parameterInfos.Length - 1; i >= 0; i--) { var parameterInfo = parameterInfos[i]; var arg = parameterInfo.ParameterType; ParamKind kind; if (arg == typeof(IReadOnlyList <ICommand>)) { kind = ParamKind.SpecialArguments; } else if (arg == typeof(ICommand)) { kind = ParamKind.NormalCommand; } else if (arg.IsArray) { kind = ParamKind.NormalArray; } else if (arg.IsEnum || BasicTypes.Contains(arg) || BasicTypes.Contains(UnwrapParamType(arg))) { kind = ParamKind.NormalParam; } // TODO How to distinguish between special type and dependency? else if (AdvancedTypes.Contains(arg)) { kind = ParamKind.NormalParam; } else { kind = ParamKind.Dependency; } if (kind.IsNormal()) { // If we have the last normal parameter, check if it fits the criteria // to be extened to a tail string. // If it does not, we set foundTail to true anyway, since no other // fitting parameter would be a tail anymore if (!foundTail && arg == typeof(string)) { kind = ParamKind.NormalTailString; } foundTail = true; } precomputed[i] = new ParamInfo( parameterInfo, kind, parameterInfo.IsOptional || parameterInfo.GetCustomAttribute <ParamArrayAttribute>() != null); } return(precomputed); }
public virtual void InitBasicTypeList() { BasicTypes.AddRange(new Type[] { typeof(string), typeof(Complex), typeof(Double), typeof(Single), typeof(Decimal), typeof(BigInteger), typeof(UInt64), typeof(Int64), typeof(UInt32), typeof(Int32), typeof(UInt16), typeof(Int16), typeof(byte), typeof(sbyte), typeof(bool) }); }
private static void ReadAttachmentIds(BinaryReader reader, BasicTypes expectedType, List <AttachmentId> attachmentIds) { if (expectedType != BasicTypes.Attachment && expectedType != BasicTypes.ItemOrAttachment) { ServiceIdConverter.TraceDebug("[IdConverter::ReadAttachmentIds] Did not expect attachments in id, but received attachments embedded in id"); throw new InvalidIdException(); } ServiceIdConverter.ReadAttachmentIds(reader, attachmentIds); }
private static IdStorageType ReadIdStorageType(BinaryReader reader, BasicTypes expectedType) { IdStorageType idStorageType = (IdStorageType)reader.ReadByte(); if (!EnumValidator.IsValidValue <IdStorageType>(idStorageType)) { ServiceIdConverter.TraceDebug("[IdConverter::ReadEnumValue] Invalid value for id storage type"); throw new InvalidIdMalformedException(); } return(idStorageType); }
/// <summary> /// Automaticall wrapes primitive results in <see cref="PrimitiveResult{T}"/>. /// Otherwise returns the result. /// </summary> /// <returns>The valid result.</returns> /// <param name="resultType">The type for the result.</param> /// <param name="result">The result value.</param> public static object ToResult(Type resultType, object result) { if (BasicTypes.Contains(resultType)) { var genType = typeof(PrimitiveResult <>).MakeGenericType(resultType); return(Activator.CreateInstance(genType, new object[] { result })); } else { return(result); } }
public void Union_Table_BasicTypes() { var builder = new FlatBuffers.FlatBufferBuilder(1024); var basicTypesOffset = Oracle.BasicTypes.CreateBasicTypes( builder, Bool: true, Byte: GetRandom <byte>(), SByte: GetRandom <sbyte>(), UShort: GetRandom <ushort>(), Short: GetRandom <short>(), UInt: GetRandom <uint>(), Int: GetRandom <int>(), ULong: GetRandom <ulong>(), Long: GetRandom <long>(), Float: GetRandom <float>(), Double: GetRandom <double>(), StringOffset: builder.CreateString("foobar")); var offset = Oracle.UnionTable.CreateUnionTable( builder, Oracle.Union.BasicTypes, basicTypesOffset.Value); builder.Finish(offset.Value); byte[] realBuffer = builder.DataBuffer.ToSizedArray(); var oracle = Oracle.UnionTable.GetRootAsUnionTable(new FlatBuffers.ByteBuffer(realBuffer)).Value <Oracle.BasicTypes>().Value; var unionTable = FlatBufferSerializer.Default.Parse <UnionTable>(realBuffer); Assert.Equal(1, unionTable.Union.Value.Discriminator); BasicTypes parsed = unionTable.Union.Value.Item1; Assert.NotNull(parsed); Assert.True(parsed.Bool); Assert.Equal(oracle.Byte, parsed.Byte); Assert.Equal(oracle.SByte, parsed.SByte); Assert.Equal(oracle.UShort, parsed.UShort); Assert.Equal(oracle.Short, parsed.Short); Assert.Equal(oracle.UInt, parsed.UInt); Assert.Equal(oracle.Int, parsed.Int); Assert.Equal(oracle.ULong, parsed.ULong); Assert.Equal(oracle.Long, parsed.Long); Assert.Equal(oracle.Float, parsed.Float); Assert.Equal(oracle.Double, parsed.Double); Assert.Equal("foobar", parsed.String); }
// MondValue -> T internal static Func <Expression, Expression> MakeParameterConversion(Type parameterType) { if (BasicTypes.Contains(parameterType)) { return(e => Expression.Convert(e, parameterType)); } if (NumberTypes.Contains(parameterType)) { return(e => Expression.Convert(Expression.Convert(e, typeof(double)), parameterType)); } return(null); }
public void Union_Table_BasicTypes() { var simple = new BasicTypes { Bool = true, Byte = GetRandom <byte>(), SByte = GetRandom <sbyte>(), Double = GetRandom <double>(), Float = GetRandom <float>(), Int = GetRandom <int>(), Long = GetRandom <long>(), Short = GetRandom <short>(), String = "foobar", UInt = GetRandom <uint>(), ULong = GetRandom <ulong>(), UShort = GetRandom <ushort>(), }; var table = new UnionTable { Union = new FlatBufferUnion <BasicTypes, Location, string>(simple) }; Span <byte> memory = new byte[10240]; int size = FlatBufferSerializer.Default.Serialize(table, memory); var oracle = Oracle.UnionTable.GetRootAsUnionTable( new FlatBuffers.ByteBuffer(memory.Slice(0, size).ToArray())); Assert.Equal(1, (int)oracle.ValueType); var bt = oracle.Value <Oracle.BasicTypes>().Value; Assert.True(bt.Bool); Assert.Equal(bt.Byte, simple.Byte); Assert.Equal(bt.SByte, simple.SByte); Assert.Equal(bt.UShort, simple.UShort); Assert.Equal(bt.Short, simple.Short); Assert.Equal(bt.UInt, simple.UInt); Assert.Equal(bt.Int, simple.Int); Assert.Equal(bt.ULong, simple.ULong); Assert.Equal(bt.Long, simple.Long); Assert.Equal(bt.Float, simple.Float); Assert.Equal(bt.Double, simple.Double); Assert.Equal(bt.String, simple.String); }
public void It_should_format_basic_types_properly() { var obj = new BasicTypes { DateTimeOffset = new DateTimeOffset(2022, 01, 02, 03, 04, 05, TimeSpan.FromHours(3)), DateTime = new DateTime(2022, 01, 02, 03, 04, 05, DateTimeKind.Utc), Decimal = (decimal)3.14, Guid = Guid.Parse("8bdcb730-6d08-409d-8170-12da52cb71e1"), NullableLong = 34, Span = TimeSpan.FromTicks(101427461000), }; var actual = ObjectFormatter.Dump(obj); Assert.That(actual.Replace("\r", ""), Is.EqualTo("BasicTypes: { Span=\"02:49:02.7461000\" DateTime=\"2022-01-02T03:04:05.0000000Z\" DateTimeOffset=\"2022-01-02T03:04:05.0000000+03:00\" Guid=\"8bdcb730-6d08-409d-8170-12da52cb71e1\" Decimal=\"3.14\" NullableLong=34 }".Replace("\r", ""))); }
private static byte[] ReadStoreId(BinaryReader reader, BasicTypes expectedType) { short num = reader.ReadInt16(); if (num < 0) { ServiceIdConverter.TraceDebug("[IdConverter::ReadStoreId] StoreId count < 0"); throw new InvalidIdMalformedException(); } byte[] array = reader.ReadBytes((int)num); if (array.Length != (int)num) { ServiceIdConverter.TraceDebug("[IdConverter::ReadStoreId] StoreId bytes length did not match actual length"); throw new InvalidIdMalformedException(); } return(array); }
public static bool IsValidResultType(Type resultType, IReadOnlyList <Type> returnTypes) { return(returnTypes.Any(t => { if (t == null) { return false; } if (BasicTypes.Contains(t)) { var genType = typeof(IPrimitiveResult <>).MakeGenericType(t); return genType.IsAssignableFrom(resultType); } else { return t.IsAssignableFrom(resultType); } })); }
/// <summary> /// Find an existing AST type equivalent to the given system type. /// If AST type names are modified, only basic types will continue to successfully resolve. /// </summary> /// <param name="type"></param> /// <returns></returns> public Type LookupType(System.Type type) { type = U.Deref(type); var ret = BasicTypes.Of(type); if (ret != null) { return(ret); } var ns = LookupNamespace(type.Namespace); if (ns != null) { ret = AllTypes.FirstOrDefault(t => t.Namespace == ns && t.Name == type.Name); } return(null); }
private void PrecomputeTypes() { for (int i = 0; i < CommandParameter.Length; i++) { ref var paramInfo = ref CommandParameter[i]; var arg = paramInfo.Type; if (arg == typeof(IReadOnlyList <ICommand>)) { paramInfo.Kind = ParamKind.SpecialArguments; } else if (arg == typeof(IReadOnlyList <Type>)) { paramInfo.Kind = ParamKind.SpecialReturns; } else if (arg == typeof(ICommand)) { paramInfo.Kind = ParamKind.NormalCommand; } else if (arg.IsArray) { paramInfo.Kind = ParamKind.NormalArray; } else if (arg.IsEnum || BasicTypes.Contains(arg) || BasicTypes.Contains(UnwrapParamType(arg))) { paramInfo.Kind = ParamKind.NormalParam; } // TODO How to distinguish between special type and dependency? else if (AdvancedTypes.Contains(arg)) { paramInfo.Kind = ParamKind.NormalParam; } else { paramInfo.Kind = ParamKind.Dependency; } }
public global::System.Threading.Tasks.Task <global::Bond.Comm.IMessage <dummy> > foo43Async(BasicTypes param) { var message = new global::Bond.Comm.Message <BasicTypes>(param); return(foo43Async(message, global::System.Threading.CancellationToken.None)); }
public virtual object Execute(ExecutionInformation info, IReadOnlyList <ICommand> arguments, IReadOnlyList <Type> returnTypes) { // Make arguments lazy, we only want to execute them once arguments = arguments.Select(c => new LazyCommand(c)).ToArray(); var parameters = FitArguments(info, arguments, returnTypes, out int availableArguments); // Check if we were able to set enough arguments int wantArgumentCount = Math.Min(parameters.Length, RequiredParameters); if (availableArguments < wantArgumentCount) { if (returnTypes.Contains(typeof(ICommand))) { return(arguments.Count > 0 ? (object)new AppliedCommand(this, arguments) : this); } throw ThrowAtLeastNArguments(wantArgumentCount); } if (returnTypes[0] == null) { // Evaluate ExecuteFunction(parameters); return(null); } if (returnTypes[0] == typeof(ICommand)) { // Return a command if we can take more arguments if (CommandParameter.Any(p => p.Type == typeof(string[])) || availableArguments < NormalParameters) { return(new AppliedCommand(this, arguments)); } } Log.Debug("Iterating over return types [{@returnTypes}]", returnTypes); var result = ExecuteFunction(parameters); if (ResultHelper.IsValidResult(result, returnTypes)) { Log.Debug("{0} can be directly returned", result); return(result); } if (result == null) { throw new CommandException("Couldn't find a proper command result for function " + internCommand.Name, CommandExceptionReason.NoReturnMatch); } var unwrapedResult = UnwrapReturn(result); var resultType = result.GetType(); var unwrapedResultType = unwrapedResult.GetType(); // Take first fitting command result foreach (var returnType in returnTypes) { if (returnType == null) { return(null); } if (returnType.IsAssignableFrom(resultType)) { return(ResultHelper.ToResult(returnType, result)); } else if (returnType.IsAssignableFrom(unwrapedResultType)) { return(ResultHelper.ToResult(returnType, unwrapedResult)); } else if (returnType == typeof(string)) { Log.Debug("Convert result to a string"); var resultStr = result.ToString(); if (!string.IsNullOrEmpty(resultStr)) { return(new PrimitiveResult <string>(resultStr)); } } else if (BasicTypes.Contains(returnType)) { if (BasicTypes.Contains(unwrapedResultType) && unwrapedResultType != typeof(string)) { // Automatically try to convert between primitive types try { return(ResultHelper.ToResult(resultType, Convert.ChangeType(unwrapedResult, returnType, CultureInfo.InvariantCulture))); } catch { } } } else if (returnType == typeof(JsonObject)) { if (result is JsonObject jsonResult) { return(jsonResult); } else { return(Activator.CreateInstance(typeof(JsonValue <>).MakeGenericType(result.GetType()), result)); } } // Ignore unknown types } throw new CommandException("Couldn't find a proper command result for function " + internCommand.Name, CommandExceptionReason.NoReturnMatch); }
static CreateBasicProperties() { GetTypeForPropertyRules.Insert(mi => BasicTypes.Any(t => t == mi.ReturnType().GetTypeOrUnderlyingType()) ? mi.ReturnType() : null); GetTypeForPropertyRules.Insert(mi => mi.TryGetAttribute <DontMapAttribute>() != null ? typeof(void) : null); GetTypeForPropertyRules.Insert(mi => mi.TryGetAttribute <SerializedUserTypeAttribute>() != null ? typeof(SerializedUserType <>).MakeGenericType(mi.ReturnType()) : null); }
// T -> MondValue internal static ReturnConverter MakeReturnConversion(Type returnType) { if (returnType == typeof(void)) { return((e, s, v) => throw new MondBindingException("Expression binder should not use void return conversion")); } if (returnType == typeof(MondValue)) { return((e, s, v) => Expression.Coalesce(v, Expression.Constant(MondValue.Null))); } if (returnType == typeof(string)) { return((e, s, v) => { var tempVar = Expression.Variable(typeof(string)); var tempVarIsNull = Expression.ReferenceEqual(tempVar, Expression.Constant(null)); var tempVarAsValue = Expression.Convert(tempVar, typeof(MondValue)); var block = Expression.Block( new[] { tempVar }, Expression.Assign(tempVar, v), Expression.Condition(tempVarIsNull, Expression.Constant(MondValue.Null), tempVarAsValue) ); return block; }); } if (BasicTypes.Contains(returnType)) { return((e, s, v) => Expression.Convert(v, typeof(MondValue))); } if (NumberTypes.Contains(returnType)) { return((e, s, v) => Expression.Convert(Expression.Convert(v, typeof(double)), typeof(MondValue))); } var classAttrib = returnType.Attribute <MondClassAttribute>(); if (classAttrib != null && classAttrib.AllowReturn) { var objInitializerType = typeof(IEnumerable <KeyValuePair <MondValue, MondValue> >); var valueFactory = typeof(MondValue).GetMethod("Object", new[] { typeof(MondState), objInitializerType }); if (valueFactory == null) { throw new Exception("Could not find MondValue.Object method"); } var findPrototype = typeof(MondState).GetMethod("FindPrototype"); if (findPrototype == null) { throw new Exception("Could not find FindPrototype method"); } var className = classAttrib.Name ?? returnType.Name; return((e, s, v) => { var prototype = Expression.Variable(typeof(MondValue)); var obj = Expression.Variable(typeof(MondValue)); var throwMsg = Expression.Constant(e + string.Format(BindingError.PrototypeNotFound, className)); var throwExpr = Expression.Throw(Expression.New(RuntimeExceptionConstructor, throwMsg)); return Expression.Block( new [] { prototype, obj }, Expression.Assign(prototype, Expression.Call(s, findPrototype, Expression.Constant(className))), Expression.IfThen(Expression.ReferenceEqual(prototype, Expression.Constant(null)), throwExpr), Expression.Assign(obj, Expression.Call(valueFactory, s, Expression.Constant(null, objInitializerType))), Expression.Assign(Expression.PropertyOrField(obj, "Prototype"), prototype), Expression.Assign(Expression.PropertyOrField(obj, "UserData"), v), obj ); }); } throw new MondBindingException(BindingError.UnsupportedReturnType, returnType); }
public virtual void foo13Async(BasicTypes request, global::Grpc.Core.Metadata headers = null, global::System.DateTime?deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { var message = global::Bond.Grpc.Message.From(request); foo13Async(message, new global::Grpc.Core.CallOptions(headers, deadline, cancellationToken)); }
unsafe public static void Main() { BasicTypes.ShowSizes(); }
private bool IsType(BasicTypes basicType) => !((Type & basicType) == 0);
private static IdProcessingInstruction ReadIdProcessingInstruction(BinaryReader reader, BasicTypes expectedType) { IdProcessingInstruction idProcessingInstruction = (IdProcessingInstruction)reader.ReadByte(); if (!EnumValidator.IsValidValue <IdProcessingInstruction>(idProcessingInstruction)) { ServiceIdConverter.TraceDebug("[IdConverter::ReadEnumValue] Invalid value for id processing instruction"); throw new InvalidIdMalformedException(); } return(idProcessingInstruction); }
public static bool IsDateType(this BasicTypes basicTypes) { return((BasicTypes.DATE_TYPE & basicTypes) != 0); }
public static IdHeaderInformation ConvertFromConcatenatedId(string id, BasicTypes expectedType, List <AttachmentId> attachmentIds) { if (string.IsNullOrEmpty(id)) { throw new InvalidIdEmptyException(); } EnumValidator.ThrowIfInvalid <BasicTypes>(expectedType, "expectedType"); IdHeaderInformation result; try { IdHeaderInformation idHeaderInformation = new IdHeaderInformation(); using (MemoryStream decompressedMemoryStream = ServiceIdConverter.GetDecompressedMemoryStream(id)) { using (BinaryReader binaryReader = new BinaryReader(decompressedMemoryStream)) { idHeaderInformation.IdStorageType = ServiceIdConverter.ReadIdStorageType(binaryReader, expectedType); switch (idHeaderInformation.IdStorageType) { case IdStorageType.MailboxItemSmtpAddressBased: idHeaderInformation.MailboxId = new MailboxId(MailboxIdSerializer.EmailAddressFromBytes(ServiceIdConverter.ReadMoniker(binaryReader, expectedType))); idHeaderInformation.IdProcessingInstruction = ServiceIdConverter.ReadIdProcessingInstruction(binaryReader, expectedType); idHeaderInformation.StoreIdBytes = ServiceIdConverter.ReadStoreId(binaryReader, expectedType); break; case IdStorageType.PublicFolder: case IdStorageType.ActiveDirectoryObject: idHeaderInformation.StoreIdBytes = ServiceIdConverter.ReadStoreId(binaryReader, expectedType); break; case IdStorageType.PublicFolderItem: idHeaderInformation.IdProcessingInstruction = ServiceIdConverter.ReadIdProcessingInstruction(binaryReader, expectedType); idHeaderInformation.StoreIdBytes = ServiceIdConverter.ReadStoreId(binaryReader, expectedType); idHeaderInformation.FolderIdBytes = ServiceIdConverter.ReadStoreId(binaryReader, expectedType); break; case IdStorageType.MailboxItemMailboxGuidBased: case IdStorageType.ConversationIdMailboxGuidBased: idHeaderInformation.MailboxId = new MailboxId(MailboxIdSerializer.MailboxGuidFromBytes(ServiceIdConverter.ReadMoniker(binaryReader, expectedType))); idHeaderInformation.IdProcessingInstruction = ServiceIdConverter.ReadIdProcessingInstruction(binaryReader, expectedType); idHeaderInformation.StoreIdBytes = ServiceIdConverter.ReadStoreId(binaryReader, expectedType); break; default: ServiceIdConverter.TraceDebug("[IdConverter::ConvertFromConcatenatedId] Invalid id storage type"); throw new InvalidIdMalformedException(); } if (attachmentIds != null) { if (decompressedMemoryStream.Position < decompressedMemoryStream.Length) { ServiceIdConverter.ReadAttachmentIds(binaryReader, expectedType, attachmentIds); } else if (expectedType == BasicTypes.Attachment) { throw new InvalidIdNotAnItemAttachmentIdException(); } } } } result = idHeaderInformation; } catch (EndOfStreamException innerException) { throw new InvalidIdMalformedException(innerException); } catch (CorruptDataException innerException2) { throw new InvalidIdMalformedException(innerException2); } catch (FormatException innerException3) { throw new InvalidIdMalformedException(innerException3); } return(result); }
public void foo13Async(BasicTypes param) { var message = new global::Bond.Comm.Message <BasicTypes>(param); foo13Async(message); }
public virtual void InitTypeConverters() { bool useComplex = BasicTypes.Contains(typeof(Complex)); bool useBigInt = BasicTypes.Contains(typeof(BigInteger)); //->string Type T = typeof(string); foreach (Type t in BasicTypes) { if (t != T) { TypeConverters.Add(t, T, ConvertAnyToString); } } //->Complex if (useComplex) { TypeConverters.Add(typeof(sbyte), typeof(Complex), ConvertAnyToComplex); TypeConverters.Add(typeof(byte), typeof(Complex), ConvertAnyToComplex); TypeConverters.Add(typeof(Int16), typeof(Complex), ConvertAnyToComplex); TypeConverters.Add(typeof(UInt16), typeof(Complex), ConvertAnyToComplex); TypeConverters.Add(typeof(Int32), typeof(Complex), ConvertAnyToComplex); TypeConverters.Add(typeof(UInt32), typeof(Complex), ConvertAnyToComplex); TypeConverters.Add(typeof(Int64), typeof(Complex), ConvertAnyToComplex); TypeConverters.Add(typeof(UInt64), typeof(Complex), ConvertAnyToComplex); TypeConverters.Add(typeof(Single), typeof(Complex), ConvertAnyToComplex); if (useBigInt) { TypeConverters.Add(typeof(BigInteger), typeof(Complex), ConvertBigIntToComplex); } } //->BigInteger if (useBigInt) { TypeConverters.Add(typeof(sbyte), typeof(BigInteger), ConvertAnyIntToBigInteger); TypeConverters.Add(typeof(byte), typeof(BigInteger), ConvertAnyIntToBigInteger); TypeConverters.Add(typeof(Int16), typeof(BigInteger), ConvertAnyIntToBigInteger); TypeConverters.Add(typeof(UInt16), typeof(BigInteger), ConvertAnyIntToBigInteger); TypeConverters.Add(typeof(Int32), typeof(BigInteger), ConvertAnyIntToBigInteger); TypeConverters.Add(typeof(UInt32), typeof(BigInteger), ConvertAnyIntToBigInteger); TypeConverters.Add(typeof(Int64), typeof(BigInteger), ConvertAnyIntToBigInteger); TypeConverters.Add(typeof(UInt64), typeof(BigInteger), ConvertAnyIntToBigInteger); } //->Double TypeConverters.Add(typeof(sbyte), typeof(double), value => (double)(sbyte)value); TypeConverters.Add(typeof(byte), typeof(double), value => (double)(byte)value); TypeConverters.Add(typeof(Int16), typeof(double), value => (double)(Int16)value); TypeConverters.Add(typeof(UInt16), typeof(double), value => (double)(UInt16)value); TypeConverters.Add(typeof(Int32), typeof(double), value => (double)(Int32)value); TypeConverters.Add(typeof(UInt32), typeof(double), value => (double)(UInt32)value); TypeConverters.Add(typeof(Int64), typeof(double), value => (double)(Int64)value); TypeConverters.Add(typeof(UInt64), typeof(double), value => (double)(UInt64)value); TypeConverters.Add(typeof(Single), typeof(double), value => (double)(Single)value); if (useBigInt) { TypeConverters.Add(typeof(BigInteger), typeof(double), value => ((BigInteger)value).ToDouble(null)); } //->Single TypeConverters.Add(typeof(sbyte), typeof(Single), value => (Single)(sbyte)value); TypeConverters.Add(typeof(byte), typeof(Single), value => (Single)(byte)value); TypeConverters.Add(typeof(Int16), typeof(Single), value => (Single)(Int16)value); TypeConverters.Add(typeof(UInt16), typeof(Single), value => (Single)(UInt16)value); TypeConverters.Add(typeof(Int32), typeof(Single), value => (Single)(Int32)value); TypeConverters.Add(typeof(UInt32), typeof(Single), value => (Single)(UInt32)value); TypeConverters.Add(typeof(Int64), typeof(Single), value => (Single)(Int64)value); TypeConverters.Add(typeof(UInt64), typeof(Single), value => (Single)(UInt64)value); if (useBigInt) { TypeConverters.Add(typeof(BigInteger), typeof(Single), value => (Single)((BigInteger)value).ToDouble(null)); } //->UInt64 TypeConverters.Add(typeof(sbyte), typeof(UInt64), value => (UInt64)(sbyte)value); TypeConverters.Add(typeof(byte), typeof(UInt64), value => (UInt64)(byte)value); TypeConverters.Add(typeof(Int16), typeof(UInt64), value => (UInt64)(Int16)value); TypeConverters.Add(typeof(UInt16), typeof(UInt64), value => (UInt64)(UInt16)value); TypeConverters.Add(typeof(Int32), typeof(UInt64), value => (UInt64)(Int32)value); TypeConverters.Add(typeof(UInt32), typeof(UInt64), value => (UInt64)(UInt32)value); TypeConverters.Add(typeof(Int64), typeof(UInt64), value => (UInt64)(Int64)value); //->Int64 TypeConverters.Add(typeof(sbyte), typeof(Int64), value => (Int64)(sbyte)value); TypeConverters.Add(typeof(byte), typeof(Int64), value => (Int64)(byte)value); TypeConverters.Add(typeof(Int16), typeof(Int64), value => (Int64)(Int16)value); TypeConverters.Add(typeof(UInt16), typeof(Int64), value => (Int64)(UInt16)value); TypeConverters.Add(typeof(Int32), typeof(Int64), value => (Int64)(Int32)value); TypeConverters.Add(typeof(UInt32), typeof(Int64), value => (Int64)(UInt32)value); //->UInt32 TypeConverters.Add(typeof(sbyte), typeof(UInt32), value => (UInt32)(sbyte)value); TypeConverters.Add(typeof(byte), typeof(UInt32), value => (UInt32)(byte)value); TypeConverters.Add(typeof(Int16), typeof(UInt32), value => (UInt32)(Int16)value); TypeConverters.Add(typeof(UInt16), typeof(UInt32), value => (UInt32)(UInt16)value); TypeConverters.Add(typeof(Int32), typeof(UInt32), value => (UInt32)(Int32)value); //->Int32 TypeConverters.Add(typeof(sbyte), typeof(Int32), value => (Int32)(sbyte)value); TypeConverters.Add(typeof(byte), typeof(Int32), value => (Int32)(byte)value); TypeConverters.Add(typeof(Int16), typeof(Int32), value => (Int32)(Int16)value); TypeConverters.Add(typeof(UInt16), typeof(Int32), value => (Int32)(UInt16)value); //->UInt16 TypeConverters.Add(typeof(sbyte), typeof(UInt16), value => (UInt16)(sbyte)value); TypeConverters.Add(typeof(byte), typeof(UInt16), value => (UInt16)(byte)value); TypeConverters.Add(typeof(Int16), typeof(UInt16), value => (UInt16)(Int16)value); //->Int16 TypeConverters.Add(typeof(sbyte), typeof(Int16), value => (Int16)(sbyte)value); TypeConverters.Add(typeof(byte), typeof(Int16), value => (Int16)(byte)value); //->byte TypeConverters.Add(typeof(sbyte), typeof(byte), value => (byte)(sbyte)value); }
private static Type GetBaseType(BasicTypes type) { switch (type) { case BasicTypes.Boolean: return typeof(Boolean); case BasicTypes.Byte: return typeof(Byte); case BasicTypes.Char: return typeof(Char); case BasicTypes.DateTime: return typeof(DateTime); case BasicTypes.Double: return typeof(Double); case BasicTypes.Int16: return typeof(Int16); case BasicTypes.Int32: return typeof(Int32); case BasicTypes.Int64: return typeof(Int64); case BasicTypes.SByte: return typeof(SByte); case BasicTypes.Single: return typeof(Single); case BasicTypes.String: return typeof(String); case BasicTypes.TimeSpan: return typeof(TimeSpan); case BasicTypes.UInt16: return typeof(UInt16); case BasicTypes.UInt32: return typeof(UInt32); case BasicTypes.UInt64: return typeof(UInt64); default: throw new UnknownDBException("BasicTypes enumeration was modified, but this function was not adapted."); } }
public static bool IsTextType(this BasicTypes basicTypes) { return((BasicTypes.TEXT_TYPE & basicTypes) != 0); }
public virtual global::Grpc.Core.AsyncUnaryCall <global::Bond.Grpc.IMessage <dummy> > foo43Async(BasicTypes request, global::Grpc.Core.Metadata headers = null, global::System.DateTime?deadline = null, global::System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { var message = global::Bond.Grpc.Message.From(request); return(foo43Async(message, new global::Grpc.Core.CallOptions(headers, deadline, cancellationToken))); }
public static bool IsNumericType(this BasicTypes basicTypes) { return((BasicTypes.NUMERIC_TYPE & basicTypes) != 0); }