コード例 #1
0
ファイル: ViewManager.cs プロジェクト: Irmanster/mngSentinel
        public void Register(IViewInformation info, Type viewerType)
        {
            if (registeredTypes.Any(t => t.Key.Identifier == info.Identifier))
            {
                throw new NotSupportedException("Already have a registered viewer with the Id of " + info.Identifier);
            }

            // Validate that the type supports the necessary interface: ILogViewer
            var intefaceType = typeof(ILogViewer);
            if (viewerType.GetInterfaces().All(i => i != intefaceType))
            {
                throw new NotSupportedException("Types registered in ViewManager must support the inteface " +
                                                intefaceType);
            }

            // Populate the registration information.
            registeredTypes.Add(info, viewerType);
        }
コード例 #2
0
        public void Register(IViewInformation info, Type viewerType)
        {
            if (registeredTypes.Any(t => t.Key.Identifier == info.Identifier))
            {
                throw new NotSupportedException("Already have a registered viewer with the Id of " + info.Identifier);
            }

            // Validate that the type supports the necessary interface: ILogViewer
            var interfaceType = typeof(ILogViewer);

            if (viewerType.GetInterfaces().All(i => i != interfaceType))
            {
                throw new NotSupportedException($"Types registered in ViewManager must support the interface '{interfaceType}'");
            }

            // Populate the registration information.
            registeredTypes.Add(info, viewerType);
        }