microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
6594a29aa91c928c547a8821d305758bc8d340ed

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.AI/FunctionCollection.cs

41lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4namespace Microsoft.Teams.AI;
5
6/// <summary>
7/// a collection of functions
8/// </summary>
9public class FunctionCollection : Dictionary<string, IFunction>
10{
11 /// <summary>
12 /// the names of the functions in
13 /// the collection
14 /// </summary>
15 public IList<string> Names => Keys.ToList();
16
17 /// <summary>
18 /// the functions in the collection
19 /// as a list
20 /// </summary>
21 public IList<IFunction> List => Values.ToList();
22
23 /// <summary>
24 /// check if the collection contains
25 /// some function name
26 /// </summary>
27 /// <param name="name">the function name</param>
28 public bool Has(string name) => ContainsKey(name);
29
30 /// <summary>
31 /// get a function
32 /// </summary>
33 /// <param name="name">the function name</param>
34 public IFunction? Get(string name) => !Has(name) ? null : this[name];
35
36 /// <summary>
37 /// add a function
38 /// </summary>
39 /// <param name="function">the function to add</param>
40 public void Add(IFunction function) => this[function.Name] = function;
41}