当前位置: 首页>>代码示例>>C#>>正文


C# System.NotSupportedException类代码示例

本文整理汇总了C#中System.NotSupportedException的典型用法代码示例。如果您正苦于以下问题:C# NotSupportedException类的具体用法?C# NotSupportedException怎么用?C# NotSupportedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NotSupportedException类属于System命名空间,在下文中一共展示了NotSupportedException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConnectionPointCookie

        /// <summary>
        /// Creates a connection point to of the given interface type
        /// which will call on a managed code sink that implements that interface.
        /// </summary>
        public ConnectionPointCookie(object source, object sink, Type eventInterface, bool throwException) {
            Exception ex = null;

            if (source is IConnectionPointContainer) {
                _connectionPointContainer = (IConnectionPointContainer)source;

                try {
                    Guid tmp = eventInterface.GUID;
                    _connectionPointContainer.FindConnectionPoint(ref tmp, out _connectionPoint);
                } catch {
                    _connectionPoint = null;
                }

                if (_connectionPoint == null) {
                    ex = new NotSupportedException();
                } else if (sink == null || !eventInterface.IsInstanceOfType(sink)) {
                    ex = new InvalidCastException();
                } else {
                    try {
                        _connectionPoint.Advise(sink, out _cookie);
                    } catch {
                        _cookie = 0;
                        _connectionPoint = null;
                        ex = new Exception();
                    }
                }
            } else {
                ex = new InvalidCastException();
            }

            if (throwException && (_connectionPoint == null || _cookie == 0)) {
                Dispose();

                if (ex == null) {
                    throw new ArgumentException("Exception null, but cookie was zero or the connection point was null");
                } else {
                    throw ex;
                }
            }

#if DEBUG
            //_callStack = Environment.StackTrace;
            //this._eventInterface = eventInterface;
#endif
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:49,代码来源:ConnectionPoint.cs

示例2: CreateNotSupportedErrorRecord

		internal static ErrorRecord CreateNotSupportedErrorRecord(string resourceStr, string errorId, object[] args)
		{
			string str = StringUtil.Format(resourceStr, args);
			NotSupportedException notSupportedException = new NotSupportedException(str);
			ErrorRecord errorRecord = new ErrorRecord(notSupportedException, errorId, ErrorCategory.NotImplemented, null);
			return errorRecord;
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:SecurityUtils.cs

示例3: TypePropertiesAreCorrect

 public void TypePropertiesAreCorrect()
 {
     Assert.AreEqual(typeof(NotSupportedException).GetClassName(), "Bridge.NotSupportedException", "Name");
     object d = new NotSupportedException();
     Assert.True(d is NotSupportedException, "is NotSupportedException");
     Assert.True(d is Exception, "is Exception");
 }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:7,代码来源:NotSupportedExceptionTests.cs

示例4: IsUnsupportedConsoleApplication

        public bool IsUnsupportedConsoleApplication(string script, out Exception e)
        {
            e = null;
            if (null == UnsupportedConsoleApplications || ! UnsupportedConsoleApplications.Any() )
            {
                return false;
            }

            if (UnsupportedConsoleApplications.Contains(
                script.Trim(),
                StringComparer.InvariantCultureIgnoreCase
                ))
            {

                e = new NotSupportedException(
                    String.Format(
@"The application ""{0}"" cannot be started because it is in the list of unsupported applications for this host.
To view or modify the list of unsupported applications for this host, see the ${1} variable, or type ""get-help {2}"".
Alternatively, you may try running the application as a unique process using the Start-Process cmdlet.",
                        script,
                        UnsupportedConsoleApplicationsVariableName,
                        UnsupportedConsoleApplicationsHelpTopicName)
                    );
                return true;
            }

            return false;
        }
开发者ID:beefarino,项目名称:bips,代码行数:28,代码来源:UnsupportedConsoleApplicationConfiguration.cs

示例5: ConstructorWithMessageAndInnerExceptionWorks

		public void ConstructorWithMessageAndInnerExceptionWorks() {
			var inner = new Exception("a");
			var ex = new NotSupportedException("The message", inner);
			Assert.IsTrue((object)ex is NotSupportedException, "is NotSupportedException");
			Assert.IsTrue(ReferenceEquals(ex.InnerException, inner), "InnerException");
			Assert.AreEqual(ex.Message, "The message");
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:7,代码来源:NotSupportedExceptionTests.cs

示例6: LogMessage

        private static void LogMessage(string text)
        {
            var randomType = Random.Next(0, 5);

            switch (randomType)
            {
                case 0:
                    var embeddedException = new NotSupportedException();
                    var keyNotFoundException = new KeyNotFoundException("Some wrapped message", embeddedException);
                    Log.Error(text, keyNotFoundException);
                    break;
                case 1:
                    Log.Fatal(text);
                    break;
                case 2:
                    Log.Info(text);
                    break;
                case 3:
                    Log.Warn(text);
                    break;
                default:
                    Log.Debug(text);
                    break;
            }
        }
开发者ID:jkoplo,项目名称:Sentinel,代码行数:25,代码来源:Program.cs

示例7: ConstructorWithMessageWorks

 public void ConstructorWithMessageWorks()
 {
     var ex = new NotSupportedException("The message");
     Assert.True((object)ex is NotSupportedException, "is NotSupportedException");
     Assert.AreEqual(ex.InnerException, null, "InnerException");
     Assert.AreEqual(ex.Message, "The message");
 }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:7,代码来源:NotSupportedExceptionTests.cs

示例8: DefaultConstructorWorks

 public void DefaultConstructorWorks()
 {
     var ex = new NotSupportedException();
     Assert.True((object)ex is NotSupportedException, "is NotSupportedException");
     Assert.AreEqual(ex.InnerException, null, "InnerException");
     Assert.AreEqual(ex.Message, "Specified method is not supported.");
 }
开发者ID:TinkerWorX,项目名称:Bridge,代码行数:7,代码来源:NotSupportedExceptionTests.cs

示例9: Invoke

        public override IMessage Invoke(IMessage message)
        {
            IMessage result = null;

            IMethodCallMessage methodCall = message as IMethodCallMessage;
            MethodInfo method = methodCall.MethodBase as MethodInfo;

            // Invoke
            if (result == null) {
                if (proxyTarget != null) {
                    Console.WriteLine("proxy going to invoke: {0}", method.Name);
                    object callResult;
                    object actualresult;
                    bool make_proxy = true;

                    if (method.ReturnType.IsInterface) {
                        actualresult = method.Invoke(proxyTarget, methodCall.InArgs);

                        if (method.ReturnType.IsGenericType) {
                            // Console.WriteLine("** return value is generic type: {0}", method.ReturnType.GetGenericTypeDefinition());
                            if (method.ReturnType.GetGenericTypeDefinition() == (typeof(IEnumerator<>))) {
                                Console.WriteLine("** method returning IEnumerator<>, making BatchProxy");
                                Type[] args = method.ReturnType.GetGenericArguments();

                                Type srvbatchtype = typeof(EnumeratorServerBatch<>).MakeGenericType(args);
                                object srv = Activator.CreateInstance(srvbatchtype, actualresult);

                                Type clbatchtype = typeof(EnumeratorClientBatch<>).MakeGenericType(args);
                                object client = Activator.CreateInstance(clbatchtype, srv);
                                make_proxy = false;
                                actualresult = client;
                            }
                        }

                        if (make_proxy) {
                            var newproxy = new MyProxy(method.ReturnType, actualresult);
                            callResult = newproxy.GetTransparentProxy();
                        } else {
                            callResult = actualresult;
                        }
                    } else {
                        callResult = method.Invoke(proxyTarget, methodCall.InArgs);
                    }

                    Console.WriteLine("proxy done Invoking: {0}", method.Name);
                    LogicalCallContext context = methodCall.LogicalCallContext;
                    result = new ReturnMessage(callResult, null, 0, context, message as IMethodCallMessage);
                } else {
                    NotSupportedException exception = new NotSupportedException("proxyTarget is not defined");
                    result = new ReturnMessage(exception, message as IMethodCallMessage);
                }
            }
            return result;
        }
开发者ID:jeske,项目名称:StepsDB-alpha,代码行数:54,代码来源:MyProxy.cs

示例10: TypePropertiesAreCorrect

		public void TypePropertiesAreCorrect() {
			Assert.AreEqual(typeof(NotSupportedException).FullName, "ss.NotSupportedException", "Name");
			Assert.IsTrue(typeof(NotSupportedException).IsClass, "IsClass");
			Assert.AreEqual(typeof(NotSupportedException).BaseType, typeof(Exception), "BaseType");
			object d = new NotSupportedException();
			Assert.IsTrue(d is NotSupportedException, "is NotSupportedException");
			Assert.IsTrue(d is Exception, "is Exception");

			var interfaces = typeof(NotSupportedException).GetInterfaces();
			Assert.AreEqual(interfaces.Length, 0, "Interfaces length");
		}
开发者ID:ShuntaoChen,项目名称:SaltarelleCompiler,代码行数:11,代码来源:NotSupportedExceptionTests.cs

示例11: FatalExceptionObject

 static void FatalExceptionObject(object exceptionObject)
 {
     var huh = exceptionObject as Exception;
     if (huh == null)
     {
         huh = new NotSupportedException(
           "Unhandled exception doesn't derive from System.Exception: "
            + exceptionObject.ToString()
         );
     }
     FatalExceptionHandler.Handle(huh);
 }
开发者ID:iEmiya,项目名称:HTTPServer,代码行数:12,代码来源:Server.cs

示例12: Act

 protected void Act()
 {
     try
     {
         _sftpFileStream.SetLength(_length);
         Assert.Fail();
     }
     catch (NotSupportedException ex)
     {
         _actualException = ex;
     }
 }
开发者ID:REALTOBIZ,项目名称:SSH.NET,代码行数:12,代码来源:SftpFileStreamTest_SetLength_SessionOpen_FIleAccessRead.cs

示例13: exception_type

        public void exception_type()
        {
            var exception1 = new NotImplementedException();
            var exception2 = new NotSupportedException();

            theExpression.IsType<NotImplementedException>();

            theMatch.Description.ShouldEqual("Exception type is " + typeof (NotImplementedException).FullName);

            theMatch.Matches(null, exception1).ShouldBeTrue();
            theMatch.Matches(null, exception2).ShouldBeFalse();
        }
开发者ID:RyanHauert,项目名称:FubuTransportation,代码行数:12,代码来源:ExceptionMatchingExpression_and_ExpressionMatch_Tester.cs

示例14: ConvertirString

        private string ConvertirString( string valorActual, List<IValorRespuestaWS> equivalencias )
        {
            IValorRespuestaWS valor = equivalencias.
                Find( x => x.Equivalencia.Equals( valorActual, StringComparison.OrdinalIgnoreCase ) );

            if ( valor == null )
            {
                NotSupportedException ex = new NotSupportedException( "No se encuentra el valor '" + valorActual + "'" );
                throw ex;
            }

            return valor.ObtenerId();
        }
开发者ID:GonzaloFernandoA,项目名称:FacturacionElectronica,代码行数:13,代码来源:ConversorDeDatosSegunEquivalencias.cs

示例15: Convert

        public virtual Exception Convert(ExceptionModel model)
        {
            Exception exception = null;
            TypeSwitch.On(model)
                .Case<ArgumentNullExceptionModel>(m => exception = new ArgumentNullException(m.ParamName, m.Message))
                .Case<ArgumentExceptionModel>(m => exception = new ArgumentException(m.ParamName, m.Message))
                .Case<InvalidOperationExceptionModel>(m => exception = new InvalidOperationException(m.Message))
                .Case<NotSupportedExceptionModel>(m => exception = new NotSupportedException(m.Message))
                .Case<HttpStatusExceptionModel>(m => exception = Convert(m.InnerException))
                .Default(m => exception = new Exception(m.Message));

            return exception;
        }
开发者ID:dennisdoomen,项目名称:Cedar,代码行数:13,代码来源:ModelToExceptionConverter.cs


注:本文中的System.NotSupportedException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。