| | 1 | | // Copyright (c) ZeroC, Inc. |
| | 2 | |
|
| | 3 | | #nullable enable |
| | 4 | |
|
| | 5 | | using Ice.Internal; |
| | 6 | | using System.Reflection; |
| | 7 | |
|
| | 8 | | namespace Ice; |
| | 9 | |
|
| | 10 | | /// <summary>Creates class and exception instances from Slice type IDs.</summary> |
| | 11 | | public interface SliceLoader |
| | 12 | | { |
| | 13 | | /// <summary>Creates an instance of a class mapped from a Slice class or exception based on a Slice type ID. |
| | 14 | | /// </summary> |
| | 15 | | /// <param name="typeId">The Slice type ID or compact type ID.</param> |
| | 16 | | /// <returns>A new instance of the class or exception identified by <paramref name="typeId"/>, or <c>null</c> if the |
| | 17 | | /// implementation cannot find the corresponding class.</returns> |
| | 18 | | /// <exception cref="MarshalException">Thrown when the corresponding class was found but its instantiation failed. |
| | 19 | | /// </exception> |
| | 20 | | object? newInstance(string typeId); |
| | 21 | |
|
| | 22 | | /// <summary>Retrieves a <see cref="SliceLoader"/> for the generated classes in the specified assemblies. |
| | 23 | | /// </summary> |
| | 24 | | /// <param name="assemblies">The assemblies to search.</param> |
| | 25 | | /// <returns>A Slice loader for the specified assemblies.</returns> |
| | 26 | | /// <remarks>The classes defined in assemblies referenced by <paramref name="assemblies" /> are included, |
| | 27 | | /// recursively, provided they contain generated code (as determined by the presence of the |
| | 28 | | /// <see cref="SliceAttribute" /> attribute).</remarks> |
| | 29 | | public static SliceLoader fromAssemblies(params Assembly[] assemblies) => |
| 1 | 30 | | AssemblySliceLoader.Merge(assemblies.Select(AssemblySliceLoaderFactory.Instance.Get)); |
| | 31 | |
|
| | 32 | | /// <summary>Retrieves the <see cref="SliceLoader"/> for the generated classes in the specified assembly. |
| | 33 | | /// </summary> |
| | 34 | | /// <param name="assembly">The assembly to search.</param> |
| | 35 | | /// <returns>A Slice loader for the specified assembly.</returns> |
| | 36 | | /// <remarks>The classes defined in assemblies referenced by <paramref name="assembly" /> are included, recursively, |
| | 37 | | /// provided they contain generated code (as determined by the presence of the <see cref="SliceAttribute" /> |
| | 38 | | /// attribute).</remarks> |
| 0 | 39 | | public static SliceLoader fromAssembly(Assembly assembly) => AssemblySliceLoaderFactory.Instance.Get(assembly); |
| | 40 | | } |