public static SubsystemInfo GetSubsystemInfo(SubsystemKind kind) { if (s_subSystemKindMap.TryGetValue(kind, out SubsystemInfo? subsystemInfo)) { return(subsystemInfo); } throw new ArgumentException( StringUtil.Format( SubsystemStrings.SubsystemKindUnknown, kind.ToString())); }
public static void RegisterSubsystem(SubsystemKind kind, ISubsystem proxy) { Requires.NotNull(proxy, nameof(proxy)); if (kind != proxy.Kind) { throw new ArgumentException( StringUtil.Format( SubsystemStrings.ImplementationMismatch, proxy.Kind.ToString(), kind.ToString()), nameof(proxy)); } RegisterSubsystem(GetSubsystemInfo(kind), proxy); }
internal static SubsystemInfo Create <TConcreteSubsystem>( SubsystemKind kind, bool allowUnregistration, bool allowMultipleRegistration, ReadOnlyCollection <string> requiredCmdlets, ReadOnlyCollection <string> requiredFunctions) where TConcreteSubsystem : class, ISubsystem { if (allowMultipleRegistration && (requiredCmdlets.Count > 0 || requiredFunctions.Count > 0)) { throw new ArgumentException( StringUtil.Format( SubsystemStrings.InvalidSubsystemInfo, kind.ToString())); } return(new SubsystemInfoImpl <TConcreteSubsystem>(kind) { AllowUnregistration = allowUnregistration, AllowMultipleRegistration = allowMultipleRegistration, RequiredCmdlets = requiredCmdlets, RequiredFunctions = requiredFunctions, }); }