Added data type detection for MNTP/CSV to return List<int> and fix for NodeById/MediaById to handle List<int> correctly
This commit is contained in:
@@ -24,6 +24,7 @@ namespace umbraco.MacroEngines
|
||||
// these are private readonlys as const can't be Guids
|
||||
private readonly Guid DATATYPE_YESNO_GUID = new Guid("38b352c1-e9f8-4fd8-9324-9a2eab06d97a");
|
||||
private readonly Guid DATATYPE_TINYMCE_GUID = new Guid("5e9b75ae-face-41c8-b47e-5f4b0fd82f83");
|
||||
private readonly Guid DATATYPE_UCOMPONENTS_MNTP_GUID = new Guid("c2d6894b-e788-4425-bcf2-308568e3d38b");
|
||||
#endregion
|
||||
|
||||
internal DynamicNodeList ownerList;
|
||||
@@ -329,6 +330,18 @@ namespace umbraco.MacroEngines
|
||||
return true;
|
||||
}
|
||||
|
||||
//MNTP List<int>
|
||||
if (dataType == DATATYPE_UCOMPONENTS_MNTP_GUID)
|
||||
{
|
||||
string sResult = string.Format("{0}", result);
|
||||
//csv mode
|
||||
if (!sResult.Contains("<"))
|
||||
{
|
||||
result = sResult.Split(',').Select(id => int.Parse(id)).ToList();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//decimal
|
||||
decimal dResult = 0;
|
||||
if (decimal.TryParse(string.Format("{0}", result).Replace(",", "."), out dResult))
|
||||
@@ -723,6 +736,13 @@ namespace umbraco.MacroEngines
|
||||
nodes.Add(new DynamicNode(eachId));
|
||||
return new DynamicNodeList(nodes);
|
||||
}
|
||||
public DynamicNodeList NodeById(List<int> Ids)
|
||||
{
|
||||
List<DynamicNode> nodes = new List<DynamicNode>();
|
||||
foreach (int eachId in Ids)
|
||||
nodes.Add(new DynamicNode(eachId));
|
||||
return new DynamicNodeList(nodes);
|
||||
}
|
||||
public DynamicNodeList NodeById(params object[] Ids)
|
||||
{
|
||||
return NodeById(Ids.ToList());
|
||||
@@ -746,6 +766,13 @@ namespace umbraco.MacroEngines
|
||||
nodes.Add(new DynamicMedia(eachId));
|
||||
return new DynamicMediaList(nodes);
|
||||
}
|
||||
public DynamicMediaList MediaById(List<int> Ids)
|
||||
{
|
||||
List<DynamicMedia> nodes = new List<DynamicMedia>();
|
||||
foreach (int eachId in Ids)
|
||||
nodes.Add(new DynamicMedia(eachId));
|
||||
return new DynamicMediaList(nodes);
|
||||
}
|
||||
public DynamicMediaList MediaById(params object[] Ids)
|
||||
{
|
||||
return MediaById(Ids.ToList());
|
||||
|
||||
Reference in New Issue
Block a user