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
- IDQuery.cs
- PeerObject.cs
- BufferedGraphicsContext.cs
- TypeSource.cs
- AuthenticationModuleElementCollection.cs
- SafeHandles.cs
- CodeMethodReturnStatement.cs
- NamespaceCollection.cs
- ServiceManager.cs
- ResourceContainer.cs
- TemplatingOptionsDialog.cs
- ToolBarButtonClickEvent.cs
- TabControlEvent.cs
- SemanticBasicElement.cs
- WindowVisualStateTracker.cs
- QilLoop.cs
- StrokeCollectionConverter.cs
- DynamicValidatorEventArgs.cs
- XmlSchemaComplexContentExtension.cs
- LoginStatusDesigner.cs
- SafeNativeMethods.cs
- Marshal.cs
- WebHttpElement.cs
- RequestQueue.cs
- FormsAuthenticationCredentials.cs
- Directory.cs
- StringValidatorAttribute.cs
- CaretElement.cs
- ReliableChannelBinder.cs
- AttachmentCollection.cs
- Properties.cs
- ListViewDataItem.cs
- Assert.cs
- DataChangedEventManager.cs
- OrthographicCamera.cs
- Section.cs
- UIntPtr.cs
- XmlCodeExporter.cs
- HTMLTextWriter.cs
- VisualStyleElement.cs
- CodeAssignStatement.cs
- TextEditorContextMenu.cs
- FormsIdentity.cs
- SchemaNamespaceManager.cs
- IsolatedStorageFilePermission.cs
- InkCanvasInnerCanvas.cs
- SafeNativeMethods.cs
- BinaryParser.cs
- CodeGroup.cs
- HttpFileCollection.cs
- InstanceDescriptor.cs
- SendParametersContent.cs
- JobCollate.cs
- RouteParameter.cs
- QueryResponse.cs
- Stack.cs
- CompatibleComparer.cs
- XpsFilter.cs
- LockedAssemblyCache.cs
- FloaterBaseParaClient.cs
- CodeArrayCreateExpression.cs
- LockRecoveryTask.cs
- WebPartsSection.cs
- TextWriterEngine.cs
- DLinqTableProvider.cs
- DataPagerFieldCommandEventArgs.cs
- panel.cs
- CommentEmitter.cs
- SkipQueryOptionExpression.cs
- GatewayIPAddressInformationCollection.cs
- CodeDelegateInvokeExpression.cs
- NamedPipeAppDomainProtocolHandler.cs
- TextEditorCharacters.cs
- DocumentGrid.cs
- PerformanceCountersElement.cs
- BitmapDownload.cs
- RSACryptoServiceProvider.cs
- CodeAssignStatement.cs
- ValidationRule.cs
- PieceDirectory.cs
- Int32Storage.cs
- VarRefManager.cs
- ScrollableControl.cs
- HtmlEmptyTagControlBuilder.cs
- AdPostCacheSubstitution.cs
- IntSecurity.cs
- MapPathBasedVirtualPathProvider.cs
- webproxy.cs
- XmlUtf8RawTextWriter.cs
- HtmlContainerControl.cs
- DataGridViewCellCollection.cs
- PermissionSetTriple.cs
- InstanceNormalEvent.cs
- DbProviderFactory.cs
- cache.cs
- XsdBuildProvider.cs
- PagedControl.cs
- GridViewColumnCollection.cs
- ViewStateException.cs
- XomlCompilerResults.cs