RepositoryItem from List&Label .lst file



目前我们使用WPF应用程序来创建/编辑List&Label Templates,但我们正在考虑迁移到WebDesigner。因为我们使用项目包含,所以我们需要使用存储库模式。

我一直在尝试导入我们现有的模板,但我遇到了一些关于RepositoryItemDescriptor的问题。要创建一个RepositoryItem对象,您必须在构造函数中给出一个Descriptor,但我找不到有关如何从生成的.lst文件中获取它的任何信息。

我们掌握的数据是:

  • 模板类型:列表或表单
  • 模板数据:.lst文件的内容 (byte[])
  • IsMainTemplate:bool,是否为"项目包含">
  • 文件名:.lst文件的名称

构造函数RepositoryItem需要:string internalID, string descriptor, string type, DateTime lastModificationUTC

我现在拥有的是:

public class TemplateBaseModel : RepositoryItem
{
// Properties
// we have our own Ids and modification date, override RepositoryItem properties
public new InternalID => $"repository://{{{Id}}}";
public DateTime LastModificationUTC => ModifiedOn; 
public TemplateBaseModel() : base($"repository://{{{Guid.NewGuid()}}}", /* ?? */, RepositoryItemType.ProjectList.Value, DateTime.Now) { }
public TemplateBaseModel(string internalID, string descriptor, string type, DateTime lastModificationUTC) : base(internalID, descriptor, type, lastModificationUTC) { }
}

在文档中,我只能找到它是什么(序列化为字符串的内部元数据,可以使用类RepositoryItemDescriptor进行编辑),但找不到它是如何创建的或如何获取它,如果我尝试调试示例我得到(在CreateOrUpdate()方法中)@2@PgUAAENoS19QYWNrZWQAeNqd1E1PE1EYxfHfmsTvMAyJEeLY8iKCtpChU5MmvAiOC2NcjDCYmqFtZkaEqF9dXThgsTVGt/fm+Z9zz3lyv3/r2HXlQiFwKVeqDI2NdIVWPdIWCuRGTo2dGRp5ryv0Suq5yKpNoUCllhk5kymMjeS6QtdyldCuHfcs6FgUiQQSqUQgEk3dJY70pF57oS8wURo7N1TIBd64Z0GgY1HfodRA6rXAqVIgdN+SK21tbZlnt4o9J41W2OjNo9Qy72Y421OcVGzvD6R9fQcNcdb7A4WhSm3FQ4GhWu7CimUrt6T5rJvJacruHcruHEosldo38PI3ykjmQi7Qk4ilYoElJ/qOvTJwoi+Z4s33daMeeGDJiyna8szs725+zf6vmz8Tf+71U5WJzGmT/5ncucxHhdoXE6VcJVe6lFsWCGdOQzsCb+ds8I3T6R2+2/qv/ZjNvit0IjcxVhmqjZWuDZpXhHfanE2rKzSQCO0o53Ceamn5rGdTrC3Ws6YtkuiJbYts2LJlXWRbbNWayIbEE7E9sZ4Na9Y91vdVR+vWx9+9pa5NmvwKhVaTzQe5U7WWQqX+R+q+TKV20PxI54ZyZ0I7LmXK5t17PkkcOnSkdKxtT6pwLNbVnava0brt6abP1txGfwD+q8AH,这也无济于事。

知道如何从.lst文件正确创建RepositoryItem吗? 或者如何创建/获取descriptor

您应该尝试使用combit.ListLabel23.Repository命名空间中的类RepositoryImportUtil。这个帮助程序类为您完成所有艰苦的工作。给定一个IRepository接口和 lst 文件,所需的代码将类似于

IRepository listLabelRepository = <yourRepository>;
using (ListLabel LL = new ListLabel())
{
LL.FileRepository = listLabelRepository;
using (RepositoryImportUtil importUtil = new RepositoryImportUtil(listLabelRepository))
{
importUtil.ImportProjectFileWithDependencies(LL, 
@"<PathToRootProject>");
}
}

如果此方法不是您需要的,则帮助程序类还有其他几个方法来帮助您导入现有项目。

最新更新