public ITPy Create( VariableCollection <IwIndexElement> value) { ITPy variable = null; try { variable = new TPy( value); } catch (Exception exception) { this.Log.Error( exception.Message, exception); } return(variable); }
public ITPy Create( ImmutableList <ITPyResultElement> value) { ITPy result = null; try { result = new TPy( value); } catch (Exception exception) { this.Log.Error( exception.Message, exception); } return(result); }
/// <summary> /// Tries to make sure <paramref name="x"/> and <paramref name="y"/> have the same type. /// </summary> /// <param name="x">First value.</param> /// <param name="y">Second value.</param> /// <returns>If <paramref name="x"/> and <paramref name="y"/> are of the same type after the call.</returns> public static bool TryMakeSameType(ref object x, ref object y) { Type xType = x.GetType(); Type yType = y.GetType(); if (xType == yType) { if (x is DateTime TPx && y is DateTime TPy && TPx.Kind != TPy.Kind) { x = TPx.ToLocalTime(); y = TPy.ToLocalTime(); } return(true); } uint xTypeCode = ObjectSerializer.GetFieldDataTypeCode(xType); uint yTypeCode = ObjectSerializer.GetFieldDataTypeCode(yType); Upgrade(ref x, ref xTypeCode); Upgrade(ref y, ref yTypeCode); if (xTypeCode == yTypeCode) { return(true); } if (xTypeCode == ObjectSerializer.TYPE_CI_STRING) { y = new CaseInsensitiveString(ToString(y, yTypeCode)); return(true); } else if (yTypeCode == ObjectSerializer.TYPE_CI_STRING) { x = new CaseInsensitiveString(ToString(x, xTypeCode)); return(true); } else if (yTypeCode == ObjectSerializer.TYPE_STRING) { x = ToString(x, xTypeCode); return(true); } switch (xTypeCode) { case ObjectSerializer.TYPE_DECIMAL: if (yTypeCode == ObjectSerializer.TYPE_DOUBLE) { y = (decimal)((double)y); return(true); } else { return(false); } case ObjectSerializer.TYPE_DOUBLE: if (yTypeCode == ObjectSerializer.TYPE_DECIMAL) { x = (decimal)((double)x); return(true); } else { return(false); } case ObjectSerializer.TYPE_STRING: y = ToString(y, yTypeCode); return(true); default: return(false); } }