如何注册自定义 FileSystemBinaryLargeObject

How to register custom FileSystemBinaryLargeObject

如何在 odrder 中配置 codefluent 运行时以插入自定义 class 继承自 FileSystemBinaryLargeObject ?

在我们的用例中,我们有一个包含超过 10 万个文件的实体。我需要弄清楚如何将它们分块到子目录中..

谢谢

对于所有实体:

<configuration>
 <configSections>
   <section name="MyDefaultNamespace" type="CodeFluent.Runtime.CodeFluentConfigurationSectionHandler, CodeFluent.Runtime" />
 </configSections>
 <MyDefaultNamespace ... other attributes ...
  binaryServicesTypeName="CustomBinaryServices, Assembly"
  binaryServicesEntityConfigurationTypeName="CustomBinaryServicesConfiguration, Assembly"
  />
</configuration>

对于特定实体:

<configuration>
 <configSections>
   <section name="MyDefaultNamespace" type="CodeFluent.Runtime.CodeFluentConfigurationSectionHandler, CodeFluent.Runtime" />
 </configSections>
 <MyDefaultNamespace ... other attributes ... >
   <binaryServices entityFullTypeName="MyDefaultNamespace.MyNamespace.MyEntity"
     binaryServicesTypeName="CustomBinaryServices, Assembly" 
     binaryServicesEntityConfigurationTypeName="CustomBinaryServicesConfiguration, Assembly"/>
 </MyDefaultNamespace>
</configuration>

我认为你的提议行不通。我已经对其进行了测试,发现我的自定义 blob class 没有被实例化。

根据下面的代码,@binaryServicesTypeName 属性只接受 4 个预定义的字符串值 : azure, azure2, 文件系统, skydrive.

否则将设置默认 "SqlServerBinaryLargeObject" blob 对象。

/// <summary>
/// Gets or sets the type name of the class deriving from the BinaryLargeObject class.
///             Based on the 'typeName' Xml attributes from the configuration file.
///             The default is SqlServerBinaryLargeObject.
/// 
/// </summary>
/// 
/// <value>
/// The configured type name.
/// </value>
public virtual string TypeName
{
  get
  {
    if (this._typeName == null)
    {
      string defaultValue = (string) null;
      if (this._configuration.PersistenceHook != null)
        defaultValue = this._configuration.PersistenceHook.BinaryLargeObjectTypeName;
      if (string.IsNullOrEmpty(defaultValue))
        defaultValue = typeof (SqlServerBinaryLargeObject).AssemblyQualifiedName;
      this._typeName = XmlUtilities.GetAttribute((XmlNode) this.Element, "binaryServicesTypeName", defaultValue);
      if (this._typeName == null)
        this._typeName = XmlUtilities.GetAttribute((XmlNode) this.Element, "typeName", defaultValue);
      if (this._typeName != null && string.Compare(this._typeName, "azure", StringComparison.OrdinalIgnoreCase) == 0)
        this._typeName = "CodeFluent.Runtime.Azure.AzureBinaryLargeObject, CodeFluent.Runtime.Azure";
      if (this._typeName != null && string.Compare(this._typeName, "azure2", StringComparison.OrdinalIgnoreCase) == 0)
        this._typeName = "CodeFluent.Runtime.Azure.AzureBinaryLargeObject, CodeFluent.Runtime.Azure2";
      if (this._typeName != null && string.Compare(this._typeName, "filesystem", StringComparison.OrdinalIgnoreCase) == 0)
        this._typeName = typeof (FileSystemBinaryLargeObject).AssemblyQualifiedName;
      if (this._typeName != null && string.Compare(this._typeName, "skydrive", StringComparison.OrdinalIgnoreCase) == 0)
        this._typeName = typeof (SkyDriveBinaryLargeObject).AssemblyQualifiedName;
    }
    return this._typeName;
  }
  set
  {
    this._typeName = value;
  }
}

其他想法?

PS:这里是 app.config 演示文件,使用为 codefluent 运行时生成的模式

app.config