本文整理汇总了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
}
示例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;
}
示例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");
}
示例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;
}
示例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");
}
示例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;
}
}
示例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");
}
示例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.");
}
示例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;
}
示例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");
}
示例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);
}
示例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;
}