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
- RelationshipEnd.cs
- MediaPlayerState.cs
- ToolStripPanelSelectionGlyph.cs
- HtmlMobileTextWriter.cs
- MyContact.cs
- X509ChainElement.cs
- EdmFunctionAttribute.cs
- TemplateControlParser.cs
- DataGridViewDataErrorEventArgs.cs
- MatrixTransform3D.cs
- FamilyCollection.cs
- TypeUnloadedException.cs
- PasswordPropertyTextAttribute.cs
- EventLogInformation.cs
- NoneExcludedImageIndexConverter.cs
- InputLanguage.cs
- SortDescription.cs
- DefaultParameterValueAttribute.cs
- GenericUriParser.cs
- ProviderConnectionPointCollection.cs
- EastAsianLunisolarCalendar.cs
- VirtualizingStackPanel.cs
- XamlPoint3DCollectionSerializer.cs
- CriticalHandle.cs
- Selection.cs
- ListBoxItem.cs
- SqlDataSource.cs
- SimpleTypeResolver.cs
- OutputCacheProfileCollection.cs
- Closure.cs
- TextReader.cs
- DataColumnCollection.cs
- Metafile.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- ObjectNavigationPropertyMapping.cs
- DataGridColumnDropSeparator.cs
- Cursor.cs
- ProtocolsConfiguration.cs
- ListBoxChrome.cs
- HttpContext.cs
- CapabilitiesAssignment.cs
- HttpResponseInternalBase.cs
- LinkConverter.cs
- FixedSOMLineCollection.cs
- InsufficientMemoryException.cs
- KerberosSecurityTokenProvider.cs
- NavigationWindow.cs
- Translator.cs
- SafeHandles.cs
- ControlAdapter.cs
- ConfigurationLoader.cs
- ResourceBinder.cs
- SafeArchiveContext.cs
- InstalledFontCollection.cs
- securitycriticaldataClass.cs
- Line.cs
- Bezier.cs
- UserNameSecurityToken.cs
- PermissionToken.cs
- SystemWebSectionGroup.cs
- DataGridTable.cs
- MemberCollection.cs
- AccessibleObject.cs
- OleDbStruct.cs
- AccessDataSource.cs
- RequiredAttributeAttribute.cs
- PackageDocument.cs
- MarkupExtensionReturnTypeAttribute.cs
- ToolStripSystemRenderer.cs
- DeflateStreamAsyncResult.cs
- sqlnorm.cs
- PolyLineSegmentFigureLogic.cs
- ValidatingCollection.cs
- Window.cs
- ApplyTemplatesAction.cs
- ManagedFilter.cs
- FormViewDeleteEventArgs.cs
- NameValueConfigurationElement.cs
- Solver.cs
- MenuItemAutomationPeer.cs
- PagedControl.cs
- Transform3DGroup.cs
- FamilyCollection.cs
- DataServiceClientException.cs
- EventHandlersDesigner.cs
- WindowsBrush.cs
- EmptyQuery.cs
- BitFlagsGenerator.cs
- EventSetterHandlerConverter.cs
- XmlArrayItemAttributes.cs
- DataGridViewColumnConverter.cs
- itemelement.cs
- _UncName.cs
- DataListItemEventArgs.cs
- EncoderNLS.cs
- ServiceBuildProvider.cs
- WebBrowserHelper.cs
- EntityProviderFactory.cs
- MenuItemStyle.cs
- HashMembershipCondition.cs