Code:
/ DotNET / DotNET / 8.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
- ImportOptions.cs
- FormattedTextSymbols.cs
- Rfc2898DeriveBytes.cs
- DataStreams.cs
- EdmProperty.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- _LocalDataStore.cs
- X509SecurityTokenAuthenticator.cs
- JournalEntry.cs
- WebServiceAttribute.cs
- WebServiceErrorEvent.cs
- WebPartConnectionsConfigureVerb.cs
- BaseTreeIterator.cs
- NumericUpDownAcceleration.cs
- FixedSOMImage.cs
- TextMessageEncodingBindingElement.cs
- NetworkCredential.cs
- TargetParameterCountException.cs
- BindableTemplateBuilder.cs
- WinInetCache.cs
- TemplateComponentConnector.cs
- InfoCard.cs
- WeakReference.cs
- CommonXSendMessage.cs
- StoreItemCollection.Loader.cs
- IdentitySection.cs
- PrtTicket_Public_Simple.cs
- NativeMethods.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- ModelPropertyImpl.cs
- TextTreeTextBlock.cs
- QilXmlWriter.cs
- EncoderParameter.cs
- MailMessageEventArgs.cs
- EmbeddedMailObject.cs
- UrlPath.cs
- MatrixValueSerializer.cs
- BindingValueChangedEventArgs.cs
- PropertyConverter.cs
- ServiceThrottle.cs
- CriticalExceptions.cs
- UpdateCommandGenerator.cs
- WebColorConverter.cs
- COAUTHINFO.cs
- StreamedFramingRequestChannel.cs
- ToolStripSeparator.cs
- EventLogPermissionEntryCollection.cs
- NodeLabelEditEvent.cs
- XmlDataSource.cs
- CodeDomSerializerBase.cs
- CheckBoxStandardAdapter.cs
- GPRECT.cs
- FaultCallbackWrapper.cs
- basevalidator.cs
- DataGridColumnCollection.cs
- VirtualizedContainerService.cs
- ParserStreamGeometryContext.cs
- TrackingLocation.cs
- ADConnectionHelper.cs
- DataError.cs
- EntryWrittenEventArgs.cs
- SqlUDTStorage.cs
- MarkupProperty.cs
- PageWrapper.cs
- SiteMapDataSource.cs
- Tag.cs
- ConsumerConnectionPointCollection.cs
- ToolStripItem.cs
- HttpWebRequestElement.cs
- FlowNode.cs
- TextTreeTextNode.cs
- SafeNativeMethods.cs
- ComponentCache.cs
- PrintControllerWithStatusDialog.cs
- BaseDataBoundControl.cs
- SimpleModelProvider.cs
- XmlComplianceUtil.cs
- Error.cs
- FormsAuthenticationUserCollection.cs
- SettingsBase.cs
- LinkedList.cs
- ScrollItemProviderWrapper.cs
- RecipientInfo.cs
- BamlResourceDeserializer.cs
- CompiledXpathExpr.cs
- ParentQuery.cs
- PartialList.cs
- CustomAttribute.cs
- TokenBasedSet.cs
- DynamicDiscoveryDocument.cs
- TextFormatterImp.cs
- FieldInfo.cs
- MetadataArtifactLoader.cs
- EntityConnectionStringBuilderItem.cs
- Module.cs
- IndexerNameAttribute.cs
- WebServiceParameterData.cs
- CompensatableSequenceActivity.cs
- URL.cs
- BinaryQueryOperator.cs