Hi,
I have not done it myself but i was told it can be done trough the Authoring assemblies.
Below is sample code that might direct you in the correct direction.
using (AuthoringType instance = this.GetAuthoringInstanceFromDefinition(def))
using (var cloningcontext = new SourceCode.Framework.CloningContext())
using (AuthoringType clone = instance.CloneInContext<AuthoringType>(cloningcontext, Guid.NewGuid()))
{
//do something with the clone.. Deploy or checkin of whatever.
}
private AuthoringType GetAuthoringInstanceFromDefinition(string xml)
{
try
{
if (typeof(AuthoringType).IsAssignableFrom(typeof(SourceCode.Forms.Authoring.Form)))
return SourceCode.Forms.Design.DefinitionUtility.LoadForm(_formsSessionData.SessionConnection, xml).TryConvert<AuthoringType>();
if (typeof(AuthoringType).IsAssignableFrom(typeof(SourceCode.Forms.Authoring.View)))
return SourceCode.Forms.Design.DefinitionUtility.LoadView(_formsSessionData.SessionConnection, xml).TryConvert<AuthoringType>();
}
catch
{
//swallow to allow direct load from Authoring API
}
if (typeof(AuthoringType).IsAssignableFrom(typeof(SourceCode.Forms.Authoring.IXmlSerializableObject)))
{
AuthoringType ret = Activator.CreateInstance<AuthoringType>();
(ret as SourceCode.Forms.Authoring.IXmlSerializableObject).FromXml(xml);
return ret;
}
throw new NotSupportedException();
}
Regards
Jurie