This commit is contained in:
2025-12-18 15:55:53 +03:30
parent 573753d032
commit f7cef7f327
+14 -3
View File
@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using xCommons.Extensions; using xCommons.Extensions;
using xDataService.Models; using xDataService.Models;
@@ -69,12 +70,22 @@ namespace xDataService.Extensions
var parts = source.Split(splitter.Value); var parts = source.Split(splitter.Value);
if (parts.Count() >= 3) if (parts.Count() >= 3)
{ {
//
T referencedTo;
try
{
referencedTo = (T)Convert.ChangeType(parts[1], typeof(T));
} catch
{
referencedTo = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFrom(parts[1]);
}
// //
// Parse String Parts ... // Parse String Parts ...
result = new XReference<T> result = new XReference<T>
{ {
ReferencedTo = referencedTo,
Index = (int)Convert.ChangeType(parts[2], typeof(int)), Index = (int)Convert.ChangeType(parts[2], typeof(int)),
ReferencedTo = (T)Convert.ChangeType(parts[1], typeof(T)),
ProvidedFor = (string)Convert.ChangeType(parts[0], typeof(string)), ProvidedFor = (string)Convert.ChangeType(parts[0], typeof(string)),
}; };
} }
@@ -96,7 +107,7 @@ namespace xDataService.Extensions
var result = string.Empty; var result = string.Empty;
// //
if (source.IsNull() && source.HasChild()) if (!source.IsNull() && source.HasChild())
{ {
// //
var stringList = new List<string>(); var stringList = new List<string>();
@@ -147,7 +158,7 @@ namespace xDataService.Extensions
public static IList<XReference<T>> ParseXReferenceList<T>(this string source) public static IList<XReference<T>> ParseXReferenceList<T>(this string source)
{ {
// //
IList<XReference<T>> result = new List<XReference<T>>(); var result = new List<XReference<T>>();
// //
if (!source.IsNullOrEmpty()) if (!source.IsNullOrEmpty())