本文整理汇总了C#中SourceCode.GetServiceInstanceForExtend方法的典型用法代码示例。如果您正苦于以下问题:C# SourceCode.GetServiceInstanceForExtend方法的具体用法?C# SourceCode.GetServiceInstanceForExtend怎么用?C# SourceCode.GetServiceInstanceForExtend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceCode
的用法示例。
在下文中一共展示了SourceCode.GetServiceInstanceForExtend方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSmartBoxSmartObject
private SourceCode.SmartObjects.Authoring.SmartObjectDefinition CreateSmartBoxSmartObject(SourceCode.SmartObjects.Management.SmartObjectManagementServer SmartObjectManagementSvr, K2Field.Apps.Framework.Build.SmartObjectDefinition SmO, string DeploymentCategory)
{
ServiceInstance serviceInstance = ServiceInstance.Create(SmartObjectManagementSvr.GetServiceInstanceForExtend(SmO.ServiceInstanceId, string.Empty));
ExtendObject extendObject = serviceInstance.GetCreateExtender();
// do set ID here - set on SmartObjectDefinition - extender is specifically for SmartBox
//extendObject.Guid = SmO.Id;
extendObject.Name = SmO.SystemName;
extendObject.Metadata.DisplayName = SmO.DisplayName;
extendObject.Metadata.Description = SmO.Description;
foreach(K2Field.Apps.Framework.Build.SmartObjectProperty prop in SmO.Properties)
{
ExtendObjectProperty SoProp = new ExtendObjectProperty();
SoProp.Guid = prop.Id;
SoProp.Name = prop.SystemName.Replace(" ", "_").Replace(".", "_");
SoProp.Metadata.DisplayName = prop.DisplayName;
SoProp.Type = (PropertyDefinitionType)prop.DataType;
SoProp.ExtendType = (SourceCode.SmartObjects.Authoring.ExtendPropertyType)prop.ExtendType;
if (prop.DataType == SmODataType.Text)
{
if (prop.MaxSize.HasValue && prop.MaxSize.Value > 0)
{
SoProp.Metadata.AddServiceElement("maxsize", prop.MaxSize.Value.ToString());
}
else
{
SoProp.Metadata.AddServiceElement("maxsize", "200");
}
}
if (!extendObject.Properties.ContainsName(prop.SystemName))
{
extendObject.Properties.Add(SoProp);
}
}
SourceCode.SmartObjects.Authoring.SmartObjectDefinition smoDefinition = new SourceCode.SmartObjects.Authoring.SmartObjectDefinition();
try
{
// Create SmartObject Definition
smoDefinition.Create(extendObject);
// must set the SmartObject Id here
smoDefinition.Guid = SmO.Id;
smoDefinition.AddDeploymentCategory(DeploymentCategory);
smoDefinition.Build();
}
catch (SmartObjectDefinitionException defEx)
{
MessageBox.Show(defEx.Message);
throw;
}
return smoDefinition;
}