public void TestGetObjectDateTimeValue() { DateTime dateTime = new DateTime(); Date date = new Date(); date.year = 2012; date.month = 12; date.day = 2; dateTime.date = date; dateTime.hour = 12; dateTime.minute = 45; dateTime.second = 0; dateTime.timeZoneID = "Asia/Shanghai"; DateTimeValue dateTimeValue = new DateTimeValue(); dateTimeValue.value = dateTime; Assert.AreEqual(dateTime, PqlUtilities.GetValue(dateTimeValue)); }
//Получения значения из строкового представления public Value GetValueFromString(string part, string type) { ConverteType converteType = GetConverteType(type); //Преобразование строки типа в элемент обрабатываемого типа //Выбор создания значения в зависимости от типа try { switch (converteType) { case ConverteType.String: //Создание значения типа string var stringValue = new Value<string>(); stringValue.OriginalValue = part; //Получение значения return stringValue; case ConverteType.Date: //Создание значения типа Datetime var dateValue = new DateTimeValue(); dateValue.OriginalValue = DateTime.Parse(part); //Преобразование строкового значения в тип Datetime return dateValue; case ConverteType.Integer: //Создание значения типа Int32 var integerValue = new Value<int>(); integerValue.OriginalValue = Int32.Parse(part); //Преобразование строкового значения в тип Int32 return integerValue; case ConverteType.Float: //Создание значения типа Float var floatValue = new FloatValue(); floatValue.OriginalValue = float.Parse(part.Replace(',', '.')); //Преобразовани значения в тип Float return floatValue; default: //Switch должен вернуть значение Debug.Fail(String.Format("Illegal value {0}", converteType)); Environment.FailFast(null); return new Value<string>(); } } catch { Console.WriteLine("Невозможно преобразовать значение {0} в тип {1}", part, type); Console.ReadKey(); Environment.Exit(1); } return new Value<string>(); //Метод должен вернуть значение }
public override ListValue MapDateTime(DateTimeValue value) { return(null); }
private List<IFilter> CreateFilters(string match, ComparisonOperation comparisonOperation, int columnIndex) { IPreprocessingData preprocessingData = Content.FilterLogic.PreprocessingData; IStringConvertibleValue value; if (preprocessingData.VariableHasType<double>(columnIndex)) { value = new DoubleValue(); } else if (preprocessingData.VariableHasType<String>(columnIndex)) { value = new StringValue(); } else if (preprocessingData.VariableHasType<DateTime>(columnIndex)) { value = new DateTimeValue(); } else { throw new ArgumentException("unsupported type"); } value.SetValue(match); var comparisonFilter = new ComparisonFilter(preprocessingData, GetConstraintOperation(comparisonOperation), value, true); comparisonFilter.ConstraintColumn = columnIndex; return new List<Filter.IFilter>() { comparisonFilter }; }
internal static OpenXmlSimpleType[] CreatePossibleMembers(UnionValueRestriction unionValueRestriction) { OpenXmlSimpleType[] simpleValues = new OpenXmlSimpleType[unionValueRestriction.UnionTypes.Length]; switch (unionValueRestriction.UnionId) { // ST_AnimationDgmBuildType case 25: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationBuildValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationDiagramOnlyBuildValues>(); break; // ST_AnimationChartBuildType case 27: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationBuildValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.AnimationChartOnlyBuildValues>(); break; // ST_AdjCoordinate case 45: simpleValues[0] = new Int64Value(); simpleValues[1] = new StringValue(); break; // ST_AdjAngle case 46: simpleValues[0] = new Int32Value(); simpleValues[1] = new StringValue(); break; // ST_LayoutShapeType case 145: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.ShapeTypeValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.OutputShapeValues>(); break; // ST_ParameterVal case 183: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HorizontalAlignmentValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.VerticalAlignmentValues>(); simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ChildDirectionValues>(); simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ChildAlignmentValues>(); simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryChildAlignmentValues>(); simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.LinearDirectionValues>(); simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryLinearDirectionValues>(); simpleValues[7] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.StartingElementValues>(); simpleValues[8] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.BendPointValues>(); simpleValues[9] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorRoutingValues>(); simpleValues[10] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ArrowheadStyleValues>(); simpleValues[11] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorDimensionValues>(); simpleValues[12] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.RotationPathValues>(); simpleValues[13] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.CenterShapeMappingValues>(); simpleValues[14] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.NodeHorizontalAlignmentValues>(); simpleValues[15] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.NodeVerticalAlignmentValues>(); simpleValues[16] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.FallbackDimensionValues>(); simpleValues[17] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextDirectionValues>(); simpleValues[18] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentPositionValues>(); simpleValues[19] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentTextMarginValues>(); simpleValues[20] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextBlockDirectionValues>(); simpleValues[21] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorHorizontalValues>(); simpleValues[22] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorVerticalValues>(); simpleValues[23] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.TextAlignmentValues>(); simpleValues[24] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AutoTextRotationValues>(); simpleValues[25] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.GrowDirectionValues>(); simpleValues[26] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.FlowDirectionValues>(); simpleValues[27] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ContinueDirectionValues>(); simpleValues[28] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.BreakpointValues>(); simpleValues[29] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.OffsetValues>(); simpleValues[30] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyAlignmentValues>(); simpleValues[31] = new Int32Value(); simpleValues[32] = new DoubleValue(); simpleValues[33] = new BooleanValue(); simpleValues[34] = new StringValue(); simpleValues[35] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorPointValues>(); break; // ST_ModelId case 184: simpleValues[0] = new Int32Value(); simpleValues[1] = new StringValue(); break; // ST_FunctionValue case 207: simpleValues[0] = new Int32Value(); simpleValues[1] = new BooleanValue(); simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.DirectionValues>(); simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyBranchStyleValues>(); simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AnimateOneByOneValues>(); simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.AnimationLevelStringValues>(); simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.ResizeHandlesStringValues>(); break; // ST_FunctionArgument case 209: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Drawing.Diagrams.VariableValues>(); break; // ST_NonZeroDecimalNumber case 368: simpleValues[0] = new Int32Value(); simpleValues[1] = new Int32Value(); break; // ST_MarkupId case 375: simpleValues[0] = new Int32Value(); simpleValues[1] = new Int32Value(); break; // ST_HexColor case 404: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Wordprocessing.AutomaticColorValues>(); simpleValues[1] = new HexBinaryValue(); break; // ST_DecimalNumberOrPercent case 507: simpleValues[0] = new StringValue(); simpleValues[1] = new Int32Value(); break; // ST_SignedHpsMeasure_O14 case 525: simpleValues[0] = new IntegerValue(); simpleValues[1] = new StringValue(); break; // ST_HpsMeasure_O14 case 528: simpleValues[0] = new UInt32Value(); simpleValues[1] = new StringValue(); break; // ST_SignedTwipsMeasure_O14 case 531: simpleValues[0] = new IntegerValue(); simpleValues[1] = new StringValue(); break; // ST_TwipsMeasure_O14 case 534: simpleValues[0] = new UInt32Value(); simpleValues[1] = new StringValue(); break; // ST_TransitionEightDirectionType case 544: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Presentation.TransitionSlideDirectionValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.TransitionCornerDirectionValues>(); break; // ST_TLTimeAnimateValueTime case 561: simpleValues[0] = new Int32Value(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_TLTime_O12 case 603: simpleValues[0] = new UInt32Value(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_TLTime_O14 case 604: simpleValues[0] = new StringValue(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_PublishDate case 689: simpleValues[0] = new DateTimeValue(); simpleValues[1] = new DateTimeValue(); simpleValues[2] = new StringValue(); break; // ST_ChannelDataPoint case 697: simpleValues[0] = new DecimalValue(); simpleValues[1] = new BooleanValue(); break; // ST_ChannelPropertyName case 701: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardChannelPropertyNameValues>(); simpleValues[1] = new StringValue(); break; // ST_BrushPropertyName case 704: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardBrushPropertyNameValues>(); simpleValues[1] = new StringValue(); break; // ST_ChannelName case 707: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardChannelNameValues>(); simpleValues[1] = new StringValue(); break; // ST_Units case 719: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardLengthUnitsValues>(); simpleValues[1] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerLengthUnitsValues>(); simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardTimeUnitsValues>(); simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerTimeUnitsValues>(); simpleValues[4] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardMassForceUnitsValues>(); simpleValues[5] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerMassForceUnitsValues>(); simpleValues[6] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardAngleUnitsValues>(); simpleValues[7] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerAngleUnitsValues>(); simpleValues[8] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardOtherUnitsValues>(); simpleValues[9] = new EnumValue<DocumentFormat.OpenXml.InkML.StandardPerOtherUnitsValues>(); simpleValues[10] = new StringValue(); break; // ST_BrushPropertyValue case 732: simpleValues[0] = new DecimalValue(); simpleValues[1] = new BooleanValue(); simpleValues[2] = new EnumValue<DocumentFormat.OpenXml.InkML.PenTipShapeValues>(); simpleValues[3] = new EnumValue<DocumentFormat.OpenXml.InkML.RasterOperationValues>(); simpleValues[4] = new StringValue(); break; // ST_Ref case 746: simpleValues[0] = new StringValue(); simpleValues[1] = new UInt32Value(); break; // ST_CtxNodeType case 747: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Office2010.Ink.KnownContextNodeTypeValues>(); simpleValues[1] = new StringValue(); break; // ST_SemanticType case 750: simpleValues[0] = new EnumValue<DocumentFormat.OpenXml.Office2010.Ink.KnownSemanticTypeValues>(); simpleValues[1] = new UInt32Value(); break; // ST_PointsOrInt case 753: simpleValues[0] = new ListValue<StringValue>(); simpleValues[1] = new Int32Value(); break; default: Debug.Assert(false); break; } Debug.Assert(simpleValues.Length > 0); return simpleValues; }
public XmlRecord(XmlProperty[] properties, FixedWKTReader wktReader, XmlNodeList propertyNodes, string nameElement, string valueElement) { for (int i = 0; i < properties.Length; i++) { string name = properties[i].Name; _ordinalMap[i] = name; switch (properties[i].Type) { case PropertyValueType.Blob: _values[name] = new BlobValue(); break; case PropertyValueType.Boolean: _values[name] = new BooleanValue(); break; case PropertyValueType.Byte: _values[name] = new ByteValue(); break; case PropertyValueType.Clob: _values[name] = new ClobValue(); break; case PropertyValueType.DateTime: _values[name] = new DateTimeValue(); break; case PropertyValueType.Double: _values[name] = new DoubleValue(); break; case PropertyValueType.Feature: _values[name] = new FeatureValue(); break; case PropertyValueType.Geometry: _values[name] = new GeometryValue(); break; case PropertyValueType.Int16: _values[name] = new Int16Value(); break; case PropertyValueType.Int32: _values[name] = new Int32Value(); break; case PropertyValueType.Int64: _values[name] = new Int64Value(); break; case PropertyValueType.Raster: _values[name] = new RasterValue(); break; case PropertyValueType.Single: _values[name] = new SingleValue(); break; case PropertyValueType.String: _values[name] = new StringValue(); break; } } foreach (XmlNode propNode in propertyNodes) { var name = propNode[nameElement].InnerText; var valueNode = propNode[valueElement]; if (valueNode != null) { var value = valueNode.InnerText; switch (_values[name].Type) { case PropertyValueType.Blob: ((BlobValue)_values[name]).Value = Encoding.UTF8.GetBytes(value); break; case PropertyValueType.Boolean: ((BooleanValue)_values[name]).Value = XmlConvert.ToBoolean(value); break; case PropertyValueType.Byte: ((ByteValue)_values[name]).Value = XmlConvert.ToByte(value); break; case PropertyValueType.Clob: ((ClobValue)_values[name]).Value = value.ToCharArray(); break; case PropertyValueType.DateTime: var dt = ConvertToDateTime(value); if (dt.HasValue) ((DateTimeValue)_values[name]).Value = dt.Value; break; case PropertyValueType.Double: ((DoubleValue)_values[name]).Value = XmlConvert.ToDouble(value); break; case PropertyValueType.Feature: ((FeatureValue)_values[name]).Value = ConvertToFeatures(value); break; case PropertyValueType.Geometry: ((GeometryValue)_values[name]).Value = wktReader.Read(value); break; case PropertyValueType.Int16: ((Int16Value)_values[name]).Value = XmlConvert.ToInt16(value); break; case PropertyValueType.Int32: ((Int32Value)_values[name]).Value = XmlConvert.ToInt32(value); break; case PropertyValueType.Int64: ((Int64Value)_values[name]).Value = XmlConvert.ToInt64(value); break; case PropertyValueType.Raster: ((RasterValue)_values[name]).Value = ConvertToRaster(value); break; case PropertyValueType.Single: ((SingleValue)_values[name]).Value = XmlConvert.ToSingle(value); break; case PropertyValueType.String: ((StringValue)_values[name]).Value = value; break; } } } }
public void DateTimeValueTest() { string utcTime = "2008-07-17T16:11:10.518Z"; // System.Globalization.CultureInfo cultureInfo = System.Globalization.CultureInfo.GetCultureInfo("zh-CN"); DateTime dateTime = System.Xml.XmlConvert.ToDateTime(utcTime, System.Xml.XmlDateTimeSerializationMode.Utc); DateTimeValue target = new DateTimeValue( dateTime ); Assert.True(target.HasValue); Assert.Equal(utcTime, target.InnerText); target = new DateTimeValue(); target.InnerText = utcTime; Assert.True(target.HasValue); Assert.Equal(dateTime, target.Value); }
public void TestGetObjectDateTimeSetValue() { DateTime dateTime = new DateTime(); Date date = new Date(); date.year = 2012; date.month = 12; date.day = 2; dateTime.date = date; dateTime.hour = 12; dateTime.minute = 45; dateTime.second = 0; dateTime.timeZoneID = "Asia/Shanghai"; DateTimeValue dateTimeValue = new DateTimeValue(); dateTimeValue.value = dateTime; SetValue setValue = new SetValue(); setValue.values = new Value[] { dateTimeValue }; List<object> value = PqlUtilities.GetValue(setValue) as List<object>; Assert.AreEqual(1, value.Count); Assert.True(value.Contains(dateTime)); }
protected DateTimeImmutable(Context ctx) { _value = DateTimeValue.CreateNow(ctx); }
public void OpenXmlSimpleTypeConverterTest() { // 1. Base64BinaryValue Base64BinaryValue base64 = new Base64BinaryValue(); base64 = "AA3322"; Assert.True("AA3322" == base64); Assert.Equal("AA3322", base64.Value); base64 = Base64BinaryValue.FromString("1234"); Assert.Equal("1234", base64.ToString()); Assert.Equal("1234", Base64BinaryValue.ToString(base64)); // 2. BooleanValue BooleanValue booleanValue = new BooleanValue(); booleanValue = true; Assert.True(booleanValue); Assert.True(booleanValue.Value); booleanValue = BooleanValue.FromBoolean(false); Assert.False(booleanValue); Assert.Equal(false, BooleanValue.ToBoolean(booleanValue)); // 3. ByteValue ByteValue byteValue = new ByteValue(); Byte bt = 1; byteValue = bt; Assert.True(bt == byteValue); Assert.Equal(bt, byteValue.Value); bt = 2; byteValue = ByteValue.FromByte(bt); Assert.Equal(bt, ByteValue.ToByte(byteValue)); // 4. DateTimeValue DateTimeValue dtValue = new DateTimeValue(); DateTime dt = DateTime.Now; dtValue = dt; Assert.True(dt == dtValue); dt = DateTime.Now.AddDays(1); dtValue = DateTimeValue.FromDateTime(dt); Assert.Equal(dt, dtValue.Value); Assert.Equal(dt, DateTimeValue.ToDateTime(dt)); // 5. DecimalValue DecimalValue decimalValue = new DecimalValue(); decimal dcm = 10; decimalValue = dcm; Assert.True(dcm == decimalValue); decimalValue = DecimalValue.FromDecimal(20); Assert.Equal(20, decimalValue.Value); Assert.Equal(20, DecimalValue.ToDecimal(decimalValue)); // 6. DoubleValue DoubleValue doubleValue = new DoubleValue(); double dbl = 1.1; doubleValue = dbl; Assert.True(dbl == doubleValue); doubleValue = DoubleValue.FromDouble(2.2); Assert.Equal(2.2, doubleValue.Value); Assert.Equal(2.2, DoubleValue.ToDouble(doubleValue)); // 7. HexBinaryValue HexBinaryValue hexBinaryValue = new HexBinaryValue(); string hex = "0X99CCFF"; hexBinaryValue = hex; Assert.True(hex == hexBinaryValue); hex = "111111"; hexBinaryValue = HexBinaryValue.FromString(hex); Assert.Equal(hex, hexBinaryValue.Value); Assert.Equal(hex, HexBinaryValue.ToString(hexBinaryValue)); // 8. Int16 Int16Value int16Value = new Int16Value(); Int16 int16 = 16; int16Value = int16; Assert.True(int16 == int16Value); int16 = 17; int16Value = Int16Value.FromInt16(int16); Assert.Equal(int16, int16Value.Value); Assert.Equal(int16, Int16Value.ToInt16(int16Value)); // 9. Int32 Int32Value int32Value = new Int32Value(); Int32 int32 = 32; int32Value = int32; Assert.True(int32 == int32Value); int32 = 33; int32Value = Int32Value.FromInt32(int32); Assert.Equal(int32, int32Value.Value); Assert.Equal(int32, Int32Value.ToInt32(int32Value)); // 10. Int64 Int64Value int64Value = new Int64Value(); Int64 int64 = 64; int64Value = int64; Assert.True(int64 == int64Value); int64 = 17; int64Value = Int64Value.FromInt64(int64); Assert.Equal(int64, int64Value.Value); Assert.Equal(int64, Int64Value.ToInt64(int64Value)); // 11. IntegerValue IntegerValue integerValue = new IntegerValue(); int integer = 64; integerValue = integer; Assert.True(integer == integerValue); integer = 17; integerValue = IntegerValue.FromInt64(integer); Assert.Equal(integer, integerValue.Value); Assert.Equal(integer, IntegerValue.ToInt64(integerValue)); // 12. OnOffValue OnOffValue onOffValue = new OnOffValue(); onOffValue = true; Assert.True(onOffValue); onOffValue = OnOffValue.FromBoolean(false); Assert.Equal(false, onOffValue.Value); Assert.Equal(false, OnOffValue.ToBoolean(onOffValue)); // 13. SByteValue SByteValue sbyteValue = new SByteValue(); SByte sbt = SByte.MaxValue; sbyteValue = sbt; Assert.True(sbt == sbyteValue); sbt = SByte.MinValue; sbyteValue = SByteValue.FromSByte(sbt); Assert.Equal(sbt, sbyteValue.Value); Assert.Equal(sbt, SByteValue.ToSByte(sbt)); // 14. SingleValue SingleValue singleValue = new SingleValue(); Single single = Single.MaxValue; singleValue = single; Assert.True(single == singleValue); single = Single.NaN; singleValue = SingleValue.FromSingle(single); Assert.Equal(single, singleValue.Value); Assert.Equal(single, SingleValue.ToSingle(singleValue)); // 15. StringValue StringValue stringValue = new StringValue(); String str = "Ethan"; stringValue = str; Assert.True(str == stringValue); str = "Yin"; stringValue = StringValue.FromString(str); Assert.Equal(str, stringValue.Value); Assert.Equal(str, stringValue.ToString()); Assert.Equal(str, StringValue.ToString(stringValue)); // 16. TrueFalseBlankValue TrueFalseBlankValue tfbValue = new TrueFalseBlankValue(); tfbValue = true; Assert.True(tfbValue); tfbValue = TrueFalseBlankValue.FromBoolean(false); Assert.Equal(false, tfbValue.Value); Assert.Equal(false, TrueFalseBlankValue.ToBoolean(tfbValue)); // 17. TrueFalseValue TrueFalseValue tfValue = new TrueFalseValue(); tfValue = true; Assert.True(tfValue); tfValue = TrueFalseValue.FromBoolean(false); Assert.Equal(false, tfValue.Value); Assert.Equal(false, TrueFalseValue.ToBoolean(tfValue)); // 18. UInt16Value UInt16Value uint16Value = new UInt16Value(); UInt16 uint16 = UInt16.MaxValue; uint16Value = uint16; Assert.True(uint16 == uint16Value); uint16 = UInt16.MinValue; uint16Value = UInt16Value.FromUInt16(uint16); Assert.Equal(uint16, uint16Value.Value); Assert.Equal(uint16, UInt16Value.ToUInt16(uint16Value)); // 19. UInt32Value UInt32Value uint32Value = new UInt32Value(); UInt32 uint32 = UInt32.MaxValue; uint32Value = uint32; Assert.True(uint32 == uint32Value); uint32 = UInt32.MinValue; uint32Value = UInt32Value.FromUInt32(uint32); Assert.Equal(uint32, uint32Value.Value); Assert.Equal(uint32, UInt32Value.ToUInt32(uint32Value)); // 20. UInt64Value UInt64Value uint64Value = new UInt64Value(); UInt64 uint64 = UInt64.MaxValue; uint64Value = uint64; Assert.True(uint64 == uint64Value); uint64 = UInt64.MinValue; uint64Value = UInt64Value.FromUInt64(uint64); Assert.Equal(uint64, uint64Value.Value); Assert.Equal(uint64, UInt64Value.ToUInt64(uint64Value)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldEncodeArrays() public virtual void ShouldEncodeArrays() { AssertEncoding("D1.0|2.0|3.0|", new int[] { 1, 2, 3 }); AssertEncoding("Ztrue|false|", new bool[] { true, false }); AssertEncoding("LYWxp|YXJl|eW91|b2s=|", new string[] { "ali", "are", "you", "ok" }); AssertEncoding("", new string[] {}); AssertEncoding("P1:4326:1.234;2.567|1:4326:2.345;5.678|2:9157:3.0;4.0;5.0|", new Point[] { Values.pointValue(CoordinateReferenceSystem.WGS84, 1.234, 2.567), Values.pointValue(CoordinateReferenceSystem.WGS84, 2.345, 5.678), Values.pointValue(CoordinateReferenceSystem.Cartesian_3D, 3, 4, 5) }); AssertEncoding("T1991-03-05|1992-04-06|", new LocalDate[] { DateValue.date(1991, 3, 5).asObjectCopy(), DateValue.date(1992, 4, 6).asObjectCopy() }); AssertEncoding("T12:45:13.000008676|05:04:50.000000076|", new LocalTime[] { LocalTimeValue.localTime(12, 45, 13, 8676).asObjectCopy(), LocalTimeValue.localTime(5, 4, 50, 76).asObjectCopy() }); AssertEncoding("T1991-03-05T12:45:13.000008676|1992-04-06T05:04:50.000000076|", new DateTime[] { LocalDateTimeValue.localDateTime(1991, 3, 5, 12, 45, 13, 8676).asObjectCopy(), LocalDateTimeValue.localDateTime(1992, 4, 6, 5, 4, 50, 76).asObjectCopy() }); AssertEncoding("T02:45:13.000008676Z|01:05:00.0000003+01:00|05:04:50.000000076+05:00|", new OffsetTime[] { TimeValue.time(2, 45, 13, 8676, UTC).asObjectCopy(), TimeValue.time(OffsetTime.ofInstant(Instant.ofEpochSecond(300, 300), ZoneId.of("Europe/Stockholm"))).asObjectCopy(), TimeValue.time(5, 4, 50, 76, "+05:00").asObjectCopy() }); AssertEncoding("T1991-03-05T02:45:13.000008676Z|1991-03-05T02:45:13.000008676+01:00[Europe/Stockholm]|1992-04-06T05:04:50.000000076+05:00|", new ZonedDateTime[] { DateTimeValue.datetime(1991, 3, 5, 2, 45, 13, 8676, UTC).asObjectCopy(), DateTimeValue.datetime(1991, 3, 5, 2, 45, 13, 8676, ZoneId.of("Europe/Stockholm")).asObjectCopy(), DateTimeValue.datetime(1992, 4, 6, 5, 4, 50, 76, "+05:00").asObjectCopy() }); AssertEncoding("AP165Y11M3DT5.000000012S|P166Y4DT6.000000005S|", new TemporalAmount[] { DurationValue.duration(1991, 3, 5, 12).asObjectCopy(), DurationValue.duration(1992, 4, 6, 5).asObjectCopy() }); }
void IValueVisitor.Visit(DateTimeValue attr) { WriteString(attr.Value?.ToString(DateTimeValue.Format)); }
public void DateTimeValue_SetDateTimeOffset_Null() { DateTimeValue value = (DateTimeOffset?)null; Assert.Equal(default, value);
public object ChangeType_DateTime() { return(DateTimeValue.ChangeType(typeof(DateTime), CultureInfo.InvariantCulture)); }
/// <summary> /// 解析time型数据的定义 /// </summary> private static bool _AnalyzeTimeType(FieldInfo fieldInfo, TableInfo tableInfo, DataTable dt, int columnIndex, FieldInfo parentField, out int nextFieldColumnIndex, out string errorString) { //const string DefineTimeStartString = "time";// DEFINE_START_STRING // 定义time型输入导出格式的key //const string TimeInputParamKey = "input";// INPUT_PARAM_KEY // const string TimeToExportParamKey = "toLua";// TO_LUA_PARAM_KEY // const string TimeToExportParamKey = "toDatabase";// TO_DATABASE_PARAM_KEY // 解析time型输入导出格式的声明 if (!DateTimeValue.DefineTimeStartString.Equals(fieldInfo.DataTypeString, StringComparison.CurrentCultureIgnoreCase)) { int leftBracketIndex = fieldInfo.DataTypeString.IndexOf('('); int rightBracketIndex = fieldInfo.DataTypeString.LastIndexOf(')'); if (leftBracketIndex == -1 && rightBracketIndex == -1) { errorString = "time型格式定义错误"; nextFieldColumnIndex = columnIndex + 1; return(false); } if (!(leftBracketIndex != -1 || rightBracketIndex > leftBracketIndex)) { errorString = "time型格式定义错误,括号不匹配"; nextFieldColumnIndex = columnIndex + 1; return(false); } // 解析声明的时间格式 string defineString = fieldInfo.DataTypeString.Substring(leftBracketIndex + 1, rightBracketIndex - leftBracketIndex - 1).Trim(); if (string.IsNullOrEmpty(defineString)) { errorString = "time型格式定义错误,若要声明时间格式就必须在括号中填写,否则不要加括号,本工具会采用config配置文件中设置的默认时间格式"; nextFieldColumnIndex = columnIndex + 1; return(false); } // 通过|分隔各个时间参数 string[] defineParams = defineString.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder paramDefineErrorStringBuilder = new StringBuilder(); const string ERROR_STRING_FORMAT = "配置项\"{0}\"设置的格式\"{1}\"错误:{2}\n"; foreach (string defineParam in defineParams) { // 通过=分隔参数项的key和value string[] paramKeyAndValue = defineParam.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); if (paramKeyAndValue.Length != 2) { paramDefineErrorStringBuilder.AppendFormat("配置参数\"{0}\"未正确用=分隔配置项的key和value\n", defineParam); continue; } string paramKey = paramKeyAndValue[0].Trim(); string paramValue = paramKeyAndValue[1].Trim(); errorString = null; if (!Enum.IsDefined(typeof(DateTimeTypeKey), paramKey)) { paramDefineErrorStringBuilder.AppendFormat("存在非法配置项key\"{0}\"\n", paramKey); } else if (TableCheckHelper.CheckTimeDefine(paramValue, out errorString) == true) { fieldInfo.ExtraParam[paramKey] = paramValue; } else { paramDefineErrorStringBuilder.AppendFormat(ERROR_STRING_FORMAT, paramKey, paramValue, errorString); } // switch (paramKey) // { // case DateTimeValue.TimeInputParamKey: // { // if (TableCheckHelper.CheckTimeDefine(paramValue, out errorString) == true) // fieldInfo.ExtraParam[DateTimeValue.TimeInputFormat] = paramValue; // else // paramDefineErrorStringBuilder.AppendFormat(ERROR_STRING_FORMAT, paramKey, paramValue, errorString); // break; // } // //case LuaStruct.TimeToExportParamKey: // // { // // if (TableCheckHelper.CheckTimeDefine(paramValue, out errorString) == true) // // fieldInfo.ExtraParam[LuaStruct.TimeToExportFormatKey] = paramValue; // // else // // paramDefineErrorStringBuilder.AppendFormat(ERROR_STRING_FORMAT, paramKey, paramValue, errorString); // // break; // // } // //case MySQLStruct.TimeToExportParamKey: // // { // // if (TableCheckHelper.CheckTimeDefine(paramValue, out errorString) == true) // // fieldInfo.ExtraParam[MySQLStruct.TimeToExportFormatKey] = paramValue; // // else // // paramDefineErrorStringBuilder.AppendFormat(ERROR_STRING_FORMAT, paramKey, paramValue, errorString); // // break; // // } // default: // { // paramDefineErrorStringBuilder.AppendFormat("存在非法配置项key\"{0}\"\n", paramKey); // break; // } // } } string paramDefineErrorString = paramDefineErrorStringBuilder.ToString(); if (!string.IsNullOrEmpty(paramDefineErrorString)) { errorString = string.Format("time型格式定义存在以下错误:\n{0}", paramDefineErrorString); nextFieldColumnIndex = columnIndex + 1; return(false); } } // 检查time型输入格式、导出至lua文件格式、导出至MySQL数据库格式是否都已声明,没有则分别采用config文件的默认设置 if (!fieldInfo.ExtraParam.ContainsKey(DateTimeTypeKey.input.ToString())) { fieldInfo.ExtraParam[DateTimeTypeKey.input.ToString()] = DateTimeValue.DefaultTimeInputFormat; } if (!fieldInfo.ExtraParam.ContainsKey(DateTimeTypeKey.toLua.ToString())) { fieldInfo.ExtraParam[DateTimeTypeKey.toLua.ToString()] = DateTimeValue.DefaultTimeInputFormat; } if (!fieldInfo.ExtraParam.ContainsKey(DateTimeTypeKey.toJson.ToString())) { fieldInfo.ExtraParam[DateTimeTypeKey.toJson.ToString()] = DateTimeValue.DefaultTimeInputFormat; } if (!fieldInfo.ExtraParam.ContainsKey(DateTimeTypeKey.toErlang.ToString())) { fieldInfo.ExtraParam[DateTimeTypeKey.toErlang.ToString()] = DateTimeValue.DefaultTimeInputFormat; } if (!fieldInfo.ExtraParam.ContainsKey(DateTimeTypeKey.toServerJson.ToString())) { fieldInfo.ExtraParam[DateTimeTypeKey.toServerJson.ToString()] = DateTimeValue.DefaultTimeInputFormat; } if (!fieldInfo.ExtraParam.ContainsKey(DateTimeTypeKey.toMySQL.ToString())) { fieldInfo.ExtraParam[DateTimeTypeKey.toMySQL.ToString()] = DateTimeValue.DefaultTimeInputFormat; } if (!fieldInfo.ExtraParam.ContainsKey(DateTimeTypeKey.toSQLITE.ToString())) { fieldInfo.ExtraParam[DateTimeTypeKey.toSQLITE.ToString()] = DateTimeValue.DefaultTimeInputFormat; } if (!fieldInfo.ExtraParam.ContainsKey(DateTimeTypeKey.toTxt.ToString())) { fieldInfo.ExtraParam[DateTimeTypeKey.toTxt.ToString()] = DateTimeValue.DefaultTimeInputFormat; } TimeFormatType timeFormatType = DateTimeValue.GetTimeFormatType((string)fieldInfo.ExtraParam[DateTimeTypeKey.input.ToString()]); fieldInfo.Data = new List <object>(); // 记录非法数据的行号以及数据值(key:行号, value:数据值) Dictionary <int, object> invalidInfo = new Dictionary <int, object>(); if (timeFormatType == TimeFormatType.FormatString) { // 用于对时间格式进行转换 DateTimeFormatInfo dateTimeFormat = new DateTimeFormatInfo(); dateTimeFormat.ShortTimePattern = (string)fieldInfo.ExtraParam[DateTimeTypeKey.input.ToString()]; for (int row = ExcelTableSetting.DataFieldDataStartRowIndex; row < dt.Rows.Count; ++row) { // 如果本行该字段的父元素标记为无效则该数据也标为无效 if (parentField != null && (bool)parentField.Data[row - ExcelTableSetting.DataFieldDataStartRowIndex] == false) { fieldInfo.Data.Add(null); } else { string inputData = dt.Rows[row][columnIndex].ToString().Trim(); // 忽略未填写的数据 if (string.IsNullOrEmpty(inputData)) { fieldInfo.Data.Add(null); } else { try { // 此函数会将DateTime的日期部分自动赋值为当前时间 DateTime tempDateTime = Convert.ToDateTime(inputData, dateTimeFormat); fieldInfo.Data.Add(new DateTime(DateTimeValue.REFERENCE_DATE.Year, DateTimeValue.REFERENCE_DATE.Month, DateTimeValue.REFERENCE_DATE.Day, tempDateTime.Hour, tempDateTime.Minute, tempDateTime.Second)); } catch { invalidInfo.Add(row, inputData); } } } } } else if (timeFormatType == TimeFormatType.ReferenceTimeSec) { for (int row = ExcelTableSetting.DataFieldDataStartRowIndex; row < dt.Rows.Count; ++row) { // 如果本行该字段的父元素标记为无效则该数据也标为无效 if (parentField != null && (bool)parentField.Data[row - ExcelTableSetting.DataFieldDataStartRowIndex] == false) { fieldInfo.Data.Add(null); } else { string inputData = dt.Rows[row][columnIndex].ToString().Trim(); uint inputIntValue = 0; if (string.IsNullOrEmpty(inputData)) { fieldInfo.Data.Add(null); } else if (uint.TryParse(inputData, out inputIntValue) == false) { invalidInfo.Add(row, inputData); } else { if (inputIntValue >= 86400) { invalidInfo.Add(row, inputData); } else { int hour = (int)inputIntValue / 60 / 60; int remainingSecond = (int)inputIntValue - hour * 60 * 60; int minute = remainingSecond / 60; remainingSecond = remainingSecond - minute * 60; DateTime dateTime = new DateTime(DateTimeValue.REFERENCE_DATE.Year, DateTimeValue.REFERENCE_DATE.Month, DateTimeValue.REFERENCE_DATE.Day, hour, minute, remainingSecond); fieldInfo.Data.Add(dateTime); } } } } } else { errorString = "错误:用_AnalyzeTimeType函数处理非法的TimeFormatType类型"; AppLog.LogErrorAndExit(errorString); nextFieldColumnIndex = columnIndex + 1; return(false); } if (invalidInfo.Count > 0) { StringBuilder invalidDataInfo = new StringBuilder(); invalidDataInfo.AppendFormat("以下行中的数据无法按指定的输入格式({0})进行读取\n", fieldInfo.ExtraParam[DateTimeTypeKey.input.ToString()]); foreach (var item in invalidInfo) { invalidDataInfo.AppendFormat("第{0}行,错误地填写数据为\"{1}\"\n", item.Key + 1, item.Value); } errorString = invalidDataInfo.ToString(); nextFieldColumnIndex = columnIndex + 1; return(false); } else { errorString = null; nextFieldColumnIndex = columnIndex + 1; return(true); } }
private static DataValue ConvertDateTime(DateTimeValue src, DataType dataType) { switch (dataType) { case DataType.DataType_String: return new StringValue(src.DateTime.ToString()); default: return null; } }
private IStringConvertibleValue CreateStringConvertibleValue(int columnIndex) { IStringConvertibleValue value; if (Content.ConstrainedValue.VariableHasType<double>(columnIndex)) { value = new DoubleValue(); } else if (Content.ConstrainedValue.VariableHasType<String>(columnIndex)) { value = new StringValue(); } else if (Content.ConstrainedValue.VariableHasType<DateTime>(columnIndex)) { value = new DateTimeValue(); } else { throw new ArgumentException("unsupported type"); } return value; }
internal DateTimeImmutable(DateTimeValue value) { _value = value; }
internal DateTimeImmutable(System_DateTime datetime, TimeZoneInfo tz) { _value = new DateTimeValue(datetime, tz); }
public void __construct(Context ctx, string?datetime = DateTimeValue.Now, DateTimeZone?timezone = null) { _value = DateTimeValue.Parse(ctx, datetime ?? string.Empty, timezone?._timezone); }
internal static OpenXmlSimpleType[] CreatePossibleMembers(UnionValueRestriction unionValueRestriction) { OpenXmlSimpleType[] simpleValues = new OpenXmlSimpleType[unionValueRestriction.UnionTypes.Length]; switch (unionValueRestriction.UnionId) { // ST_AnimationDgmBuildType case 25: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationBuildValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationDiagramOnlyBuildValues>(); break; // ST_AnimationChartBuildType case 27: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationBuildValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.AnimationChartOnlyBuildValues>(); break; // ST_AdjCoordinate case 45: simpleValues[0] = new Int64Value(); simpleValues[1] = new StringValue(); break; // ST_AdjAngle case 46: simpleValues[0] = new Int32Value(); simpleValues[1] = new StringValue(); break; // ST_LayoutShapeType case 145: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.ShapeTypeValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.OutputShapeValues>(); break; // ST_ParameterVal case 183: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.HorizontalAlignmentValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.VerticalAlignmentValues>(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ChildDirectionValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ChildAlignmentValues>(); simpleValues[4] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryChildAlignmentValues>(); simpleValues[5] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.LinearDirectionValues>(); simpleValues[6] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.SecondaryLinearDirectionValues>(); simpleValues[7] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.StartingElementValues>(); simpleValues[8] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.BendPointValues>(); simpleValues[9] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorRoutingValues>(); simpleValues[10] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ArrowheadStyleValues>(); simpleValues[11] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorDimensionValues>(); simpleValues[12] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.RotationPathValues>(); simpleValues[13] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.CenterShapeMappingValues>(); simpleValues[14] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.NodeHorizontalAlignmentValues>(); simpleValues[15] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.NodeVerticalAlignmentValues>(); simpleValues[16] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.FallbackDimensionValues>(); simpleValues[17] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextDirectionValues>(); simpleValues[18] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentPositionValues>(); simpleValues[19] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.PyramidAccentTextMarginValues>(); simpleValues[20] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextBlockDirectionValues>(); simpleValues[21] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorHorizontalValues>(); simpleValues[22] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextAnchorVerticalValues>(); simpleValues[23] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.TextAlignmentValues>(); simpleValues[24] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.AutoTextRotationValues>(); simpleValues[25] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.GrowDirectionValues>(); simpleValues[26] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.FlowDirectionValues>(); simpleValues[27] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ContinueDirectionValues>(); simpleValues[28] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.BreakpointValues>(); simpleValues[29] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.OffsetValues>(); simpleValues[30] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyAlignmentValues>(); simpleValues[31] = new Int32Value(); simpleValues[32] = new DoubleValue(); simpleValues[33] = new BooleanValue(); simpleValues[34] = new StringValue(); simpleValues[35] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ConnectorPointValues>(); break; // ST_ModelId case 184: simpleValues[0] = new Int32Value(); simpleValues[1] = new StringValue(); break; // ST_FunctionValue case 207: simpleValues[0] = new Int32Value(); simpleValues[1] = new BooleanValue(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.DirectionValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.HierarchyBranchStyleValues>(); simpleValues[4] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.AnimateOneByOneValues>(); simpleValues[5] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.AnimationLevelStringValues>(); simpleValues[6] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.ResizeHandlesStringValues>(); break; // ST_FunctionArgument case 209: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Drawing.Diagrams.VariableValues>(); break; // ST_NonZeroDecimalNumber case 368: simpleValues[0] = new Int32Value(); simpleValues[1] = new Int32Value(); break; // ST_MarkupId case 375: simpleValues[0] = new Int32Value(); simpleValues[1] = new Int32Value(); break; // ST_HexColor case 404: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Wordprocessing.AutomaticColorValues>(); simpleValues[1] = new HexBinaryValue(); break; // ST_DecimalNumberOrPercent case 507: simpleValues[0] = new StringValue(); simpleValues[1] = new Int32Value(); break; // ST_SignedHpsMeasure_O14 case 525: simpleValues[0] = new IntegerValue(); simpleValues[1] = new StringValue(); break; // ST_HpsMeasure_O14 case 528: simpleValues[0] = new UInt32Value(); simpleValues[1] = new StringValue(); break; // ST_SignedTwipsMeasure_O14 case 531: simpleValues[0] = new IntegerValue(); simpleValues[1] = new StringValue(); break; // ST_TwipsMeasure_O14 case 534: simpleValues[0] = new UInt32Value(); simpleValues[1] = new StringValue(); break; // ST_TransitionEightDirectionType case 544: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Presentation.TransitionSlideDirectionValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.TransitionCornerDirectionValues>(); break; // ST_TLTimeAnimateValueTime case 561: simpleValues[0] = new Int32Value(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_TLTime_O12 case 603: simpleValues[0] = new UInt32Value(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_TLTime_O14 case 604: simpleValues[0] = new StringValue(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Presentation.IndefiniteTimeDeclarationValues>(); break; // ST_PublishDate case 689: simpleValues[0] = new DateTimeValue(); simpleValues[1] = new DateTimeValue(); simpleValues[2] = new StringValue(); break; // ST_ChannelDataPoint case 697: simpleValues[0] = new DecimalValue(); simpleValues[1] = new BooleanValue(); break; // ST_ChannelPropertyName case 701: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardChannelPropertyNameValues>(); simpleValues[1] = new StringValue(); break; // ST_BrushPropertyName case 704: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardBrushPropertyNameValues>(); simpleValues[1] = new StringValue(); break; // ST_ChannelName case 707: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardChannelNameValues>(); simpleValues[1] = new StringValue(); break; // ST_Units case 719: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardLengthUnitsValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerLengthUnitsValues>(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardTimeUnitsValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerTimeUnitsValues>(); simpleValues[4] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardMassForceUnitsValues>(); simpleValues[5] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerMassForceUnitsValues>(); simpleValues[6] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardAngleUnitsValues>(); simpleValues[7] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerAngleUnitsValues>(); simpleValues[8] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardOtherUnitsValues>(); simpleValues[9] = new EnumValue <DocumentFormat.OpenXml.InkML.StandardPerOtherUnitsValues>(); simpleValues[10] = new StringValue(); break; // ST_BrushPropertyValue case 732: simpleValues[0] = new DecimalValue(); simpleValues[1] = new BooleanValue(); simpleValues[2] = new EnumValue <DocumentFormat.OpenXml.InkML.PenTipShapeValues>(); simpleValues[3] = new EnumValue <DocumentFormat.OpenXml.InkML.RasterOperationValues>(); simpleValues[4] = new StringValue(); break; // ST_Ref case 746: simpleValues[0] = new StringValue(); simpleValues[1] = new UInt32Value(); break; // ST_CtxNodeType case 747: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2010.Ink.KnownContextNodeTypeValues>(); simpleValues[1] = new StringValue(); break; // ST_SemanticType case 750: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2010.Ink.KnownSemanticTypeValues>(); simpleValues[1] = new UInt32Value(); break; // ST_PointsOrInt case 753: simpleValues[0] = new ListValue <StringValue>(); simpleValues[1] = new Int32Value(); break; // ST_TransitionCornerAndCenterDirectionType case 766: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Presentation.TransitionCornerDirectionValues>(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Office2010.PowerPoint.TransitionCenterDirectionTypeValues>(); break; // ST_ColorStyleMethod case 835: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.ColorStyleMethodEnum>(); simpleValues[1] = new StringValue(); break; // ST_StyleReferenceModifier case 837: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.StyleReferenceModifierEnum>(); simpleValues[1] = new StringValue(); break; // ST_StyleColorVal case 840: simpleValues[0] = new UInt32Value(); simpleValues[1] = new EnumValue <DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.StyleColorEnum>(); simpleValues[2] = new StringValue(); break; // ST_StyleEntryModifier case 842: simpleValues[0] = new EnumValue <DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle.StyleEntryModifierEnum>(); simpleValues[1] = new StringValue(); break; default: Debug.Assert(false); break; } Debug.Assert(simpleValues.Length > 0); return(simpleValues); }
/// <summary> /// Adds a new DateTime value to the list of query parameters. /// </summary> /// <param name="key">The parameter name.</param> /// <param name="value">The parameter value.</param> /// <returns>The statement builder, for chaining method calls.</returns> public StatementBuilder AddValue(string key, DateTime value) { DateTimeValue queryValue = new DateTimeValue(); queryValue.value = value; return AddValue(key, queryValue); }
protected override void SetDateTimeField(DateTimeValue value) { App.Client.SetValueFix(LogicalName, value.Value, value.DateOnly, GlobalTestingContext.ConnectionManager.CurrentConnection.UserSettings.DateFormat, GlobalTestingContext.ConnectionManager.CurrentConnection.UserSettings.TimeFormat); }
/// <summary> /// Gets the values. /// </summary> /// <returns></returns> public Dictionary<string, ValueExpression> GetValues() { Dictionary<string, ValueExpression> values = new Dictionary<string, ValueExpression>(); foreach (DataGridViewRow row in grdProperties.Rows) { string name = row.Cells[0].Value.ToString(); PropertyDefinition propDef = row.Cells[0].Tag as PropertyDefinition; if (row.Cells[1].Value != null) { string str = row.Cells[1].Value.ToString(); if (!string.IsNullOrEmpty(str)) { ValueExpression expr = null; if (propDef.PropertyType == PropertyType.PropertyType_DataProperty) { DataPropertyDefinition dp = propDef as DataPropertyDefinition; switch (dp.DataType) { case DataType.DataType_Boolean: expr = new BooleanValue(Convert.ToBoolean(str)); break; case DataType.DataType_Byte: expr = new ByteValue(Convert.ToByte(str)); break; case DataType.DataType_DateTime: expr = new DateTimeValue(Convert.ToDateTime(str)); break; case DataType.DataType_Decimal: expr = new DecimalValue(Convert.ToDouble(str)); break; case DataType.DataType_Double: expr = new DoubleValue(Convert.ToDouble(str)); break; case DataType.DataType_Int16: expr = new Int16Value(Convert.ToInt16(str)); break; case DataType.DataType_Int32: expr = new Int32Value(Convert.ToInt32(str)); break; case DataType.DataType_Int64: expr = new Int64Value(Convert.ToInt64(str)); break; case DataType.DataType_Single: expr = new SingleValue(Convert.ToSingle(str)); break; case DataType.DataType_String: expr = new StringValue(str); break; default: throw new NotSupportedException("Unsupported data type: " + dp.DataType); } } else if (propDef.PropertyType == PropertyType.PropertyType_GeometricProperty) { FdoGeometryFactory fact = FdoGeometryFactory.Instance; OSGeo.FDO.Geometry.IGeometry geom = fact.CreateGeometry(str); byte[] fgf = fact.GetFgf(geom); expr = new GeometryValue(fgf); geom.Dispose(); } if (expr != null) values.Add(name, expr); } } } return values; }
protected abstract void SetDateTimeField(DateTimeValue value);
//Генерация случайного значения для всех ячеек, кроме ячеек заголовка public Value GetRandomValue(int cellIndex) { var type = randomTypeList[cellIndex]; //Получения типа из листа случайных типов //Создание значения соответствующего типа switch (type) { case ConverteType.String: //Создание значения типа String var stringValue = new Value<string>(); stringValue.OriginalValue = GetRandomString(); //Получение случайного значения string return stringValue; case ConverteType.Date: //Создание значения типа Date var dateValue = new DateTimeValue(); dateValue.OriginalValue = GetRandomDate(); //Получение случайного значения Datetime return dateValue; case ConverteType.Integer: //Создание значения типа Integer var integerValue = new Value<int>(); integerValue.OriginalValue = GetRandomInt(); //Получение случайной значения Integer return integerValue; case ConverteType.Float: //Создание значения типа Float var floatValue = new FloatValue(); floatValue.OriginalValue = GetRandomFloat(); //Получение случайной значения Float return floatValue; default: //Switch должен вернуть значение Debug.Fail(String.Format("Illegal value {0}", type)); Environment.FailFast(null); return new Value<string>(); } }
public LocalNativeRecord(MgReader reader, FixedWKTReader mgReader, MgAgfReaderWriter agfRw, MgWktReaderWriter wktRw) { for (int i = 0; i < reader.GetPropertyCount(); i++) { string name = reader.GetPropertyName(i); _ordinalMap[i] = name; var pt = (PropertyValueType)reader.GetPropertyType(name); switch (pt) { case PropertyValueType.Blob: _values[name] = new BlobValue(); break; case PropertyValueType.Boolean: _values[name] = new BooleanValue(); break; case PropertyValueType.Byte: _values[name] = new ByteValue(); break; case PropertyValueType.Clob: _values[name] = new ClobValue(); break; case PropertyValueType.DateTime: _values[name] = new DateTimeValue(); break; case PropertyValueType.Double: _values[name] = new DoubleValue(); break; case PropertyValueType.Feature: _values[name] = new FeatureValue(); break; case PropertyValueType.Geometry: _values[name] = new GeometryValue(); break; case PropertyValueType.Int16: _values[name] = new Int16Value(); break; case PropertyValueType.Int32: _values[name] = new Int32Value(); break; case PropertyValueType.Int64: _values[name] = new Int64Value(); break; case PropertyValueType.Raster: _values[name] = new RasterValue(); break; case PropertyValueType.Single: _values[name] = new SingleValue(); break; case PropertyValueType.String: _values[name] = new StringValue(); break; } } for (int i = 0; i < reader.GetPropertyCount(); i++) { string name = _ordinalMap[i]; GetByteReaderMethod getblob = () => { return reader.GetBLOB(name); }; GetByteReaderMethod getclob = () => { return reader.GetCLOB(name); }; GetByteReaderMethod getgeom = () => { return reader.GetGeometry(name); }; if (!reader.IsNull(name)) { var pt = (PropertyValueType)reader.GetPropertyType(name); switch (pt) { case PropertyValueType.Blob: ((BlobValue)_values[name]).Value = Utility.StreamAsArray(new MgReadOnlyStream(getblob)); break; case PropertyValueType.Boolean: ((BooleanValue)_values[name]).Value = reader.GetBoolean(name); break; case PropertyValueType.Byte: ((ByteValue)_values[name]).Value = reader.GetByte(name); break; case PropertyValueType.Clob: byte [] b = Utility.StreamAsArray(new MgReadOnlyStream(getclob)); ((ClobValue)_values[name]).Value = Encoding.UTF8.GetChars(b); break; case PropertyValueType.DateTime: ((DateTimeValue)_values[name]).Value = Utility.ConvertMgDateTime(reader.GetDateTime(name)); break; case PropertyValueType.Double: ((DoubleValue)_values[name]).Value = reader.GetDouble(name); break; //case PropertyValueType.Feature: case PropertyValueType.Geometry: try { //TODO: See if SWIG issues come into play here var geom = agfRw.Read(reader.GetGeometry(name)); var wkt = wktRw.Write(geom); ((GeometryValue)_values[name]).Value = mgReader.Read(wkt); } catch //Invalid geometry fail! { ((GeometryValue)_values[name]).SetNull(); } break; case PropertyValueType.Int16: ((Int16Value)_values[name]).Value = reader.GetInt16(name); break; case PropertyValueType.Int32: ((Int32Value)_values[name]).Value = reader.GetInt32(name); break; case PropertyValueType.Int64: ((Int64Value)_values[name]).Value = reader.GetInt64(name); break; case PropertyValueType.Single: ((SingleValue)_values[name]).Value = reader.GetSingle(name); break; case PropertyValueType.String: ((StringValue)_values[name]).Value = reader.GetString(name); break; } } } }
private void Prepare(PropertyValueCollection propVals) { propVals.Clear(); currentValues.Clear(); // I do not trust the long-term stability of the PropertyValueCollection // // So what we do is load it up once with LiteralValue references and manipulate these // outside of the collection (via a cached dictionary). We cache everything from the wrapper API // that can be cached in the managed world so that we only have minimal contact with it // Omit read-only properties using (FdoFeatureService service = _conn.CreateFeatureService()) { ClassDefinition c = service.GetClassByName(this.ClassName); foreach (PropertyDefinition p in c.Properties) { string name = p.Name; PropertyValue pv = new PropertyValue(name, null); if (p.PropertyType == PropertyType.PropertyType_DataProperty) { DataPropertyDefinition d = p as DataPropertyDefinition; if (!d.ReadOnly && !d.IsAutoGenerated) { DataValue dv = null; switch (d.DataType) { case DataType.DataType_BLOB: dv = new BLOBValue(); break; case DataType.DataType_Boolean: dv = new BooleanValue(); break; case DataType.DataType_Byte: dv = new ByteValue(); break; case DataType.DataType_CLOB: dv = new CLOBValue(); break; case DataType.DataType_DateTime: dv = new DateTimeValue(); break; case DataType.DataType_Decimal: dv = new DecimalValue(); break; case DataType.DataType_Double: dv = new DoubleValue(); break; case DataType.DataType_Int16: dv = new Int16Value(); break; case DataType.DataType_Int32: dv = new Int32Value(); break; case DataType.DataType_Int64: dv = new Int64Value(); break; case DataType.DataType_Single: dv = new SingleValue(); break; case DataType.DataType_String: dv = new StringValue(); break; } if (dv != null) { pv.Value = dv; propVals.Add(pv); } } } else if (p.PropertyType == PropertyType.PropertyType_GeometricProperty) { GeometricPropertyDefinition g = p as GeometricPropertyDefinition; if (!g.ReadOnly) { GeometryValue gv = new GeometryValue(); pv.Value = gv; propVals.Add(pv); } } } c.Dispose(); } //Load property values into temp dictionary foreach (PropertyValue p in propVals) { currentValues[p.Name.Name] = p.Value as LiteralValue; } if (propertySnapshot == null) { propertySnapshot = new List<string>(); foreach (PropertyValue p in propVals) { propertySnapshot.Add(p.Name.Name); } } }
void IValueVisitor.Visit(DateTimeValue attr) { _value.Value = attr.Value?.ToString(DateTimeValue.Format); }