当前位置: 首页>>代码示例>>C#>>正文


C# MediaManagement.MediaItemAspectMetadata类代码示例

本文整理汇总了C#中MediaPortal.Common.MediaManagement.MediaItemAspectMetadata的典型用法代码示例。如果您正苦于以下问题:C# MediaItemAspectMetadata类的具体用法?C# MediaItemAspectMetadata怎么用?C# MediaItemAspectMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MediaItemAspectMetadata类属于MediaPortal.Common.MediaManagement命名空间,在下文中一共展示了MediaItemAspectMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FirstCharGroupingFunction

 public FirstCharGroupingFunction(MediaItemAspectMetadata.AttributeSpecification attributeType)
 {
   _attributeType = attributeType;
   if (_emptyOrMiscCharacterGroupName == null)
     _emptyOrMiscCharacterGroupName = LocalizationHelper.Translate(EMPTY_OR_MISC_CHAR_GROUP_NAME_RES);
   // TODO: How to get all valid letters in all variants (with umlauts etc.)?
   _letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
 }
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:8,代码来源:FirstCharGroupingFunction.cs

示例2: ComplexAttributeQueryBuilder

 /// <summary>
 /// Creates a new <see cref="ComplexAttributeQueryBuilder"/> instance.
 /// </summary>
 /// <param name="miaManagement">MIAM management instance from media library.</param>
 /// <param name="complexQueryAttribute">Complex attribute, which is requested by this query. Only attributes
 /// with a cardinality different from <see cref="Cardinality.Inline"/> are allowed here.</param>
 /// <param name="selectProjectionFunction">This delegate function will be called for the selected attribute.
 /// It must return an SQL projection expression whose return value is the requested value for that attribute.
 /// If this delegate function is <c>null</c>, the actual attribute is selected without a projection function.</param>
 /// <param name="necessaryRequestedMIAs">MIAs which must be present for the media item to match the query.</param>
 /// <param name="filter">Filter which must be applied to the media items to match the query.</param>
 public ComplexAttributeQueryBuilder(
     MIA_Management miaManagement,
     MediaItemAspectMetadata.AttributeSpecification complexQueryAttribute,
     SelectProjectionFunction selectProjectionFunction,
     IEnumerable<MediaItemAspectMetadata> necessaryRequestedMIAs, IFilter filter) : base(miaManagement)
 {
   _queryAttribute = complexQueryAttribute;
   _selectProjectionFunction = selectProjectionFunction;
   _necessaryRequestedMIAs = necessaryRequestedMIAs;
   _filter = filter;
 }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:22,代码来源:ComplexAttributeQueryBuilder.cs

