-
Notifications
You must be signed in to change notification settings - Fork 3
Legacy
The legacy layer supplies a COM+ layer required by the Tridion .NET templating engine for some of its legacy functionality.
For example while using the GetUsingItems and GetUsedItems functionality, the template engine still relies on the old Tridion COM+ layer to retrieve the required information.
Since the COM+ layer is not available, the results are emulated using the Tridion CoreService.
The Tridion.COM library exposes an ILegacyProvider interface which allows to supply a class to provide the Tridion legacy functionality.
/// <summary>
/// <see cref="ILegacyProvider" /> provides the means to implement Tridion legacy functionality
/// </summary>
/// <param name="legacyProvider"><see cref="ILegacyProvider" /></param>
[ComImport, Guid("44C1A000-AD24-46C9-B870-16D797E770DE")]
public interface ILegacyProvider
{
[DispId(1)]
Boolean HasUsingItems([In, MarshalAs(UnmanagedType.Interface)] UserContext userContext,
[In, MarshalAs(UnmanagedType.BStr)] String URI,
[In, MarshalAs(UnmanagedType.BStr)] String rowFilter);
[return: MarshalAs(UnmanagedType.BStr)]
[DispId(2)]
String GetUsingItems([In, MarshalAs(UnmanagedType.Interface)] UserContext userContext,
[In, MarshalAs(UnmanagedType.BStr)] String URI,
[In] ListColumnFilter columnFilter,
[In, MarshalAs(UnmanagedType.BStr)] String rowFilter);
[return: MarshalAs(UnmanagedType.BStr)]
[DispId(3)]
String GetUsedItems([In, MarshalAs(UnmanagedType.Interface)] UserContext userContext,
[In, MarshalAs(UnmanagedType.BStr)] String URI,
[In] ListColumnFilter columnFilter,
[In, MarshalAs(UnmanagedType.BStr)] String rowFilter);
}
Note: The ILegacyProvider is a COM interface which allows interfacing between the Tridion non-native legacy layer and native .NET code.
The ILegacyProvider is configured using the ILegacyInterface:
/// <summary>
/// <see cref="LegacyInterface" /> implements <see cref="I:ILegacyInterface" />
/// in order to configure the <see cref="ILegacyProvider" />
/// </summary>
[ComImport, Guid("C1C34A56-61D2-4BDB-A8AB-C273F5EAA165")]
public class LegacyInterface : ILegacyInterface
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(1)]
public virtual extern void SetProvider(ILegacyProvider legacyProvider);
}
// Initialize TcmDebugger.COM
legacyInterface = new LegacyInterface();
legacyInterface.SetProvider(new LegacyProvider());
....
Marshal.ReleaseComObject(legacyInterface);
TcmDebugger implements the LegacyProvider using the CoreSevice hosted at http://<cmshost>/webservices/CoreService2011.svc/wsHttp.
This allows Tridion templates to use the legacy calls and retrieve the desired results.