-
Notifications
You must be signed in to change notification settings - Fork 10
/
IExtensiblePropertyContainer.cs
39 lines (36 loc) · 1.91 KB
/
IExtensiblePropertyContainer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// -----------------------------------------------------------------------
// <copyright file="IExtensiblePropertyContainer.cs" company="Ubiquity.NET Contributors">
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
using System.Diagnostics.CodeAnalysis;
namespace Ubiquity.NET.Llvm
{
/// <summary>Interface to allow adding arbitrary named data items to an object</summary>
/// <remarks>
/// It is sometimes useful for code generation applications to attach some tool specific
/// data to the LLVM objects created but that don't need representation as LLVM Metadata
/// nodes. This interface provides such a facility.
/// </remarks>
public interface IExtensiblePropertyContainer
{
/// <summary>Try to get a value from the container</summary>
/// <typeparam name="T">Type of value to retrieve</typeparam>
/// <param name="id">id of the value to retrieve</param>
/// <param name="value">value retrieved if present (or default value of type <typeparamref name="T"/> otherwise)</param>
/// <returns>
/// true if the item was found and it's type matches <typeparamref name="T"/> false otherwise.
/// </returns>
bool TryGetExtendedPropertyValue<T>( string id, [MaybeNull] out T value );
/// <summary>Adds a value to the container</summary>
/// <param name="id">Id of the value</param>
/// <param name="value">value to add</param>
/// <remarks>
/// Adds the value with the specified id. If a value with the same id
/// already exists and its type is the same as <paramref name="value"/>
/// it is replaced. If the existing value is of a different type, then
/// an ArgumentException is thrown.
/// </remarks>
void AddExtendedPropertyValue( string id, object? value );
}
}