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
- SmiMetaData.cs
- BinaryFormatter.cs
- PrintControllerWithStatusDialog.cs
- IPAddress.cs
- CheckBoxStandardAdapter.cs
- ZipIOCentralDirectoryBlock.cs
- TimeEnumHelper.cs
- VisualStyleElement.cs
- ModuleElement.cs
- KeyGestureConverter.cs
- VersionPair.cs
- TaskDesigner.cs
- StandardToolWindows.cs
- HtmlProps.cs
- ReadWriteObjectLock.cs
- ConfigViewGenerator.cs
- DependencyProperty.cs
- Guid.cs
- ButtonColumn.cs
- XmlDataSourceView.cs
- TextElementCollectionHelper.cs
- SynchronizationValidator.cs
- CharacterString.cs
- ListItem.cs
- RenderDataDrawingContext.cs
- OdbcConnectionPoolProviderInfo.cs
- EndpointConfigContainer.cs
- GridToolTip.cs
- UniqueConstraint.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- CngKeyCreationParameters.cs
- MSHTMLHost.cs
- ChtmlCalendarAdapter.cs
- WebPartCloseVerb.cs
- SignatureHelper.cs
- Stack.cs
- FormViewPagerRow.cs
- ServiceDeploymentInfo.cs
- UnmanagedMemoryStream.cs
- DBNull.cs
- QueryOperationResponseOfT.cs
- Maps.cs
- DBSqlParserTableCollection.cs
- CompilerScopeManager.cs
- ArrayConverter.cs
- DataSourceComponent.cs
- SystemIPInterfaceStatistics.cs
- AttachedPropertyMethodSelector.cs
- TextElementCollectionHelper.cs
- UnsafeNativeMethods.cs
- XsltContext.cs
- Hash.cs
- AnnotationHighlightLayer.cs
- Dynamic.cs
- FileLevelControlBuilderAttribute.cs
- IndexingContentUnit.cs
- RedirectionProxy.cs
- StylusPlugin.cs
- UrlPropertyAttribute.cs
- BufferCache.cs
- UDPClient.cs
- externdll.cs
- SessionIDManager.cs
- LogicalCallContext.cs
- InternalCache.cs
- IEnumerable.cs
- FrameSecurityDescriptor.cs
- AutomationElement.cs
- DataGridViewRowDividerDoubleClickEventArgs.cs
- MetaForeignKeyColumn.cs
- InternalsVisibleToAttribute.cs
- Module.cs
- FactoryGenerator.cs
- DecoderFallback.cs
- SystemNetworkInterface.cs
- GridViewCommandEventArgs.cs
- DataRecord.cs
- _CookieModule.cs
- ListViewGroupItemCollection.cs
- TcpSocketManager.cs
- BoundColumn.cs
- bidPrivateBase.cs
- ManipulationDeltaEventArgs.cs
- TextPattern.cs
- OneOfScalarConst.cs
- HttpResponseInternalWrapper.cs
- ResourceKey.cs
- ApplicationServicesHostFactory.cs
- COM2ComponentEditor.cs
- AsymmetricKeyExchangeDeformatter.cs
- LinkButton.cs
- ForceCopyBuildProvider.cs
- Operators.cs
- PenLineJoinValidation.cs
- RuntimeEnvironment.cs
- FactoryRecord.cs
- InertiaExpansionBehavior.cs
- SchemaObjectWriter.cs
- Invariant.cs
- GeneralTransform2DTo3DTo2D.cs