示例3: RegisterLocallyKnownMediaItemAspectType

 public void RegisterLocallyKnownMediaItemAspectType(MediaItemAspectMetadata miaType)
 {
   if (_locallyKnownMediaItemAspectTypes.ContainsKey(miaType.AspectId))
     return;
   _locallyKnownMediaItemAspectTypes.Add(miaType.AspectId, miaType);
   IServerConnectionManager serverConnectionManager = ServiceRegistration.Get<IServerConnectionManager>();
   IContentDirectory cd = serverConnectionManager == null ? null :
       serverConnectionManager.ContentDirectory;
   if (cd != null)
     cd.AddMediaItemAspectStorage(miaType);
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:11,代码来源:MediaItemAspectTypeRegistration.cs

示例4: CompiledGroupedAttributeValueQuery

 public CompiledGroupedAttributeValueQuery(
     MIA_Management miaManagement,
     IEnumerable<MediaItemAspectMetadata> necessaryRequestedMIATypes,
     MediaItemAspectMetadata.AttributeSpecification selectedAttribute, IAttributeFilter selectAttributeFilter,
     SelectProjectionFunction selectProjectionFunction, Type projectionValueType,
     IFilter filter)
 {
   _miaManagement = miaManagement;
   _necessaryRequestedMIATypes = necessaryRequestedMIATypes;
   _selectAttribute = selectedAttribute;
   _selectAttributeFilter = selectAttributeFilter;
   _selectProjectionFunction = selectProjectionFunction;
   _projectionValueType = projectionValueType;
   _filter = filter;
 }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:15,代码来源:CompiledGroupedAttributeValueQuery.cs

示例5: InsertOrUpdateManyToManyMIAAttributeValue

    protected void InsertOrUpdateManyToManyMIAAttributeValue(ITransaction transaction,
        MediaItemAspectMetadata.AttributeSpecification spec, Guid mediaItemId, object value)
    {
      string collectionAttributeTableName = GetMIACollectionAttributeTableName(spec);
      IDatabaseManager databaseManager = ServiceRegistration.Get<IDatabaseManager>();
      ISQLDatabase database = transaction.Database;
      // Insert value into collection attribute table if not exists: We do it in a single statement to avoid rountrips to the DB
      using (IDbCommand command = transaction.CreateCommand())
      {
        command.CommandText = "INSERT INTO " + collectionAttributeTableName + " (" +
            FOREIGN_COLL_ATTR_ID_COL_NAME + ", " + COLL_ATTR_VALUE_COL_NAME + ") SELECT @FOREIGN_COLL_ATTR, @COLL_ATTR_VALUE FROM " +
            databaseManager.DummyTableName + " WHERE NOT EXISTS(SELECT " + FOREIGN_COLL_ATTR_ID_COL_NAME +
            " FROM " + collectionAttributeTableName + " WHERE " + COLL_ATTR_VALUE_COL_NAME + " = @COLL_ATTR_VALUE)";

        database.AddParameter(command, "FOREIGN_COLL_ATTR", Guid.NewGuid(), typeof(Guid));
        value = TruncateBigValue(value, spec);
        database.AddParameter(command, "COLL_ATTR_VALUE", value, spec.AttributeType); // Used twice in query

        command.ExecuteNonQuery();
      }

      // Check association: We do it here with a single statement to avoid roundtrips to the DB
      string nmTableName = GetMIACollectionAttributeNMTableName(spec);
      using (IDbCommand command = transaction.CreateCommand())
      {
        command.CommandText = "INSERT INTO " + nmTableName + " (" + MIA_MEDIA_ITEM_ID_COL_NAME + ", " + FOREIGN_COLL_ATTR_ID_COL_NAME +
            ") SELECT @MEDIA_ITEM_ID, " + FOREIGN_COLL_ATTR_ID_COL_NAME + " FROM " + collectionAttributeTableName +
            " WHERE " + COLL_ATTR_VALUE_COL_NAME + " = @COLL_ATTR_VALUE AND NOT EXISTS(" +
              "SELECT V." + FOREIGN_COLL_ATTR_ID_COL_NAME + " FROM " + collectionAttributeTableName + " V " +
              " INNER JOIN " + nmTableName + " NM ON V." + FOREIGN_COLL_ATTR_ID_COL_NAME + " = NM." + FOREIGN_COLL_ATTR_ID_COL_NAME +
              " WHERE V." + COLL_ATTR_VALUE_COL_NAME + " = @COLL_ATTR_VALUE AND NM." + MIA_MEDIA_ITEM_ID_COL_NAME + " = @MEDIA_ITEM_ID" +
            ")";

        database.AddParameter(command, "MEDIA_ITEM_ID", mediaItemId, typeof(Guid)); // Used twice in query
        database.AddParameter(command, "COLL_ATTR_VALUE", value, spec.AttributeType); // Used twice in query

        command.ExecuteNonQuery();
      }
    }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:39,代码来源:MIA_Management.cs

示例6: CleanupManyToManyOrphanedAttributeValues

    protected void CleanupManyToManyOrphanedAttributeValues(ITransaction transaction,
        MediaItemAspectMetadata.AttributeSpecification spec)
    {
      string collectionAttributeTableName = GetMIACollectionAttributeTableName(spec);
      string nmTableName = GetMIACollectionAttributeNMTableName(spec);

      using (IDbCommand command = transaction.CreateCommand())
      {
        command.CommandText = "DELETE FROM " + collectionAttributeTableName + " WHERE NOT EXISTS (" +
            "SELECT " + FOREIGN_COLL_ATTR_ID_COL_NAME + " FROM " + nmTableName + " NM WHERE " +
            FOREIGN_COLL_ATTR_ID_COL_NAME + " = " + collectionAttributeTableName + "." + FOREIGN_COLL_ATTR_ID_COL_NAME + ")";

        command.ExecuteNonQuery();
      }
    }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:15,代码来源:MIA_Management.cs

示例7: GetMIACollectionAttributeNMTableIdentifier

 /// <summary>
 /// Gets a technical table identifier for the N:M table for the given MIAM collection attribute.
 /// </summary>
 /// <returns>Table identifier for the N:M table for the given collection attribute. The returned identifier must be
 /// mapped to a shortened table name to be used in the DB.</returns>
 internal string GetMIACollectionAttributeNMTableIdentifier(MediaItemAspectMetadata.AttributeSpecification spec)
 {
   return "NM_" + GetMIATableName(spec.ParentMIAM) + "_" + SqlUtils.ToSQLIdentifier(spec.AttributeName);
 }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:9,代码来源:MIA_Management.cs

示例8: AddMediaItemAspectStorage

    public bool AddMediaItemAspectStorage(MediaItemAspectMetadata miam)
    {
      lock (_syncObj)
      {
        if (_managedMIATypes.ContainsKey(miam.AspectId))
          return false;
        _managedMIATypes.Add(miam.AspectId, null);
      }
      ISQLDatabase database = ServiceRegistration.Get<ISQLDatabase>();
      ITransaction transaction = database.BeginTransaction();
      ServiceRegistration.Get<ILogger>().Info("MIA_Management: Adding media library storage for media item aspect '{0}' (id '{1}')",
          miam.Name, miam.AspectId);
      try
      {
        // Register metadata first - generated aliases will reference to the new MIA type row
        using (IDbCommand command = MediaLibrary_SubSchema.CreateMediaItemAspectMetadataCommand(transaction, miam.AspectId, miam.Name, miam.Serialize()))
          command.ExecuteNonQuery();

        // Create main table for new MIA type
        string miaTableName = GenerateMIATableName(transaction, miam);
        StringBuilder mainStatementBuilder = new StringBuilder("CREATE TABLE " + miaTableName + " (" +
            MIA_MEDIA_ITEM_ID_COL_NAME + " " + database.GetSQLType(typeof(Guid)) + ", ");
        IList<string> terms = new List<string>();
        IList<string> additionalAttributesConstraints = new List<string>();
        string collectionAttributeTableName;
        string pkConstraintName;

        // Attributes: First run
        foreach (MediaItemAspectMetadata.AttributeSpecification spec in miam.AttributeSpecifications.Values)
        {
          string sqlType = spec.AttributeType == typeof(string) ? database.GetSQLVarLengthStringType(spec.MaxNumChars) :
              database.GetSQLType(spec.AttributeType);
          string attributeColumnName = GenerateMIAAttributeColumnName(transaction, spec);
          switch (spec.Cardinality)
          {
            case Cardinality.Inline:
              terms.Add(attributeColumnName + " " + sqlType);
              break;
            case Cardinality.OneToMany:
              GenerateMIACollectionAttributeTableName(transaction, spec);
              break;
            case Cardinality.ManyToOne:
              // Create foreign table - the join attribute will be located in the main MIA table
              // We need to create the "One" table first because the main table references on it
              collectionAttributeTableName = GenerateMIACollectionAttributeTableName(transaction, spec);
              pkConstraintName = GenerateDBObjectName(transaction, miam.AspectId, collectionAttributeTableName + "_PK", "PK");

              using (IDbCommand command = transaction.CreateCommand())
              {
                command.CommandText = "CREATE TABLE " + collectionAttributeTableName + " (" +
                    FOREIGN_COLL_ATTR_ID_COL_NAME + " " + database.GetSQLType(typeof(Guid)) + ", " +
                    COLL_ATTR_VALUE_COL_NAME + " " + sqlType + ", " +
                    "CONSTRAINT " + pkConstraintName + " PRIMARY KEY (" + FOREIGN_COLL_ATTR_ID_COL_NAME + ")" +
                    ")";
                ServiceRegistration.Get<ILogger>().Debug("MIA_Management: Creating MTO table '{0}' for attribute '{1}' in media item aspect '{2}'",
                    collectionAttributeTableName, spec.AttributeName, miam.AspectId);
                command.ExecuteNonQuery();
              }

              // Create foreign table - the join attribute will be located in the main MIA table
              string fkMediaItemConstraintName = GenerateDBObjectName(transaction, miam.AspectId, "MIA_" + collectionAttributeTableName + "_FK", "FK");

              terms.Add(attributeColumnName + " " + database.GetSQLType(typeof(Guid)));
              additionalAttributesConstraints.Add("CONSTRAINT " + fkMediaItemConstraintName +
                  " FOREIGN KEY (" + attributeColumnName + ")" +
                  " REFERENCES " + collectionAttributeTableName + " (" + FOREIGN_COLL_ATTR_ID_COL_NAME + ") ON DELETE SET NULL");
              break;
            case Cardinality.ManyToMany:
              GenerateMIACollectionAttributeTableName(transaction, spec);
              break;
            default:
              throw new NotImplementedException(string.Format("Cardinality '{0}' for attribute '{1}.{2}' is not implemented",
                  spec.Cardinality, miam.AspectId, spec.AttributeName));
          }
        }

        // Main table
        foreach (string term in terms)
        {
          mainStatementBuilder.Append(term);
          mainStatementBuilder.Append(", ");
        }
        string pkConstraintName1 = GenerateDBObjectName(transaction, miam.AspectId, miaTableName + "_PK", "PK");
        string fkMediaItemConstraintName1 = GenerateDBObjectName(transaction, miam.AspectId, miaTableName + "_MEDIA_ITEMS_FK", "FK");
        mainStatementBuilder.Append(
            "CONSTRAINT " + pkConstraintName1 + " PRIMARY KEY (" + MIA_MEDIA_ITEM_ID_COL_NAME + "), " +
            "CONSTRAINT " + fkMediaItemConstraintName1 +
            " FOREIGN KEY (" + MIA_MEDIA_ITEM_ID_COL_NAME + ") REFERENCES " +
                MediaLibrary_SubSchema.MEDIA_ITEMS_TABLE_NAME + " (" + MediaLibrary_SubSchema.MEDIA_ITEMS_ITEM_ID_COL_NAME + ") ON DELETE CASCADE");
        if (additionalAttributesConstraints.Count > 0)
        {
          mainStatementBuilder.Append(", ");
          mainStatementBuilder.Append(StringUtils.Join(", ", additionalAttributesConstraints));
        }
        mainStatementBuilder.Append(")");
        using (IDbCommand command = transaction.CreateCommand())
        {
          command.CommandText = mainStatementBuilder.ToString();
          ServiceRegistration.Get<ILogger>().Debug(
              "MIA_Management: Creating main table '{0}' for media item aspect '{1}'", miaTableName, miam.AspectId);
//.........这里部分代码省略.........
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:101,代码来源:MIA_Management.cs

示例9: GetMIACollectionAttributeNMTableName

 /// <summary>
 /// Gets the actual table name for a MIAM collection attribute table.
 /// </summary>
 /// <returns>Table name for the table containing the specified collection attribute.</returns>
 internal string GetMIACollectionAttributeNMTableName(MediaItemAspectMetadata.AttributeSpecification spec)
 {
   string identifier = GetMIACollectionAttributeNMTableIdentifier(spec);
   return GetAliasMapping(identifier, string.Format("Attribute '{0}' of MIAM '{1}' (id: '{2}') doesn't have a corresponding N:M table name yet",
       spec.AttributeName, spec.ParentMIAM.Name, spec.ParentMIAM.AspectId));
 }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:10,代码来源:MIA_Management.cs

示例10: LockAttribute

 protected void LockAttribute(MediaItemAspectMetadata.AttributeSpecification spec)
 {
   lock (_syncObj)
   {
     Thread currentThread = Thread.CurrentThread;
     ThreadOwnership to;
     while (_lockedAttrs.TryGetValue(spec, out to) && to.CurrentThread != currentThread)
       Monitor.Wait(_syncObj);
     if (!_lockedAttrs.TryGetValue(spec, out to))
       _lockedAttrs[spec] = to = new ThreadOwnership(currentThread);
     to.LockCount++;
   }
 }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:13,代码来源:MIA_Management.cs

示例11: UnlockAttribute

 protected void UnlockAttribute(MediaItemAspectMetadata.AttributeSpecification spec)
 {
   lock (_syncObj)
   {
     Thread currentThread = Thread.CurrentThread;
     ThreadOwnership to;
     if (!_lockedAttrs.TryGetValue(spec, out to) || to.CurrentThread != currentThread)
       throw new IllegalCallException("Media item aspect attribute '{0}' of media item aspect '{1}' (id '{2}') is not locked by the current thread",
           spec.AttributeName, spec.ParentMIAM.Name, spec.ParentMIAM.AspectId);
     to.LockCount--;
     if (to.LockCount == 0)
     {
       _lockedAttrs.Remove(spec);
       Monitor.PulseAll(_syncObj);
     }
   }
 }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:17,代码来源:MIA_Management.cs

示例12: GetManyToOneMIAAttributeValue

    protected object GetManyToOneMIAAttributeValue(ITransaction transaction, Guid mediaItemId,
        MediaItemAspectMetadata.AttributeSpecification spec, string miaTableName)
    {
      string collectionAttributeTableName = GetMIACollectionAttributeTableName(spec);
      string mainTableAttrName = GetMIAAttributeColumnName(spec);
      ISQLDatabase database = transaction.Database;
      using (IDbCommand command = transaction.CreateCommand())
      {
        command.CommandText = "SELECT " + COLL_ATTR_VALUE_COL_NAME + " FROM " + collectionAttributeTableName + " V" +
            " INNER JOIN " + miaTableName + " MAIN ON V." + FOREIGN_COLL_ATTR_ID_COL_NAME + " = MAIN." + mainTableAttrName +
            " WHERE MAIN." + MIA_MEDIA_ITEM_ID_COL_NAME + " = @MEDIA_ITEM_ID";

        database.AddParameter(command, "MEDIA_ITEM_ID", mediaItemId, typeof(Guid));

        Type valueType = spec.AttributeType;
        using (IDataReader reader = command.ExecuteReader(CommandBehavior.SingleRow))
        {
          if (reader.Read())
            return database.ReadDBValue(valueType, reader, 0);
          return null;
        }
      }
    }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:23,代码来源:MIA_Management.cs

示例13: GetManyToManyMIAAttributeValues

    protected IList GetManyToManyMIAAttributeValues(ITransaction transaction, Guid mediaItemId,
        MediaItemAspectMetadata.AttributeSpecification spec)
    {
      string collectionAttributeTableName = GetMIACollectionAttributeTableName(spec);
      string nmTableName = GenerateMIACollectionAttributeNMTableName(transaction, spec);
      ISQLDatabase database = transaction.Database;
      using (IDbCommand command = transaction.CreateCommand())
      {
        command.CommandText = "SELECT " + COLL_ATTR_VALUE_COL_NAME + " FROM " + collectionAttributeTableName + " V" +
            " INNER JOIN " + nmTableName + " NM ON V." + FOREIGN_COLL_ATTR_ID_COL_NAME + " = NM." + FOREIGN_COLL_ATTR_ID_COL_NAME +
            " WHERE NM." + MIA_MEDIA_ITEM_ID_COL_NAME + " = @MEDIA_ITEM_ID";

        database.AddParameter(command, "MEDIA_ITEM_ID", mediaItemId, typeof(Guid));

        Type valueType = spec.AttributeType;
        using (IDataReader reader = command.ExecuteReader())
        {
          IList result = new ArrayList();
          while (reader.Read())
            result.Add(database.ReadDBValue(valueType, reader, 0));
          return result;
        }
      }
    }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:24,代码来源:MIA_Management.cs

示例14: TruncateBigValue

 protected static object TruncateBigValue(object value, MediaItemAspectMetadata.AttributeSpecification attributeSpecification)
 {
   string str = value as string;
   uint maxNumChars = attributeSpecification.MaxNumChars;
   if (!string.IsNullOrEmpty(str) && maxNumChars > 0 && str.Length > maxNumChars)
     return str.Substring(0, (int) maxNumChars);
   return value;
 }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:8,代码来源:MIA_Management.cs

示例15: GenerateMIACollectionAttributeNMTableName

 internal string GenerateMIACollectionAttributeNMTableName(ITransaction transaction, MediaItemAspectMetadata.AttributeSpecification spec)
 {
   string identifier = GetMIACollectionAttributeNMTableIdentifier(spec);
   return GenerateDBObjectName(transaction, spec.ParentMIAM.AspectId, identifier, "NM_" + spec.AttributeName);
 }
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:5,代码来源:MIA_Management.cs


注:本文中的MediaPortal.Common.MediaManagement.MediaItemAspectMetadata类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。