Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Runtime / Remoting / ProxyAttribute.cs / 1 / ProxyAttribute.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** File: ProxyAttribute.cs ** ** ** Purpose: Defines the attribute that is used on types which ** need custom proxies. ** ** ===========================================================*/ namespace System.Runtime.Remoting.Proxies { using System.Reflection; using System.Runtime.Remoting.Activation; using System.Runtime.Remoting.Contexts; using System.Security.Permissions; // Attribute for types that need custom proxies [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] [SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.Infrastructure)] [SecurityPermissionAttribute(SecurityAction.InheritanceDemand, Flags=SecurityPermissionFlag.Infrastructure)] [System.Runtime.InteropServices.ComVisible(true)] public class ProxyAttribute : Attribute , IContextAttribute { public ProxyAttribute() { // Default constructor } // Default implementation of CreateInstance uses our activation services to create an instance // of the transparent proxy or an uninitialized marshalbyrefobject and returns it. public virtual MarshalByRefObject CreateInstance(Type serverType) { if (!serverType.IsContextful) { throw new RemotingException( Environment.GetResourceString( "Remoting_Activation_MBR_ProxyAttribute")); } if (serverType.IsAbstract) { throw new RemotingException( Environment.GetResourceString( "Acc_CreateAbst")); } return CreateInstanceInternal(serverType); } internal MarshalByRefObject CreateInstanceInternal(Type serverType) { return ActivationServices.CreateInstance(serverType); } // Default implementation of CreateProxy creates an instance of our // remoting proxy public virtual RealProxy CreateProxy(ObjRef objRef, Type serverType, Object serverObject, Context serverContext) { RemotingProxy rp = new RemotingProxy(serverType); // If this is a serverID, set the native context field in the TP if (null != serverContext) { RealProxy.SetStubData(rp, serverContext.InternalContextID); } if (objRef != null && objRef.GetServerIdentity().IsAllocated) { rp.SetSrvInfo(objRef.GetServerIdentity(), objRef.GetDomainID()); } // Set the flag indicating that the fields of the proxy // have been initialized rp.Initialized = true; // Sanity check Type t = serverType; if (!t.IsContextful && !t.IsMarshalByRef && (null != serverContext)) { throw new RemotingException( Environment.GetResourceString( "Remoting_Activation_MBR_ProxyAttribute")); } return rp; } // implementation of interface IContextAttribute [System.Runtime.InteropServices.ComVisible(true)] public bool IsContextOK(Context ctx, IConstructionCallMessage msg) { // always happy... return true; } [System.Runtime.InteropServices.ComVisible(true)] public void GetPropertiesForNewContext(IConstructionCallMessage msg) { // chill.. do nothing. return; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RectangleConverter.cs
- InteropBitmapSource.cs
- WebPartConnectVerb.cs
- AnimatedTypeHelpers.cs
- BrowserPolicyValidator.cs
- QueryRewriter.cs
- GenerateTemporaryTargetAssembly.cs
- XmlQualifiedNameTest.cs
- _AutoWebProxyScriptHelper.cs
- Constant.cs
- DetailsViewPageEventArgs.cs
- NCryptSafeHandles.cs
- SkewTransform.cs
- BindingCollection.cs
- UidManager.cs
- RoutedCommand.cs
- SqlUDTStorage.cs
- LineServicesCallbacks.cs
- AdapterDictionary.cs
- HttpModule.cs
- DeploymentSection.cs
- Page.cs
- ExtensionSurface.cs
- DictionaryItemsCollection.cs
- CodeNamespace.cs
- KeyedPriorityQueue.cs
- AVElementHelper.cs
- WebHttpSecurityElement.cs
- OracleRowUpdatedEventArgs.cs
- InputLangChangeEvent.cs
- StrongBox.cs
- ZoneButton.cs
- AnimationLayer.cs
- SqlFunctionAttribute.cs
- Type.cs
- WmlMobileTextWriter.cs
- SafeNativeMethods.cs
- ToolStripItem.cs
- ConfigurationSettings.cs
- RecipientInfo.cs
- CodeMemberMethod.cs
- GAC.cs
- IInstanceTable.cs
- DataGridLengthConverter.cs
- Page.cs
- UpdateException.cs
- Utils.cs
- CodeDOMProvider.cs
- EventLogPermissionEntry.cs
- StoreItemCollection.Loader.cs
- SID.cs
- NewExpression.cs
- Quaternion.cs
- SymmetricSecurityProtocol.cs
- MetaChildrenColumn.cs
- Region.cs
- NamespaceMapping.cs
- OdbcHandle.cs
- DispatcherProcessingDisabled.cs
- EventHandlerList.cs
- BoundPropertyEntry.cs
- DateTimeValueSerializer.cs
- SQLDouble.cs
- UrlMapping.cs
- WpfKnownMemberInvoker.cs
- Label.cs
- Adorner.cs
- TranslateTransform.cs
- BindingWorker.cs
- WebControlToolBoxItem.cs
- EmbeddedMailObject.cs
- DependencyPropertyKind.cs
- DoubleAnimationBase.cs
- DependencyPropertyHelper.cs
- ContentFileHelper.cs
- ImageList.cs
- OutputScopeManager.cs
- ValidationErrorCollection.cs
- SecurityAlgorithmSuite.cs
- ItemsPanelTemplate.cs
- KnownBoxes.cs
- PageCodeDomTreeGenerator.cs
- LinkDescriptor.cs
- ExpressionQuoter.cs
- ResXBuildProvider.cs
- Button.cs
- SqlNotificationEventArgs.cs
- RestrictedTransactionalPackage.cs
- TreeNode.cs
- StyleSelector.cs
- ObjectDataSourceChooseTypePanel.cs
- XslVisitor.cs
- OverflowException.cs
- BooleanKeyFrameCollection.cs
- ErrorHandler.cs
- Enum.cs
- ListControl.cs
- DragCompletedEventArgs.cs
- BitmapEffect.cs
- XmlLanguageConverter.cs