public IAnswerData cast(UncastData data) { System.DateTime ret = DateUtils.parseDate(data.value_Renamed); //UPGRADE_TODO: The 'System.DateTime' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" if (ret != null) { //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" return(new DateData(ref ret)); } throw new System.ArgumentException("Invalid cast of data [" + data.value_Renamed + "] to type Date"); }
public static IAnswerData getAnswerData(System.String text, int dataType, QuestionDef q) { System.String trimmedText = text.Trim(); if (trimmedText.Length == 0) { trimmedText = null; } switch (dataType) { case Constants.DATATYPE_NULL: case Constants.DATATYPE_UNSUPPORTED: case Constants.DATATYPE_TEXT: case Constants.DATATYPE_BARCODE: case Constants.DATATYPE_BINARY: return(new StringData(text)); case Constants.DATATYPE_INTEGER: try { return(trimmedText == null?null:new IntegerData(System.Int32.Parse(trimmedText))); } catch (System.FormatException nfe) { return(null); } goto case Constants.DATATYPE_LONG; case Constants.DATATYPE_LONG: try { return(trimmedText == null?null:new LongData(System.Int64.Parse(trimmedText))); } catch (System.FormatException nfe) { return(null); } goto case Constants.DATATYPE_DECIMAL; case Constants.DATATYPE_DECIMAL: try { return(trimmedText == null?null:new DecimalData(System.Double.Parse(trimmedText))); } catch (System.FormatException nfe) { return(null); } goto case Constants.DATATYPE_CHOICE; case Constants.DATATYPE_CHOICE: System.Collections.ArrayList selections = getSelections(text, q); return(selections.Count == 0?null:new SelectOneData((Selection)selections[0])); case Constants.DATATYPE_CHOICE_LIST: return(new SelectMultiData(getSelections(text, q))); case Constants.DATATYPE_DATE_TIME: //UPGRADE_TODO: The 'System.DateTime' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" System.DateTime dt = (trimmedText == null?null:DateUtils.parseDateTime(trimmedText)); //UPGRADE_TODO: The 'System.DateTime' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" return(dt == null?null:new DateTimeData(ref dt)); case Constants.DATATYPE_DATE: //UPGRADE_TODO: The 'System.DateTime' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" System.DateTime d = (trimmedText == null?null:DateUtils.parseDate(trimmedText)); //UPGRADE_TODO: The 'System.DateTime' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" return(d == null?null:new DateData(ref d)); case Constants.DATATYPE_TIME: //UPGRADE_TODO: The 'System.DateTime' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" System.DateTime t = (trimmedText == null?null:DateUtils.parseTime(trimmedText)); //UPGRADE_TODO: The 'System.DateTime' structure does not have an equivalent to NULL. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1291'" //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" return(t == null?null:new TimeData(ref t)); case Constants.DATATYPE_BOOLEAN: if (trimmedText == null) { return(null); } else { if (trimmedText.Equals("1")) { return(new BooleanData(true)); } if (trimmedText.Equals("0")) { return(new BooleanData(false)); } return(trimmedText.Equals("t")?new BooleanData(true):new BooleanData(false)); } goto case Constants.DATATYPE_GEOPOINT; case Constants.DATATYPE_GEOPOINT: if (trimmedText == null) { return(new GeoPointData()); } try { UncastData uncast = new UncastData(trimmedText); // silly... GeoPointData gp = new GeoPointData(); return(gp.cast(uncast)); } catch (System.Exception e) { return(null); } goto case Constants.DATATYPE_GEOSHAPE; case Constants.DATATYPE_GEOSHAPE: if (trimmedText == null) { return(new GeoShapeData()); } try { UncastData uncast = new UncastData(trimmedText); // silly... GeoShapeData gs = new GeoShapeData(); return(gs.cast(uncast)); } catch (System.Exception e) { return(null); } goto case Constants.DATATYPE_GEOTRACE; case Constants.DATATYPE_GEOTRACE: if (trimmedText == null) { return(new GeoTraceData()); } try { UncastData uncast = new UncastData(trimmedText); // silly... GeoTraceData gl = new GeoTraceData(); return(gl.cast(uncast)); } catch (System.Exception e) { return(null); } goto default; default: return(new UncastData(trimmedText)); } }