Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / clr / src / BCL / System / Security / Policy / ApplicationDirectory.cs / 1 / ApplicationDirectory.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // ApplicationDirectory.cs // // ApplicationDirectory is an evidence type representing the directory the assembly // was loaded from. // namespace System.Security.Policy { using System; using System.IO; using System.Security.Util; using System.Collections; [Serializable] [System.Runtime.InteropServices.ComVisible(true)] sealed public class ApplicationDirectory : IBuiltInEvidence { private URLString m_appDirectory; internal ApplicationDirectory() { m_appDirectory = null; } public ApplicationDirectory( String name ) { if (name == null) throw new ArgumentNullException( "name" ); m_appDirectory = new URLString( name ); } public String Directory { get { return m_appDirectory.ToString(); } } public override bool Equals(Object o) { if (o == null) return false; if (o is ApplicationDirectory) { ApplicationDirectory appDir = (ApplicationDirectory) o; if (this.m_appDirectory == null) { return appDir.m_appDirectory == null; } else if (appDir.m_appDirectory == null) { return false; } else { return this.m_appDirectory.IsSubsetOf( appDir.m_appDirectory ) && appDir.m_appDirectory.IsSubsetOf( this.m_appDirectory ); } } return false; } public override int GetHashCode() { return this.Directory.GetHashCode(); } public Object Copy() { ApplicationDirectory appDir = new ApplicationDirectory(); appDir.m_appDirectory = this.m_appDirectory; return appDir; } internal SecurityElement ToXml() { SecurityElement root = new SecurityElement( "System.Security.Policy.ApplicationDirectory" ); // If you hit this assert then most likely you are trying to change the name of this class. // This is ok as long as you change the hard coded string above and change the assert below. BCLDebug.Assert( this.GetType().FullName.Equals( "System.Security.Policy.ApplicationDirectory" ), "Class name changed!" ); root.AddAttribute( "version", "1" ); if (m_appDirectory != null) root.AddChild( new SecurityElement( "Directory", m_appDirectory.ToString() ) ); return root; } ///int IBuiltInEvidence.OutputToBuffer( char[] buffer, int position, bool verbose ) { buffer[position++] = BuiltInEvidenceHelper.idApplicationDirectory; String directory = this.Directory; int length = directory.Length; if (verbose) { BuiltInEvidenceHelper.CopyIntToCharArray(length, buffer, position); position += 2; } directory.CopyTo( 0, buffer, position, length ); return length + position; } /// int IBuiltInEvidence.InitFromBuffer( char[] buffer, int position) { int length = BuiltInEvidenceHelper.GetIntFromCharArray(buffer, position); position += 2; m_appDirectory = new URLString( new String(buffer, position, length )); return position + length; } /// int IBuiltInEvidence.GetRequiredSize(bool verbose) { if (verbose) return this.Directory.Length + 3; // Directory + identifier + length else return this.Directory.Length + 1; // Directory + identifier } public override String ToString() { return ToXml().ToString(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== // ApplicationDirectory.cs // // ApplicationDirectory is an evidence type representing the directory the assembly // was loaded from. // namespace System.Security.Policy { using System; using System.IO; using System.Security.Util; using System.Collections; [Serializable] [System.Runtime.InteropServices.ComVisible(true)] sealed public class ApplicationDirectory : IBuiltInEvidence { private URLString m_appDirectory; internal ApplicationDirectory() { m_appDirectory = null; } public ApplicationDirectory( String name ) { if (name == null) throw new ArgumentNullException( "name" ); m_appDirectory = new URLString( name ); } public String Directory { get { return m_appDirectory.ToString(); } } public override bool Equals(Object o) { if (o == null) return false; if (o is ApplicationDirectory) { ApplicationDirectory appDir = (ApplicationDirectory) o; if (this.m_appDirectory == null) { return appDir.m_appDirectory == null; } else if (appDir.m_appDirectory == null) { return false; } else { return this.m_appDirectory.IsSubsetOf( appDir.m_appDirectory ) && appDir.m_appDirectory.IsSubsetOf( this.m_appDirectory ); } } return false; } public override int GetHashCode() { return this.Directory.GetHashCode(); } public Object Copy() { ApplicationDirectory appDir = new ApplicationDirectory(); appDir.m_appDirectory = this.m_appDirectory; return appDir; } internal SecurityElement ToXml() { SecurityElement root = new SecurityElement( "System.Security.Policy.ApplicationDirectory" ); // If you hit this assert then most likely you are trying to change the name of this class. // This is ok as long as you change the hard coded string above and change the assert below. BCLDebug.Assert( this.GetType().FullName.Equals( "System.Security.Policy.ApplicationDirectory" ), "Class name changed!" ); root.AddAttribute( "version", "1" ); if (m_appDirectory != null) root.AddChild( new SecurityElement( "Directory", m_appDirectory.ToString() ) ); return root; } /// int IBuiltInEvidence.OutputToBuffer( char[] buffer, int position, bool verbose ) { buffer[position++] = BuiltInEvidenceHelper.idApplicationDirectory; String directory = this.Directory; int length = directory.Length; if (verbose) { BuiltInEvidenceHelper.CopyIntToCharArray(length, buffer, position); position += 2; } directory.CopyTo( 0, buffer, position, length ); return length + position; } /// int IBuiltInEvidence.InitFromBuffer( char[] buffer, int position) { int length = BuiltInEvidenceHelper.GetIntFromCharArray(buffer, position); position += 2; m_appDirectory = new URLString( new String(buffer, position, length )); return position + length; } /// int IBuiltInEvidence.GetRequiredSize(bool verbose) { if (verbose) return this.Directory.Length + 3; // Directory + identifier + length else return this.Directory.Length + 1; // Directory + identifier } public override String ToString() { return ToXml().ToString(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UIElement.cs
- DocumentPageTextView.cs
- ArgumentValidation.cs
- XmlQueryTypeFactory.cs
- DodSequenceMerge.cs
- xml.cs
- TemplateBaseAction.cs
- IconConverter.cs
- ValidatingReaderNodeData.cs
- ServicePointManagerElement.cs
- NameValueSectionHandler.cs
- OracleFactory.cs
- Dynamic.cs
- ICspAsymmetricAlgorithm.cs
- DefaultEventAttribute.cs
- Brush.cs
- CodeMemberField.cs
- PresentationSource.cs
- xmlfixedPageInfo.cs
- JsonStringDataContract.cs
- Tool.cs
- WindowsGraphicsCacheManager.cs
- CardSpaceException.cs
- XmlCharacterData.cs
- StorageMappingItemLoader.cs
- UrlMapping.cs
- XmlSerializerNamespaces.cs
- JournalEntry.cs
- SmtpDigestAuthenticationModule.cs
- LicenseException.cs
- MarkedHighlightComponent.cs
- UrlMapping.cs
- SoapReflector.cs
- MetadataItem.cs
- StsCommunicationException.cs
- WebBrowserUriTypeConverter.cs
- ProcessInfo.cs
- DefaultPropertiesToSend.cs
- DataGridSortingEventArgs.cs
- KnownTypes.cs
- AccessKeyManager.cs
- VisualBasicValue.cs
- PanelStyle.cs
- HtmlLinkAdapter.cs
- SslStreamSecurityBindingElement.cs
- DataRelationPropertyDescriptor.cs
- RenamedEventArgs.cs
- FormViewRow.cs
- TextEditorSelection.cs
- EndOfStreamException.cs
- XNameTypeConverter.cs
- EventBuilder.cs
- DoubleAnimationClockResource.cs
- UdpDiscoveryMessageFilter.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- CrossSiteScriptingValidation.cs
- ContainerUIElement3D.cs
- Buffer.cs
- JsonFormatReaderGenerator.cs
- ColorTransform.cs
- XhtmlBasicLiteralTextAdapter.cs
- OrCondition.cs
- ExpressionPrefixAttribute.cs
- HashHelper.cs
- ListControl.cs
- DecimalFormatter.cs
- BindingManagerDataErrorEventArgs.cs
- RefType.cs
- ColumnWidthChangedEvent.cs
- TableLayoutStyleCollection.cs
- EdmEntityTypeAttribute.cs
- Accessors.cs
- HtmlHistory.cs
- UpdateCommand.cs
- DbXmlEnabledProviderManifest.cs
- BufferAllocator.cs
- ListViewCancelEventArgs.cs
- NetStream.cs
- WebControl.cs
- ValidationRule.cs
- PropertyValue.cs
- HttpCacheVary.cs
- DataGridCellInfo.cs
- TcpAppDomainProtocolHandler.cs
- FlowDocumentView.cs
- AddInIpcChannel.cs
- ExpandSegment.cs
- CharacterMetricsDictionary.cs
- xdrvalidator.cs
- TcpProcessProtocolHandler.cs
- FtpWebResponse.cs
- SequentialUshortCollection.cs
- basenumberconverter.cs
- DataServicePagingProviderWrapper.cs
- ColorMatrix.cs
- DesignBindingConverter.cs
- Setter.cs
- CatalogPart.cs
- DataGridViewCheckBoxCell.cs
- TwoPhaseCommit.cs