Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Log / System / IO / Log / PolicyUnit.cs / 1305376 / PolicyUnit.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.IO.Log
{
using System;
using System.Globalization;
public struct PolicyUnit
{
PolicyUnitType type;
long value;
public PolicyUnit(long value, PolicyUnitType type)
{
if (type == PolicyUnitType.Percentage)
{
if ((value < 0) || (value > 100))
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ArgumentOutOfRange("value"));
}
else if (type == PolicyUnitType.Extents)
{
if (value < 0)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ArgumentOutOfRange("value"));
}
else
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ArgumentOutOfRange("type"));
}
this.type = type;
this.value = value;
}
public PolicyUnitType Type
{
get
{
return this.type;
}
}
public long Value
{
get
{
return this.value;
}
}
public override int GetHashCode()
{
return (this.type.GetHashCode() ^
this.value.GetHashCode());
}
public override bool Equals(object obj)
{
if (!(obj is PolicyUnit)) return false;
PolicyUnit other = (PolicyUnit)(obj);
return this == other;
}
public static bool operator ==(PolicyUnit left, PolicyUnit right)
{
return ((left.type == right.type) &&
(left.value == right.value));
}
public static bool operator !=(PolicyUnit left, PolicyUnit right)
{
return !(left == right);
}
public static PolicyUnit Percentage(long value)
{
return new PolicyUnit(value, PolicyUnitType.Percentage);
}
public static PolicyUnit Extents(long value)
{
return new PolicyUnit(value, PolicyUnitType.Extents);
}
public override string ToString()
{
if (this.type == PolicyUnitType.Percentage)
{
return SR.GetString(SR.PolicyUnit_Percent, this.value);
}
else
{
return SR.GetString(SR.PolicyUnit_Extents, this.value);
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.IO.Log
{
using System;
using System.Globalization;
public struct PolicyUnit
{
PolicyUnitType type;
long value;
public PolicyUnit(long value, PolicyUnitType type)
{
if (type == PolicyUnitType.Percentage)
{
if ((value < 0) || (value > 100))
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ArgumentOutOfRange("value"));
}
else if (type == PolicyUnitType.Extents)
{
if (value < 0)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ArgumentOutOfRange("value"));
}
else
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ArgumentOutOfRange("type"));
}
this.type = type;
this.value = value;
}
public PolicyUnitType Type
{
get
{
return this.type;
}
}
public long Value
{
get
{
return this.value;
}
}
public override int GetHashCode()
{
return (this.type.GetHashCode() ^
this.value.GetHashCode());
}
public override bool Equals(object obj)
{
if (!(obj is PolicyUnit)) return false;
PolicyUnit other = (PolicyUnit)(obj);
return this == other;
}
public static bool operator ==(PolicyUnit left, PolicyUnit right)
{
return ((left.type == right.type) &&
(left.value == right.value));
}
public static bool operator !=(PolicyUnit left, PolicyUnit right)
{
return !(left == right);
}
public static PolicyUnit Percentage(long value)
{
return new PolicyUnit(value, PolicyUnitType.Percentage);
}
public static PolicyUnit Extents(long value)
{
return new PolicyUnit(value, PolicyUnitType.Extents);
}
public override string ToString()
{
if (this.type == PolicyUnitType.Percentage)
{
return SR.GetString(SR.PolicyUnit_Percent, this.value);
}
else
{
return SR.GetString(SR.PolicyUnit_Extents, this.value);
}
}
}
}
// 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
- CollectionViewSource.cs
- COM2ExtendedUITypeEditor.cs
- HtmlHead.cs
- BindingCompleteEventArgs.cs
- SoapSchemaMember.cs
- TextContainer.cs
- Trace.cs
- HostedAspNetEnvironment.cs
- HttpStreamMessageEncoderFactory.cs
- DispatcherOperation.cs
- RichTextBoxConstants.cs
- OutputCacheProfile.cs
- DefaultBinder.cs
- ToolStripItemTextRenderEventArgs.cs
- PixelFormats.cs
- filewebrequest.cs
- SessionSwitchEventArgs.cs
- SafeArrayRankMismatchException.cs
- WebPartConnectionsCancelEventArgs.cs
- CanonicalXml.cs
- HttpRequest.cs
- CalendarTable.cs
- ApplicationServiceManager.cs
- SchemaInfo.cs
- ToolStripDropDown.cs
- IndentedTextWriter.cs
- GridView.cs
- MimeObjectFactory.cs
- WebRequestModuleElement.cs
- UserInitiatedNavigationPermission.cs
- SafeFileHandle.cs
- GridViewColumnCollectionChangedEventArgs.cs
- HttpHandlerAction.cs
- CheckPair.cs
- _NegoState.cs
- DataGridTable.cs
- CommonGetThemePartSize.cs
- XmlSchemaDocumentation.cs
- TimerElapsedEvenArgs.cs
- InputBinder.cs
- UniformGrid.cs
- XmlSchemaComplexType.cs
- Assembly.cs
- SoapParser.cs
- XamlValidatingReader.cs
- SqlCaseSimplifier.cs
- SortableBindingList.cs
- IsolatedStorageFile.cs
- XmlNamedNodeMap.cs
- CheckBox.cs
- PolyBezierSegment.cs
- DefaultProxySection.cs
- DefaultEventAttribute.cs
- PassportAuthenticationEventArgs.cs
- FormViewPagerRow.cs
- TraceHandler.cs
- ResXBuildProvider.cs
- BrowserCapabilitiesFactoryBase.cs
- ProfilePropertySettingsCollection.cs
- DataStreamFromComStream.cs
- ListDictionaryInternal.cs
- FlagsAttribute.cs
- DllNotFoundException.cs
- PassportPrincipal.cs
- MobileTemplatedControlDesigner.cs
- DatatypeImplementation.cs
- StateRuntime.cs
- PixelFormat.cs
- objectresult_tresulttype.cs
- ResolvedKeyFrameEntry.cs
- InProcStateClientManager.cs
- SchemaType.cs
- MimeMapping.cs
- TransformDescriptor.cs
- DecoderFallback.cs
- XmlSchemaIdentityConstraint.cs
- SchemaElementLookUpTable.cs
- Journal.cs
- AssemblyFilter.cs
- DbParameterHelper.cs
- DocumentPageView.cs
- RoutedEvent.cs
- LocalBuilder.cs
- EndEvent.cs
- CodeGenerator.cs
- CodeSubDirectoriesCollection.cs
- URI.cs
- OleDbException.cs
- ScrollEvent.cs
- NavigationWindow.cs
- RegexMatchCollection.cs
- SystemEvents.cs
- PipelineModuleStepContainer.cs
- ExpressionWriter.cs
- WasEndpointConfigContainer.cs
- QilGeneratorEnv.cs
- EdgeProfileValidation.cs
- ChannelSinkStacks.cs
- StylusCollection.cs
- ProfileModule.cs