private String Step(I0 s, String inp) { Char c = PreStep(ref inp); if (DECIMAL.Contains(c)) { return(c.ToString() + Step(new T1(), inp)); } throw new CannotParseException(); }
private String Step(SV s, String inp) { Char c = PreStep(ref inp); if (POINT.Contains(c)) { return("0." + Step(new I0(), inp)); } else if (ZERO.Contains(c)) { return("0" + Step(new T2(), inp)); } else if (DECIMAL.Contains(c)) { return(c.ToString() + Step(new T4(), inp)); } throw new CannotParseException(); }
private String Step(T3 s, String inp) { Char c; try { c = PreStep(ref inp); } catch (EndOfStringException) { return(""); } if (DECIMAL.Contains(c)) { return(c.ToString() + Step(new T3(), inp)); } throw new CannotParseException(); }
public void TestIsNumeric() { // Define variables and constants Number number = 3; const string STRING = "Hi"; const bool BOOL = true; object @object = new object(); const decimal DECIMAL = 12m; // Set up context // Execute // Assert outcome Assert.IsTrue(Number.IsNumeric(number)); Assert.IsFalse(Number.IsNumeric(STRING)); Assert.IsFalse(Number.IsNumeric(BOOL)); Assert.IsFalse(Number.IsNumeric(@object)); Assert.IsTrue(Number.IsNumeric(DECIMAL)); Assert.IsTrue(Number.IsNumericType(number.GetType())); Assert.IsFalse(Number.IsNumericType(STRING.GetType())); Assert.IsFalse(Number.IsNumericType(BOOL.GetType())); Assert.IsFalse(Number.IsNumericType(@object.GetType())); Assert.IsTrue(Number.IsNumericType(DECIMAL.GetType())); foreach (Number num in allNumbers) { Assert.IsTrue(Number.IsNumeric(num.ActualValue)); Assert.IsTrue(Number.IsNumericType(num.ActualValue.GetType())); Assert.IsTrue(Number.IsNumericType(num.GetTypeCode())); Assert.IsTrue(Number.IsNumericType(num.GetTypeCode().ToType())); } }
public override string ToString() { StringBuilder __sb = new StringBuilder("LogicalType("); bool __first = true; if (STRING != null && __isset.@STRING) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("STRING: "); __sb.Append(STRING == null ? "<null>" : STRING.ToString()); } if (MAP != null && __isset.MAP) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("MAP: "); __sb.Append(MAP == null ? "<null>" : MAP.ToString()); } if (LIST != null && __isset.LIST) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("LIST: "); __sb.Append(LIST == null ? "<null>" : LIST.ToString()); } if (ENUM != null && __isset.@ENUM) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("ENUM: "); __sb.Append(ENUM == null ? "<null>" : ENUM.ToString()); } if (DECIMAL != null && __isset.@DECIMAL) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("DECIMAL: "); __sb.Append(DECIMAL == null ? "<null>" : DECIMAL.ToString()); } if (DATE != null && __isset.DATE) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("DATE: "); __sb.Append(DATE == null ? "<null>" : DATE.ToString()); } if (TIME != null && __isset.TIME) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("TIME: "); __sb.Append(TIME == null ? "<null>" : TIME.ToString()); } if (TIMESTAMP != null && __isset.TIMESTAMP) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("TIMESTAMP: "); __sb.Append(TIMESTAMP == null ? "<null>" : TIMESTAMP.ToString()); } if (INTEGER != null && __isset.INTEGER) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("INTEGER: "); __sb.Append(INTEGER == null ? "<null>" : INTEGER.ToString()); } if (UNKNOWN != null && __isset.UNKNOWN) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("UNKNOWN: "); __sb.Append(UNKNOWN == null ? "<null>" : UNKNOWN.ToString()); } if (JSON != null && __isset.JSON) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("JSON: "); __sb.Append(JSON == null ? "<null>" : JSON.ToString()); } if (BSON != null && __isset.BSON) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("BSON: "); __sb.Append(BSON == null ? "<null>" : BSON.ToString()); } if (UUID != null && __isset.UUID) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("UUID: "); __sb.Append(UUID == null ? "<null>" : UUID.ToString()); } __sb.Append(")"); return(__sb.ToString()); }
public void Write(TProtocol oprot) { oprot.IncrementRecursionDepth(); try { TStruct struc = new TStruct("LogicalType"); oprot.WriteStructBegin(struc); TField field = new TField(); if (STRING != null && __isset.@STRING) { field.Name = "STRING"; field.Type = TType.Struct; field.ID = 1; oprot.WriteFieldBegin(field); STRING.Write(oprot); oprot.WriteFieldEnd(); } if (MAP != null && __isset.MAP) { field.Name = "MAP"; field.Type = TType.Struct; field.ID = 2; oprot.WriteFieldBegin(field); MAP.Write(oprot); oprot.WriteFieldEnd(); } if (LIST != null && __isset.LIST) { field.Name = "LIST"; field.Type = TType.Struct; field.ID = 3; oprot.WriteFieldBegin(field); LIST.Write(oprot); oprot.WriteFieldEnd(); } if (ENUM != null && __isset.@ENUM) { field.Name = "ENUM"; field.Type = TType.Struct; field.ID = 4; oprot.WriteFieldBegin(field); ENUM.Write(oprot); oprot.WriteFieldEnd(); } if (DECIMAL != null && __isset.@DECIMAL) { field.Name = "DECIMAL"; field.Type = TType.Struct; field.ID = 5; oprot.WriteFieldBegin(field); DECIMAL.Write(oprot); oprot.WriteFieldEnd(); } if (DATE != null && __isset.DATE) { field.Name = "DATE"; field.Type = TType.Struct; field.ID = 6; oprot.WriteFieldBegin(field); DATE.Write(oprot); oprot.WriteFieldEnd(); } if (TIME != null && __isset.TIME) { field.Name = "TIME"; field.Type = TType.Struct; field.ID = 7; oprot.WriteFieldBegin(field); TIME.Write(oprot); oprot.WriteFieldEnd(); } if (TIMESTAMP != null && __isset.TIMESTAMP) { field.Name = "TIMESTAMP"; field.Type = TType.Struct; field.ID = 8; oprot.WriteFieldBegin(field); TIMESTAMP.Write(oprot); oprot.WriteFieldEnd(); } if (INTEGER != null && __isset.INTEGER) { field.Name = "INTEGER"; field.Type = TType.Struct; field.ID = 10; oprot.WriteFieldBegin(field); INTEGER.Write(oprot); oprot.WriteFieldEnd(); } if (UNKNOWN != null && __isset.UNKNOWN) { field.Name = "UNKNOWN"; field.Type = TType.Struct; field.ID = 11; oprot.WriteFieldBegin(field); UNKNOWN.Write(oprot); oprot.WriteFieldEnd(); } if (JSON != null && __isset.JSON) { field.Name = "JSON"; field.Type = TType.Struct; field.ID = 12; oprot.WriteFieldBegin(field); JSON.Write(oprot); oprot.WriteFieldEnd(); } if (BSON != null && __isset.BSON) { field.Name = "BSON"; field.Type = TType.Struct; field.ID = 13; oprot.WriteFieldBegin(field); BSON.Write(oprot); oprot.WriteFieldEnd(); } if (UUID != null && __isset.UUID) { field.Name = "UUID"; field.Type = TType.Struct; field.ID = 14; oprot.WriteFieldBegin(field); UUID.Write(oprot); oprot.WriteFieldEnd(); } oprot.WriteFieldStop(); oprot.WriteStructEnd(); } finally { oprot.DecrementRecursionDepth(); } }
public async Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken) { oprot.IncrementRecursionDepth(); try { var struc = new TStruct("LogicalType"); await oprot.WriteStructBeginAsync(struc, cancellationToken); var field = new TField(); if (STRING != null && __isset.@STRING) { field.Name = "STRING"; field.Type = TType.Struct; field.ID = 1; await oprot.WriteFieldBeginAsync(field, cancellationToken); await STRING.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (MAP != null && __isset.MAP) { field.Name = "MAP"; field.Type = TType.Struct; field.ID = 2; await oprot.WriteFieldBeginAsync(field, cancellationToken); await MAP.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (LIST != null && __isset.LIST) { field.Name = "LIST"; field.Type = TType.Struct; field.ID = 3; await oprot.WriteFieldBeginAsync(field, cancellationToken); await LIST.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (ENUM != null && __isset.@ENUM) { field.Name = "ENUM"; field.Type = TType.Struct; field.ID = 4; await oprot.WriteFieldBeginAsync(field, cancellationToken); await ENUM.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (DECIMAL != null && __isset.@DECIMAL) { field.Name = "DECIMAL"; field.Type = TType.Struct; field.ID = 5; await oprot.WriteFieldBeginAsync(field, cancellationToken); await DECIMAL.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (DATE != null && __isset.DATE) { field.Name = "DATE"; field.Type = TType.Struct; field.ID = 6; await oprot.WriteFieldBeginAsync(field, cancellationToken); await DATE.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (TIME != null && __isset.TIME) { field.Name = "TIME"; field.Type = TType.Struct; field.ID = 7; await oprot.WriteFieldBeginAsync(field, cancellationToken); await TIME.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (TIMESTAMP != null && __isset.TIMESTAMP) { field.Name = "TIMESTAMP"; field.Type = TType.Struct; field.ID = 8; await oprot.WriteFieldBeginAsync(field, cancellationToken); await TIMESTAMP.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (INTEGER != null && __isset.INTEGER) { field.Name = "INTEGER"; field.Type = TType.Struct; field.ID = 10; await oprot.WriteFieldBeginAsync(field, cancellationToken); await INTEGER.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (UNKNOWN != null && __isset.UNKNOWN) { field.Name = "UNKNOWN"; field.Type = TType.Struct; field.ID = 11; await oprot.WriteFieldBeginAsync(field, cancellationToken); await UNKNOWN.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (JSON != null && __isset.JSON) { field.Name = "JSON"; field.Type = TType.Struct; field.ID = 12; await oprot.WriteFieldBeginAsync(field, cancellationToken); await JSON.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } if (BSON != null && __isset.BSON) { field.Name = "BSON"; field.Type = TType.Struct; field.ID = 13; await oprot.WriteFieldBeginAsync(field, cancellationToken); await BSON.WriteAsync(oprot, cancellationToken); await oprot.WriteFieldEndAsync(cancellationToken); } await oprot.WriteFieldStopAsync(cancellationToken); await oprot.WriteStructEndAsync(cancellationToken); } finally { oprot.DecrementRecursionDepth(); } }
private static extern HRESULT VarDecFromR8(double dblIn, out DECIMAL pdecOut);
public void DECIMAL_ToDecimal_InvokeEmpty_ReturnsExpected() { var dec = new DECIMAL(); Assert.Equal(0m, dec.ToDecimal()); }