Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / Microsoft / Scripting / Ast / CatchBlock.cs / 1305376 / CatchBlock.cs
/* **************************************************************************** * * Copyright (c) Microsoft Corporation. * * This source code is subject to terms and conditions of the Microsoft Public License. A * copy of the license can be found in the License.html file at the root of this distribution. If * you cannot locate the Microsoft Public License, please send an email to * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound * by the terms of the Microsoft Public License. * * You must not remove this notice, or any other, from this software. * * * ***************************************************************************/ using System.Diagnostics; using System.Dynamic.Utils; #if SILVERLIGHT using System.Core; #endif namespace System.Linq.Expressions { ////// Represents a catch statement in a try block. /// This must have the same return type (i.e., the type of #if !SILVERLIGHT [DebuggerTypeProxy(typeof(Expression.CatchBlockProxy))] #endif public sealed class CatchBlock { private readonly Type _test; private readonly ParameterExpression _var; private readonly Expression _body; private readonly Expression _filter; internal CatchBlock(Type test, ParameterExpression variable, Expression body, Expression filter) { _test = test; _var = variable; _body = body; _filter = filter; } ///) as the try block it is associated with. /// /// Gets a reference to the public ParameterExpression Variable { get { return _var; } } ///object caught by this handler. /// /// Gets the type of public Type Test { get { return _test; } } ///this handler catches. /// /// Gets the body of the catch block. /// public Expression Body { get { return _body; } } ////// Gets the body of the public Expression Filter { get { return _filter; } } ///'s filter. /// /// Returns a ///that represents the current . /// A public override string ToString() { return ExpressionStringBuilder.CatchBlockToString(this); } ///that represents the current . /// Creates a new expression that is like this one, but using the /// supplied children. If all of the children are the same, it will /// return this expression. /// /// Theproperty of the result. /// The property of the result. /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public CatchBlock Update(ParameterExpression variable, Expression filter, Expression body) { if (variable == Variable && filter == Filter && body == Body) { return this; } return Expression.MakeCatchBlock(Test, variable, body, filter); } } public partial class Expression { ////// Creates a /// Therepresenting a catch statement. /// The of object to be caught can be specified but no reference to the object /// will be available for use in the . /// of this will handle. /// The body of the catch statement. /// The created public static CatchBlock Catch(Type type, Expression body) { return MakeCatchBlock(type, null, body, null); } ///. /// Creates a /// Arepresenting a catch statement with a reference to the caught object for use in the handler body. /// representing a reference to the object caught by this handler. /// The body of the catch statement. /// The created public static CatchBlock Catch(ParameterExpression variable, Expression body) { ContractUtils.RequiresNotNull(variable, "variable"); return MakeCatchBlock(variable.Type, variable, body, null); } ///. /// Creates a /// Therepresenting a catch statement with /// an filter but no reference to the caught object. /// of this will handle. /// The body of the catch statement. /// The body of the filter. /// The created public static CatchBlock Catch(Type type, Expression body, Expression filter) { return MakeCatchBlock(type, null, body, filter); } ///. /// Creates a /// Arepresenting a catch statement with /// an filter and a reference to the caught object. /// representing a reference to the object caught by this handler. /// The body of the catch statement. /// The body of the filter. /// The created public static CatchBlock Catch(ParameterExpression variable, Expression body, Expression filter) { ContractUtils.RequiresNotNull(variable, "variable"); return MakeCatchBlock(variable.Type, variable, body, filter); } ///. /// Creates a /// Therepresenting a catch statement with the specified elements. /// of this will handle. /// A representing a reference to the object caught by this handler. /// The body of the catch statement. /// The body of the filter. /// The created ///. public static CatchBlock MakeCatchBlock(Type type, ParameterExpression variable, Expression body, Expression filter) { ContractUtils.RequiresNotNull(type, "type"); ContractUtils.Requires(variable == null || TypeUtils.AreEquivalent(variable.Type, type), "variable"); if (variable != null && variable.IsByRef) { throw Error.VariableMustNotBeByRef(variable, variable.Type); } RequiresCanRead(body, "body"); if (filter != null) { RequiresCanRead(filter, "filter"); if (filter.Type != typeof(bool)) throw Error.ArgumentMustBeBoolean(); } return new CatchBlock(type, variable, body, filter); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /* **************************************************************************** * * Copyright (c) Microsoft Corporation. * * This source code is subject to terms and conditions of the Microsoft Public License. A * copy of the license can be found in the License.html file at the root of this distribution. If * you cannot locate the Microsoft Public License, please send an email to * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound * by the terms of the Microsoft Public License. * * You must not remove this notice, or any other, from this software. * * * ***************************************************************************/ using System.Diagnostics; using System.Dynamic.Utils; #if SILVERLIGHT using System.Core; #endif namespace System.Linq.Expressions { /// must be non-null and match the type of (if it is supplied). /// Represents a catch statement in a try block. /// This must have the same return type (i.e., the type of #if !SILVERLIGHT [DebuggerTypeProxy(typeof(Expression.CatchBlockProxy))] #endif public sealed class CatchBlock { private readonly Type _test; private readonly ParameterExpression _var; private readonly Expression _body; private readonly Expression _filter; internal CatchBlock(Type test, ParameterExpression variable, Expression body, Expression filter) { _test = test; _var = variable; _body = body; _filter = filter; } ///) as the try block it is associated with. /// /// Gets a reference to the public ParameterExpression Variable { get { return _var; } } ///object caught by this handler. /// /// Gets the type of public Type Test { get { return _test; } } ///this handler catches. /// /// Gets the body of the catch block. /// public Expression Body { get { return _body; } } ////// Gets the body of the public Expression Filter { get { return _filter; } } ///'s filter. /// /// Returns a ///that represents the current . /// A public override string ToString() { return ExpressionStringBuilder.CatchBlockToString(this); } ///that represents the current . /// Creates a new expression that is like this one, but using the /// supplied children. If all of the children are the same, it will /// return this expression. /// /// Theproperty of the result. /// The property of the result. /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public CatchBlock Update(ParameterExpression variable, Expression filter, Expression body) { if (variable == Variable && filter == Filter && body == Body) { return this; } return Expression.MakeCatchBlock(Test, variable, body, filter); } } public partial class Expression { ////// Creates a /// Therepresenting a catch statement. /// The of object to be caught can be specified but no reference to the object /// will be available for use in the . /// of this will handle. /// The body of the catch statement. /// The created public static CatchBlock Catch(Type type, Expression body) { return MakeCatchBlock(type, null, body, null); } ///. /// Creates a /// Arepresenting a catch statement with a reference to the caught object for use in the handler body. /// representing a reference to the object caught by this handler. /// The body of the catch statement. /// The created public static CatchBlock Catch(ParameterExpression variable, Expression body) { ContractUtils.RequiresNotNull(variable, "variable"); return MakeCatchBlock(variable.Type, variable, body, null); } ///. /// Creates a /// Therepresenting a catch statement with /// an filter but no reference to the caught object. /// of this will handle. /// The body of the catch statement. /// The body of the filter. /// The created public static CatchBlock Catch(Type type, Expression body, Expression filter) { return MakeCatchBlock(type, null, body, filter); } ///. /// Creates a /// Arepresenting a catch statement with /// an filter and a reference to the caught object. /// representing a reference to the object caught by this handler. /// The body of the catch statement. /// The body of the filter. /// The created public static CatchBlock Catch(ParameterExpression variable, Expression body, Expression filter) { ContractUtils.RequiresNotNull(variable, "variable"); return MakeCatchBlock(variable.Type, variable, body, filter); } ///. /// Creates a /// Therepresenting a catch statement with the specified elements. /// of this will handle. /// A representing a reference to the object caught by this handler. /// The body of the catch statement. /// The body of the filter. /// The created ///. public static CatchBlock MakeCatchBlock(Type type, ParameterExpression variable, Expression body, Expression filter) { ContractUtils.RequiresNotNull(type, "type"); ContractUtils.Requires(variable == null || TypeUtils.AreEquivalent(variable.Type, type), "variable"); if (variable != null && variable.IsByRef) { throw Error.VariableMustNotBeByRef(variable, variable.Type); } RequiresCanRead(body, "body"); if (filter != null) { RequiresCanRead(filter, "filter"); if (filter.Type != typeof(bool)) throw Error.ArgumentMustBeBoolean(); } return new CatchBlock(type, variable, body, filter); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. must be non-null and match the type of (if it is supplied).
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CryptoHandle.cs
- Manipulation.cs
- TemplateInstanceAttribute.cs
- QueryInterceptorAttribute.cs
- BinaryMessageEncoder.cs
- DataTableReader.cs
- FullTextBreakpoint.cs
- SecurityCriticalDataForSet.cs
- MdImport.cs
- DataGridColumn.cs
- XmlConvert.cs
- TextBoxRenderer.cs
- UInt32.cs
- DispatcherSynchronizationContext.cs
- UriGenerator.cs
- MimeReflector.cs
- TracingConnectionInitiator.cs
- ReferencedType.cs
- WeakReferenceList.cs
- IgnoreFlushAndCloseStream.cs
- DependencyObject.cs
- CheckableControlBaseAdapter.cs
- HttpHandlerActionCollection.cs
- NameValueSectionHandler.cs
- SqlCacheDependencySection.cs
- PopupControlService.cs
- DispatchChannelSink.cs
- TypeGeneratedEventArgs.cs
- TreeNodeCollection.cs
- ConfigXmlElement.cs
- SafeCancelMibChangeNotify.cs
- validationstate.cs
- XmlCharCheckingReader.cs
- SQlBooleanStorage.cs
- Statements.cs
- RequestSecurityTokenResponse.cs
- Trustee.cs
- ObjectMemberMapping.cs
- PageSettings.cs
- formatstringdialog.cs
- followingquery.cs
- BasicSecurityProfileVersion.cs
- BooleanKeyFrameCollection.cs
- RelationshipEndCollection.cs
- DataGridViewComboBoxEditingControl.cs
- dbenumerator.cs
- Activator.cs
- XpsS0ValidatingLoader.cs
- LabelLiteral.cs
- RectangleGeometry.cs
- PaperSize.cs
- NameScope.cs
- AssemblyBuilderData.cs
- StateManagedCollection.cs
- TextViewBase.cs
- HttpApplication.cs
- WebCategoryAttribute.cs
- PropagatorResult.cs
- SchemaManager.cs
- Wizard.cs
- ObjectDataSourceSelectingEventArgs.cs
- ComponentManagerBroker.cs
- SimpleBitVector32.cs
- Popup.cs
- FixedSOMTable.cs
- UriTemplateTableMatchCandidate.cs
- MemberDomainMap.cs
- XmlILModule.cs
- PerformanceCounterCategory.cs
- HttpResponse.cs
- CollectionViewProxy.cs
- ColumnResizeUndoUnit.cs
- FontSizeConverter.cs
- SqlUserDefinedTypeAttribute.cs
- BitmapEffectGroup.cs
- XmlAttributeCache.cs
- DataGridViewCellStyleChangedEventArgs.cs
- Decimal.cs
- PackagePartCollection.cs
- SmtpDigestAuthenticationModule.cs
- HttpResponse.cs
- WorkflowTerminatedException.cs
- HtmlLabelAdapter.cs
- ColorTranslator.cs
- GridErrorDlg.cs
- VScrollProperties.cs
- DiagnosticTrace.cs
- NextPreviousPagerField.cs
- ConfigXmlDocument.cs
- TemplatedEditableDesignerRegion.cs
- TextSpanModifier.cs
- ArgumentOutOfRangeException.cs
- FontNamesConverter.cs
- XPathItem.cs
- InstanceData.cs
- ChannelReliableSession.cs
- HelpKeywordAttribute.cs
- QilGenerator.cs
- ListItemsCollectionEditor.cs
- ApplicationContext.cs