Code:
/ FX-1434 / FX-1434 / 1.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
- BaseDataBoundControl.cs
- XmlSchemaAttributeGroup.cs
- SerializationUtilities.cs
- DockPattern.cs
- COM2TypeInfoProcessor.cs
- RenameRuleObjectDialog.Designer.cs
- TogglePattern.cs
- Int32CAMarshaler.cs
- TypeDescriptorContext.cs
- Descriptor.cs
- HttpServerProtocol.cs
- DataControlPagerLinkButton.cs
- DataColumnChangeEvent.cs
- StringWriter.cs
- TypeDescriptorFilterService.cs
- BaseCodePageEncoding.cs
- CompositeDuplexBindingElementImporter.cs
- ServiceElement.cs
- FileDataSource.cs
- SerializationFieldInfo.cs
- AssertFilter.cs
- TextOutput.cs
- MgmtResManager.cs
- CodeMemberEvent.cs
- XmlKeywords.cs
- HybridDictionary.cs
- CodeMethodReturnStatement.cs
- WebZone.cs
- MailMessageEventArgs.cs
- LogPolicy.cs
- ClassDataContract.cs
- Separator.cs
- Thumb.cs
- PropertyFilterAttribute.cs
- ParameterCollection.cs
- XmlNavigatorFilter.cs
- Profiler.cs
- TablePatternIdentifiers.cs
- ContentHostHelper.cs
- CryptoApi.cs
- GAC.cs
- ResetableIterator.cs
- AxParameterData.cs
- OdbcConnection.cs
- SizeChangedInfo.cs
- FileLevelControlBuilderAttribute.cs
- FixedLineResult.cs
- PreviewPrintController.cs
- ObjectConverter.cs
- StringValueSerializer.cs
- NegationPusher.cs
- TableLayoutStyleCollection.cs
- METAHEADER.cs
- OraclePermission.cs
- TriggerBase.cs
- WindowsRichEdit.cs
- TableParaClient.cs
- StringFunctions.cs
- SQLChars.cs
- GetWinFXPath.cs
- WindowsListViewGroup.cs
- WindowsEditBoxRange.cs
- GetPageCompletedEventArgs.cs
- File.cs
- Missing.cs
- MobilePage.cs
- IntSecurity.cs
- SelectedDatesCollection.cs
- SignatureDescription.cs
- StorageConditionPropertyMapping.cs
- XslTransform.cs
- RepeaterItemEventArgs.cs
- Win32KeyboardDevice.cs
- SspiHelper.cs
- ScriptingSectionGroup.cs
- RegexCompiler.cs
- ErrorWebPart.cs
- PointCollectionValueSerializer.cs
- Intellisense.cs
- DataSourceListEditor.cs
- PageRouteHandler.cs
- AuthenticationServiceManager.cs
- LiteralTextContainerControlBuilder.cs
- TextRunCache.cs
- TraceSection.cs
- KnownAssembliesSet.cs
- ParsedAttributeCollection.cs
- NativeBuffer.cs
- sqlcontext.cs
- DefaultMemberAttribute.cs
- Int32Storage.cs
- ElementsClipboardData.cs
- InheritedPropertyDescriptor.cs
- ExtensionsSection.cs
- EntitySetRetriever.cs
- BadImageFormatException.cs
- Transform.cs
- EnumDataContract.cs
- baseshape.cs
- DataGridViewColumnStateChangedEventArgs.cs