/// <summary> /// Resolves the specified data type. /// </summary> /// <param name="dataType">Data type specification.</param> /// <returns>Resolved EDM Type.</returns> PrimitiveDataType IPrimitiveDataTypeVisitor <PrimitiveDataType> .Visit(DateTimeDataType dataType) { int?precision = null; TimePrecisionFacet timePrecisionFacet; if (dataType.TryGetFacet(out timePrecisionFacet)) { precision = timePrecisionFacet.Value; } string typeName = dataType.GetFacetValue <EdmTypeNameFacet, string>(null); bool hasTimeZoneOffsetFacet = dataType.GetFacetValue <HasTimeZoneOffsetFacet, bool>(false); Type clrType = dataType.GetFacetValue <PrimitiveClrTypeFacet, Type>(null); bool hasDateTimeOffsetEdmTypeNameFacet = "DateTimeOffset".Equals(typeName, StringComparison.OrdinalIgnoreCase); if (hasTimeZoneOffsetFacet && typeName != null && !hasDateTimeOffsetEdmTypeNameFacet) { throw new TaupoInvalidOperationException( string.Format(CultureInfo.InvariantCulture, "Cannot resolve date time data type as it has 'true' value for the '{0}' which contradicts with the edm type name '{1}'", typeof(HasTimeZoneOffsetFacet).Name, typeName)); } if (hasTimeZoneOffsetFacet || hasDateTimeOffsetEdmTypeNameFacet || clrType == typeof(DateTimeOffset)) { return(EdmDataTypes.DateTimeOffset(precision)); } if (typeName != null && !"DateTime".Equals(typeName, StringComparison.OrdinalIgnoreCase)) { throw new TaupoInvalidOperationException( string.Format(CultureInfo.InvariantCulture, "Edm type name '{0}' is invalid for date time data types.", typeName)); } return(EdmDataTypes.DateTime(precision)); }
public EvaluationContext(Request req) { this._request = req; this._results = new Dictionary <string, Result>(); this._currentdate = new DateDataType(); this._currenttime = new TimeDataType(); this._currentdatetime = new DateTimeDataType(); }
public EvaluationContext(EvaluationContext context) { this._request = new Request(context._request); this._results = new Dictionary <string, Result>(); this._currentdate = context._currentdate; this._currenttime = context._currenttime; this._currentdatetime = context._currentdatetime; this._rootPolicyId = context._rootPolicyId; }
public override DataTypeValue Evaluate(DataTypeValue[] @params, EvaluationContext ctx) { if (@params.Length == paramsnum && @params[0] is DateTimeDataType && @params[1] is YearMonthDurationDataType) { var datetime = new DateTimeDataType(((DateTimeDataType)@params[0])); Calendar cal = datetime.Calendar; var period = (YearMonthDurationDataType)@params[1]; cal.add(Calendar.YEAR, -period.Year); cal.add(Calendar.MONTH, -period.Month); return(datetime); } throw new IllegalExpressionEvaluationException(stringIdentifer); }
public override DataTypeValue Evaluate(DataTypeValue[] @params, EvaluationContext ctx) { if (@params.Length == paramsnum && @params[0] is DateTimeDataType && @params[1] is DayTimeDurationDataType) { var datetime = new DateTimeDataType(((DateTimeDataType)@params[0])); Calendar cal = datetime.Calendar; var period = (DayTimeDurationDataType)@params[1]; cal.add(Calendar.SECOND, period.Second); cal.add(Calendar.MINUTE, period.Minute); cal.add(Calendar.HOUR, period.Hour); cal.add(Calendar.DAY, period.Day); return(datetime); } throw new IllegalExpressionEvaluationException(stringIdentifer); }
/// <summary> /// Initializes static members of the DataTypes class. /// </summary> static DataTypes() { Integer = new IntegerDataType(); Stream = new StreamDataType(); String = new StringDataType(); Boolean = new BooleanDataType(); FixedPoint = new FixedPointDataType(); FloatingPoint = new FloatingPointDataType(); DateTime = new DateTimeDataType(); Binary = new BinaryDataType(); Guid = new GuidDataType(); TimeOfDay = new TimeOfDayDataType(); ComplexType = new ComplexDataType(); EntityType = new EntityDataType(); CollectionType = new CollectionDataType(); ReferenceType = new ReferenceDataType(); RowType = new RowDataType(); EnumType = new EnumDataType(); Spatial = new SpatialDataType(); }
public DataTypeValue GetInstance(Node node) { return(DateTimeDataType.GetInstance(node)); }
public DataTypeValue GetInstance(string value) { return(DateTimeDataType.GetInstance(value)); }
IEdmPrimitiveTypeReference IPrimitiveDataTypeVisitor <IEdmPrimitiveTypeReference> .Visit(DateTimeDataType dataType) { return(this.GetTemporalTypeReference(dataType)); }