本文整理汇总了C#中System.NotSupportedException类的典型用法代码示例。如果您正苦于以下问题:C# NotSupportedException类的具体用法?C# NotSupportedException怎么用?C# NotSupportedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NotSupportedException类属于System命名空间,在下文中一共展示了NotSupportedException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: GetStatement
private static RuleCodeDomStatement GetStatement(CodeStatement statement)
{
Type type = statement.GetType();
if (type == typeof(CodeExpressionStatement))
{
return ExpressionStatement.Create(statement);
}
if (type == typeof(CodeAssignStatement))
{
return AssignmentStatement.Create(statement);
}
NotSupportedException exception = new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Messages.CodeStatementNotHandled, new object[] { statement.GetType().FullName }));
exception.Data["ErrorObject"] = statement;
throw exception;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:CodeDomStatementWalker.cs
示例17: Should_Throw_Exception_To_Requester_If_Responder_Throws_Sync
public async Task Should_Throw_Exception_To_Requester_If_Responder_Throws_Sync()
{
/* Setup */
var responseException = new NotSupportedException("I'll throw this");
var requester = BusClientFactory.CreateDefault(TimeSpan.FromHours(1));
var responder = BusClientFactory.CreateDefault(TimeSpan.FromHours(1));
responder.RespondAsync<BasicRequest, BasicResponse>((request, context) =>
{
throw responseException;
});
/* Test */
/* Assert */
var e = await Assert.ThrowsAsync<MessageHandlerException>(() => requester.RequestAsync<BasicRequest, BasicResponse>());
Assert.Equal(expected: responseException.Message, actual: e.InnerException.Message);
}
开发者ID:Originalutter,项目名称:RawRabbit,代码行数:16,代码来源:MessageHandlerExceptionTests.cs
示例18: NewMediaFile
public override IMediaFile NewMediaFile(IFile file, MediaFileNodeType mediaFileNodeType)
{
var lastException = new NotSupportedException();
foreach (MediaFileFactory factory in this.ComponentFactories)
{
try
{
return factory.NewMediaFile(file, mediaFileNodeType);
}
catch (NotSupportedException e)
{
lastException = e;
}
}
throw lastException;
}
开发者ID:Euphrates-Media,项目名称:Platform.VirtualFileSystem,代码行数:18,代码来源:CompositeMediaFileFactory.cs
示例19: CheckValid
public void CheckValid(MethodInfo method, Attribute[] attributes, bool methodIsAsync)
{
if (!CheckedMethodCaches.ContainsKey(method))
{
var @params = method.GetParameters();
var delegateParam = @params.FirstOrDefault(p => typeof (Delegate).IsAssignableFrom(p.ParameterType));
if (delegateParam != null)
{
CheckedMethodCaches[method] = new NotSupportedException(string.Format("Dude, method {0} has param {1} is a delegate of type {2}. RPC call does not support delegate", method.Name, delegateParam.Name, delegateParam.ParameterType.FullName));
}
else if (method.DeclaringType != null && method.DeclaringType.GetProperties().Any(prop => prop.GetSetMethod() == method || prop.GetGetMethod() == method))
{
CheckedMethodCaches[method] = new NotSupportedException(string.Format("Dude, property accessor {0} is not supported for RPC call", method.Name));
}
else if (!methodIsAsync)
{
CheckedMethodCaches[method] = null;
}
else if (method.ReturnType != typeof (void))
{
CheckedMethodCaches[method] = new Exception(string.Format("Dude, method {0} requires to return a value but it's expected to run asynchronously", method.Name));
}
else foreach (var param in @params)
{
if (param.IsOut)
{
CheckedMethodCaches[method] = new Exception(string.Format("Dude, param '{0}' of method {1} is 'out' param, but the method is expected to run asynchronously", param.Name, method.Name));
break;
}
}
}
if (CheckedMethodCaches.ContainsKey(method) && CheckedMethodCaches[method] != null)
{
throw CheckedMethodCaches[method];
}
}
开发者ID:joefeser,项目名称:Burrow.NET,代码行数:43,代码来源:IMethodFilter.cs
示例20: GetMappingExceptionForHR
//.........这里部分代码省略.........
exception = new InvalidOperationException();
if (errorCode != __HResults.COR_E_INVALIDOPERATION)
shouldDisplayHR = true;
break;
case __HResults.COR_E_MARSHALDIRECTIVE:
exception = new MarshalDirectiveException();
break;
case __HResults.COR_E_METHODACCESS: // MethodAccessException
case __HResults.META_E_CA_FRIENDS_SN_REQUIRED: // MethodAccessException
case __HResults.COR_E_FIELDACCESS:
case __HResults.COR_E_MEMBERACCESS:
exception = new MemberAccessException();
if (errorCode != __HResults.COR_E_METHODACCESS)
shouldDisplayHR = true;
break;
case __HResults.COR_E_MISSINGFIELD: // MissingFieldException
case __HResults.COR_E_MISSINGMETHOD: // MissingMethodException
case __HResults.COR_E_MISSINGMEMBER:
case unchecked((int)0x800A01CD):
exception = new MissingMemberException();
break;
case __HResults.COR_E_MISSINGMANIFESTRESOURCE:
exception = new System.Resources.MissingManifestResourceException();
break;
case __HResults.COR_E_NOTSUPPORTED:
case unchecked((int)0x800A01B6):
case unchecked((int)0x800A01BD):
case unchecked((int)0x800A01CA):
case unchecked((int)0x800A01CB):
exception = new NotSupportedException();
if (errorCode != __HResults.COR_E_NOTSUPPORTED)
shouldDisplayHR = true;
break;
case __HResults.COR_E_NULLREFERENCE:
exception = new NullReferenceException();
break;
case __HResults.COR_E_OBJECTDISPOSED:
case __HResults.RO_E_CLOSED:
// No default constructor
exception = new ObjectDisposedException(String.Empty);
break;
case __HResults.COR_E_OPERATIONCANCELED:
#if ENABLE_WINRT
exception = new OperationCanceledException();
#endif
break;
case __HResults.COR_E_OVERFLOW:
case __HResults.CTL_E_OVERFLOW:
exception = new OverflowException();
break;
case __HResults.COR_E_PLATFORMNOTSUPPORTED:
exception = new PlatformNotSupportedException(message);
break;
case __HResults.COR_E_RANK:
exception = new RankException();
break;
case __HResults.COR_E_REFLECTIONTYPELOAD:
#if ENABLE_WINRT
exception = new System.Reflection.ReflectionTypeLoadException(null, null);
#endif
开发者ID:justinvp,项目名称:corert,代码行数:67,代码来源:ExceptionHelpers.cs
注:本文中的System.NotSupportedException类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论