static Func <string, DataType> TryGetUnoTypeByNameFactory(IDataType type) { type = type.ActualIDataTypeImpl ?? type; var cField = type.GetType().GetField("_c", BindingFlags.NonPublic | BindingFlags.Instance); if (cField == null) // not available on deferred generic type etc { return(name => null); } var c = cField.GetValue(type) as CompilerDataTypeProvider; if (c == null) { throw new Exception("UXIL private field hack broke"); } var tryGetUnoTypeByNameMethod = c.GetType().GetMethod("TryGetUnoTypeByName", BindingFlags.NonPublic | BindingFlags.Instance); if (tryGetUnoTypeByNameMethod == null) { throw new Exception("UXIL private field hack broke"); } return(name => tryGetUnoTypeByNameMethod.Invoke(c, new object[] { name }) as DataType); }
/// <summary> /// Converts the datatype value to a DTG compatible string /// </summary> /// <param name="dataType">The DataType.</param> /// <returns></returns> public static string ToDtgString(IDataType dataType) { var value = dataType.Data.Value != null?dataType.Data.Value.ToString() : string.Empty; try { var assembly = Assembly.GetAssembly(dataType.GetType()); var type = assembly.GetType("Our.Umbraco.DataType.Markdown.XsltExtensions"); return((string)type.InvokeMember("Transform", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, new object[] { value })); } catch // (Exception ex) { return(value); // TODO: [LK->OA] Did you want to capture the exception? } }
/// <summary> /// Converts the datatype value to a DTG compatible string /// </summary> /// <param name="dataType">The DataType.</param> /// <returns></returns> public static string ToDtgString(IDataType dataType) { var value = dataType.Data.Value != null ? dataType.Data.Value.ToString() : string.Empty; try { var assembly = Assembly.GetAssembly(dataType.GetType()); var type = assembly.GetType("Our.Umbraco.DataType.Markdown.XsltExtensions"); return (string)type.InvokeMember("Transform", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, null, new object[] { value }); } catch // (Exception ex) { return value; // TODO: [LK->OA] Did you want to capture the exception? } }
protected override int InternalCompareTo(IDataType other) { if (other is null) { return(1); } else if (other is DateType dt) { return(Value.CompareTo(dt.Value)); } throw new InvalidCalcOperationException($"Can't compare a {GetType().Name} to a {other.GetType().Name}."); }
protected override int InternalCompareTo(IDataType other) { if (other is null) { return(1); } else if (other is FloatType dt1) { return(Value.CompareTo(new BigInteger(dt1.Value))); } else if (other is LimitedIntegerType dt2) { return(Value.CompareTo(dt2.Value)); } else if (other is TimespanType dt3) { return(Value.CompareTo(new BigInteger(dt3.Value.TotalSeconds))); } else if (other is TimeType dt4) { return(Value.CompareTo(new BigInteger(dt4.Value.TotalSeconds))); } else if (other is UnlimitedIntegerType dt5) { return(Value.CompareTo(dt5.Value)); } throw new InvalidCalcOperationException($"Can't compare a {GetType().Name} to a {other.GetType().Name}."); }