在Tridion 2011中,我希望使用与UpdateXml相当的Core Service以通用方式创建新的Tridion对象.我打算在文件夹和结构组上创建新的组件,页面和更高版本.它使用UpdateXml工作得很好,但我遇到了将RepositoryLocalObject(或另一个泛型类型对象)转换为ComponentData具有核心服务的对象的问题.我的核心服务代码更长(并且在第二代增长).
我尝试访问对象类型特定属性时出现错误消息:
错误9'Tridion.ContentManager.CoreService.Client.RepositoryLocalObjectData'不包含'Content'的定义,也没有扩展方法'Content'接受'Tridion.ContentManager.CoreService.Client.RepositoryLocalObjectData'类型的第一个参数
可能的解决方案是创建扩展方法吗?
Tridion TOM API:
Function CreateNewItemCopy(organizationalItemUri, itemType, title, xml,
directory, filename)
Dim newItem : set newItem = tdse.GetNewObject(itemType, organizationalItemUri)
newItem.UpdateXml(xml)
newItem.Title = title
if(itemType = 64) then ' page
newItem.FileName = filename
elseif(itemType = 4) then ' sg
newItem.Directory = directory
end if
newItem.save(true)
CreateNewItemCopy = newItem.id
set newItem = nothing
End Function
Run Code Online (Sandbox Code Playgroud)
Tridion 2011核心服务
*根据以下优秀答案更新代码
private ItemType GetTridionItemType(RepositoryLocalObjectData source)
{
string itemType = source.GetType().Name;
switch (itemType)
{
case "ComponentData": …Run Code Online (Sandbox Code Playgroud) tridion ×1