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 / URL.cs / 1 / URL.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//
// Url.cs
//
// Url is an IIdentity representing url internet sites.
//
namespace System.Security.Policy {
using System.IO;
using System.Security.Util;
using UrlIdentityPermission = System.Security.Permissions.UrlIdentityPermission;
using System.Runtime.Serialization;
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
sealed public class Url : IIdentityPermissionFactory, IBuiltInEvidence
{
private URLString m_url;
internal Url()
{
m_url = null;
}
internal Url( SerializationInfo info, StreamingContext context )
{
m_url = new URLString( (String)info.GetValue( "Url", typeof( String ) ) );
}
internal Url( String name, bool parsed )
{
if (name == null)
throw new ArgumentNullException( "name" );
m_url = new URLString( name, parsed );
}
public Url( String name )
{
if (name == null)
throw new ArgumentNullException( "name" );
m_url = new URLString( name );
}
public String Value
{
get
{
if (m_url == null) return null;
return m_url.ToString();
}
}
internal URLString GetURLString()
{
return m_url;
}
public IPermission CreateIdentityPermission( Evidence evidence )
{
return new UrlIdentityPermission( m_url );
}
public override bool Equals(Object o)
{
if (o == null)
return false;
if (o is Url)
{
Url url = (Url) o;
if (this.m_url == null)
{
return url.m_url == null;
}
else if (url.m_url == null)
{
return false;
}
else
{
return this.m_url.Equals( url.m_url );
}
}
return false;
}
public override int GetHashCode()
{
if (this.m_url == null)
return 0;
else
return this.m_url.GetHashCode();
}
public Object Copy()
{
Url url = new Url();
url.m_url = this.m_url;
return url;
}
internal SecurityElement ToXml()
{
SecurityElement root = new SecurityElement( "System.Security.Policy.Url" );
// 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.Url" ), "Class name changed!" );
root.AddAttribute( "version", "1" );
if (m_url != null)
root.AddChild( new SecurityElement( "Url", m_url.ToString() ) );
return root;
}
public override String ToString()
{
return ToXml().ToString();
}
///
int IBuiltInEvidence.OutputToBuffer( char[] buffer, int position, bool verbose )
{
buffer[position++] = BuiltInEvidenceHelper.idUrl;
String value = this.Value;
int length = value.Length;
if (verbose)
{
BuiltInEvidenceHelper.CopyIntToCharArray(length, buffer, position);
position += 2;
}
value.CopyTo( 0, buffer, position, length );
return length + position;
}
///
int IBuiltInEvidence.GetRequiredSize(bool verbose )
{
if (verbose)
return this.Value.Length + 3;
else
return this.Value.Length + 1;
}
///
int IBuiltInEvidence.InitFromBuffer( char[] buffer, int position)
{
int length = BuiltInEvidenceHelper.GetIntFromCharArray(buffer, position);
position += 2;
m_url = new URLString( new String(buffer, position, length ));
return position + length;
}
#if false
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
String normalizedUrl = m_url.NormalizeUrl();
info.AddValue( "Url", normalizedUrl );
}
#endif
// INormalizeForIsolatedStorage is not implemented for startup perf
// equivalent to INormalizeForIsolatedStorage.Normalize()
internal Object Normalize()
{
return m_url.NormalizeUrl();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
//
// Url.cs
//
// Url is an IIdentity representing url internet sites.
//
namespace System.Security.Policy {
using System.IO;
using System.Security.Util;
using UrlIdentityPermission = System.Security.Permissions.UrlIdentityPermission;
using System.Runtime.Serialization;
[Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
sealed public class Url : IIdentityPermissionFactory, IBuiltInEvidence
{
private URLString m_url;
internal Url()
{
m_url = null;
}
internal Url( SerializationInfo info, StreamingContext context )
{
m_url = new URLString( (String)info.GetValue( "Url", typeof( String ) ) );
}
internal Url( String name, bool parsed )
{
if (name == null)
throw new ArgumentNullException( "name" );
m_url = new URLString( name, parsed );
}
public Url( String name )
{
if (name == null)
throw new ArgumentNullException( "name" );
m_url = new URLString( name );
}
public String Value
{
get
{
if (m_url == null) return null;
return m_url.ToString();
}
}
internal URLString GetURLString()
{
return m_url;
}
public IPermission CreateIdentityPermission( Evidence evidence )
{
return new UrlIdentityPermission( m_url );
}
public override bool Equals(Object o)
{
if (o == null)
return false;
if (o is Url)
{
Url url = (Url) o;
if (this.m_url == null)
{
return url.m_url == null;
}
else if (url.m_url == null)
{
return false;
}
else
{
return this.m_url.Equals( url.m_url );
}
}
return false;
}
public override int GetHashCode()
{
if (this.m_url == null)
return 0;
else
return this.m_url.GetHashCode();
}
public Object Copy()
{
Url url = new Url();
url.m_url = this.m_url;
return url;
}
internal SecurityElement ToXml()
{
SecurityElement root = new SecurityElement( "System.Security.Policy.Url" );
// 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.Url" ), "Class name changed!" );
root.AddAttribute( "version", "1" );
if (m_url != null)
root.AddChild( new SecurityElement( "Url", m_url.ToString() ) );
return root;
}
public override String ToString()
{
return ToXml().ToString();
}
///
int IBuiltInEvidence.OutputToBuffer( char[] buffer, int position, bool verbose )
{
buffer[position++] = BuiltInEvidenceHelper.idUrl;
String value = this.Value;
int length = value.Length;
if (verbose)
{
BuiltInEvidenceHelper.CopyIntToCharArray(length, buffer, position);
position += 2;
}
value.CopyTo( 0, buffer, position, length );
return length + position;
}
///
int IBuiltInEvidence.GetRequiredSize(bool verbose )
{
if (verbose)
return this.Value.Length + 3;
else
return this.Value.Length + 1;
}
///
int IBuiltInEvidence.InitFromBuffer( char[] buffer, int position)
{
int length = BuiltInEvidenceHelper.GetIntFromCharArray(buffer, position);
position += 2;
m_url = new URLString( new String(buffer, position, length ));
return position + length;
}
#if false
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
String normalizedUrl = m_url.NormalizeUrl();
info.AddValue( "Url", normalizedUrl );
}
#endif
// INormalizeForIsolatedStorage is not implemented for startup perf
// equivalent to INormalizeForIsolatedStorage.Normalize()
internal Object Normalize()
{
return m_url.NormalizeUrl();
}
}
}
// 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
- WebPartAddingEventArgs.cs
- CalculatedColumn.cs
- COM2PropertyDescriptor.cs
- ByteFacetDescriptionElement.cs
- ProxyFragment.cs
- CustomCredentialPolicy.cs
- BindingExpressionBase.cs
- SwitchLevelAttribute.cs
- BitmapEffectGeneralTransform.cs
- Hash.cs
- RelatedView.cs
- SecurityPermission.cs
- EndEvent.cs
- Calendar.cs
- NativeMethods.cs
- CellConstantDomain.cs
- ListViewCancelEventArgs.cs
- StorageMappingFragment.cs
- RuntimeEnvironment.cs
- SimpleTypeResolver.cs
- DynamicValidator.cs
- OSFeature.cs
- SyndicationFeed.cs
- CompiledIdentityConstraint.cs
- DataGridPagerStyle.cs
- ObjectDataSourceStatusEventArgs.cs
- SizeChangedInfo.cs
- MdImport.cs
- OraclePermissionAttribute.cs
- XmlWellformedWriterHelpers.cs
- Binding.cs
- XmlUnspecifiedAttribute.cs
- StaticExtension.cs
- QueueProcessor.cs
- Solver.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- PropertyChangedEventArgs.cs
- CompilerState.cs
- DataServiceQuery.cs
- ListMarkerLine.cs
- BuilderPropertyEntry.cs
- ObjectIDGenerator.cs
- DBSqlParserColumn.cs
- RecommendedAsConfigurableAttribute.cs
- ObjectQuery_EntitySqlExtensions.cs
- MasterPageBuildProvider.cs
- PersonalizationStateQuery.cs
- ConfigurationFileMap.cs
- CanonicalFontFamilyReference.cs
- LocalFileSettingsProvider.cs
- OutputCacheProviderCollection.cs
- EmptyStringExpandableObjectConverter.cs
- XamlFrame.cs
- SharedPersonalizationStateInfo.cs
- TableColumn.cs
- XPathException.cs
- LassoHelper.cs
- TextBounds.cs
- NetworkStream.cs
- IndexedDataBuffer.cs
- AtomServiceDocumentSerializer.cs
- StatusStrip.cs
- KnownBoxes.cs
- SchemaTableColumn.cs
- JavaScriptSerializer.cs
- XmlILAnnotation.cs
- ObjectQuery.cs
- UnitControl.cs
- ComPlusDiagnosticTraceRecords.cs
- CheckedPointers.cs
- InputLangChangeRequestEvent.cs
- MatrixTransform3D.cs
- Enlistment.cs
- SoapObjectInfo.cs
- UnsafeNativeMethods.cs
- Int64Animation.cs
- RuntimeHelpers.cs
- StateFinalizationActivity.cs
- Invariant.cs
- IODescriptionAttribute.cs
- QueryCacheEntry.cs
- BaseDataBoundControlDesigner.cs
- ProgressChangedEventArgs.cs
- InvalidDataException.cs
- ProtocolsSection.cs
- LateBoundBitmapDecoder.cs
- RefreshEventArgs.cs
- objectquery_tresulttype.cs
- DataViewSetting.cs
- DataAdapter.cs
- CipherData.cs
- WebProxyScriptElement.cs
- GenericXmlSecurityToken.cs
- ConstantSlot.cs
- DirectoryObjectSecurity.cs
- ProfessionalColorTable.cs
- DateRangeEvent.cs
- CompilerCollection.cs
- ObjectConverter.cs
- MouseGestureConverter.cs