Пример #1
0
 internal static SubsystemInfo Create <TConcreteSubsystem>(
     SubsystemKind kind,
     bool allowUnregistration,
     bool allowMultipleRegistration) where TConcreteSubsystem : class, ISubsystem
 {
     return(new SubsystemInfoImpl <TConcreteSubsystem>(kind)
     {
         AllowUnregistration = allowUnregistration,
         AllowMultipleRegistration = allowMultipleRegistration,
     });
 }
Пример #2
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()));
        }
Пример #3
0
        private protected SubsystemInfo(SubsystemKind kind, Type subsystemType)
        {
            _syncObj         = new object();
            _cachedImplInfos = Utils.EmptyReadOnlyCollection <ImplementationInfo>();

            Kind                      = kind;
            SubsystemType             = subsystemType;
            AllowUnregistration       = false;
            AllowMultipleRegistration = false;
            RequiredCmdlets           = Utils.EmptyReadOnlyCollection <string>();
            RequiredFunctions         = Utils.EmptyReadOnlyCollection <string>();
        }
Пример #4
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);
        }
Пример #5
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,
            });
        }
Пример #6
0
 public static void UnregisterSubsystem(SubsystemKind kind, Guid id)
 {
     UnregisterSubsystem(GetSubsystemInfo(kind), id);
 }
Пример #7
0
 internal SubsystemInfoImpl(SubsystemKind kind)
     : base(kind, typeof(TConcreteSubsystem))
 {
     _registeredImpls = Utils.EmptyReadOnlyCollection <TConcreteSubsystem>();
 }
Пример #8
0
 internal static SubsystemInfo Create <TConcreteSubsystem>(SubsystemKind kind)
     where TConcreteSubsystem : class, ISubsystem
 {
     return(new SubsystemInfoImpl <TConcreteSubsystem>(kind));
 }