/// <summary> /// Returns the attribute definition with <code>key</code> for entity type <code>entity</code>. /// </summary> /// <param name="key">The key of the attribute definition.</param> /// <param name="type">The entity type for which the definition should be returned.</param> public AbstractAttributeDefinition GetDefinition(Entity type, ushort key) { AbstractAttributeDefinition result = null; switch (type) { case Entity.Part: PartAttributesDict.TryGetValue(key, out result); break; case Entity.Characteristic: CharacteristicAttributesDict.TryGetValue(key, out result); break; case Entity.Measurement: MeasurementAttributesDict.TryGetValue(key, out result); break; case Entity.Value: ValueAttributesDict.TryGetValue(key, out result); break; case Entity.Catalog: CatalogAttributesDict.TryGetValue(key, out result); break; } return(result); }
private static void FillTable( AbstractAttributeDefinition[] atts, ref Dictionary<ushort, AbstractAttributeDefinition> table ) { table = table ?? new Dictionary<ushort, AbstractAttributeDefinition>(); foreach( var def in atts ) table[ def.Key ] = def; }
/// <summary> /// Adds new attribute definitions to the database configuration for the specified <paramref name="entity"/>. /// </summary> /// <param name="entity">The entity the attribute definitions should be added to.</param> /// <param name="definitions">The attribute definitions to add.</param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public Task CreateAttributeDefinitions( Entity entity, AbstractAttributeDefinition[] definitions, CancellationToken cancellationToken = default(CancellationToken) ) { return Post( string.Format( "configuration/{0}", entity ), definitions, cancellationToken ); }
/// <summary> /// Adds a new attribute definition to the database configuration for the specified <paramref name="entity"/>. /// </summary> /// <param name="entity">The entity the attribute definition should be added to.</param> /// <param name="definition">The attribute definition to add.</param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public Task CreateAttributeDefinition(Entity entity, AbstractAttributeDefinition definition, CancellationToken cancellationToken = default(CancellationToken)) { return(CreateAttributeDefinitions(entity, new[] { definition }, cancellationToken)); }
/// <summary> /// Adds a new attribute definition to the database configuration for the specified <paramref name="entity"/>. /// </summary> /// <param name="entity">The entity the attribute definition should be added to.</param> /// <param name="definition">The attribute definition to add.</param> /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param> public Task CreateAttributeDefinition( Entity entity, AbstractAttributeDefinition definition, CancellationToken cancellationToken = default( CancellationToken ) ) { return CreateAttributeDefinitions( entity, new[] { definition }, cancellationToken ); }