Пример #1
0
        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()));
        }
Пример #2
0
        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);
        }
Пример #3
0
        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,
            });
        }