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