Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / 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(); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AssemblyBuilderData.cs
- ScriptMethodAttribute.cs
- GAC.cs
- Pointer.cs
- TdsParserSessionPool.cs
- MemberHolder.cs
- AppDomainShutdownMonitor.cs
- CqlGenerator.cs
- DataTablePropertyDescriptor.cs
- ProtectedConfiguration.cs
- DbProviderServices.cs
- HttpRequestContext.cs
- LogicalExpressionEditor.cs
- _DomainName.cs
- FilterableData.cs
- AlphaSortedEnumConverter.cs
- ResourceReferenceKeyNotFoundException.cs
- UIPropertyMetadata.cs
- DecimalConstantAttribute.cs
- MembershipSection.cs
- followingquery.cs
- QilLoop.cs
- ListBindingHelper.cs
- RTLAwareMessageBox.cs
- TimeoutTimer.cs
- DrawTreeNodeEventArgs.cs
- MailWebEventProvider.cs
- VersionPair.cs
- SByte.cs
- CommandExpr.cs
- followingquery.cs
- cookie.cs
- XmlElementList.cs
- XmlSignatureProperties.cs
- BitmapVisualManager.cs
- COAUTHINFO.cs
- XmlHierarchyData.cs
- ObjectKeyFrameCollection.cs
- FormViewDesigner.cs
- HTMLTagNameToTypeMapper.cs
- FastEncoderWindow.cs
- VBCodeProvider.cs
- TypeNameParser.cs
- SafeThemeHandle.cs
- Message.cs
- FilterQuery.cs
- RefreshPropertiesAttribute.cs
- MenuItemBindingCollection.cs
- RegionInfo.cs
- Property.cs
- WindowsSysHeader.cs
- SqlDataReader.cs
- WinInet.cs
- MulticastDelegate.cs
- UIPermission.cs
- StdValidatorsAndConverters.cs
- AutoSizeToolBoxItem.cs
- GlyphRunDrawing.cs
- HelpProvider.cs
- FamilyCollection.cs
- SystemColors.cs
- Win32Interop.cs
- MethodAccessException.cs
- ImageClickEventArgs.cs
- BuilderPropertyEntry.cs
- TextEditorCopyPaste.cs
- EntityReference.cs
- DropDownList.cs
- __ConsoleStream.cs
- ActivityCodeDomSerializer.cs
- SmtpAuthenticationManager.cs
- SqlDataSourceStatusEventArgs.cs
- TraceFilter.cs
- URLMembershipCondition.cs
- AssemblyCache.cs
- BaseParser.cs
- CodeExpressionCollection.cs
- BindingValueChangedEventArgs.cs
- PerformanceCounterPermission.cs
- ConfigurationFileMap.cs
- XmlAtomicValue.cs
- AddInProcess.cs
- IgnoreSection.cs
- SequenceQuery.cs
- RichTextBox.cs
- DocumentViewerConstants.cs
- StyleCollectionEditor.cs
- BooleanSwitch.cs
- VisualStyleElement.cs
- AngleUtil.cs
- SafeNativeMethodsOther.cs
- TextEmbeddedObject.cs
- SafeFileMappingHandle.cs
- XsdValidatingReader.cs
- CommandExpr.cs
- WorkflowApplication.cs
- ContentPlaceHolder.cs
- Source.cs
- AuthenticateEventArgs.cs
- ProcessMessagesAsyncResult.cs