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
- TypeDescriptor.cs
- EarlyBoundInfo.cs
- XsltLibrary.cs
- ObservableDictionary.cs
- BlockCollection.cs
- RectangleHotSpot.cs
- GeneralTransform3DGroup.cs
- CodeAttachEventStatement.cs
- TypeInfo.cs
- WebConfigurationHost.cs
- TextChangedEventArgs.cs
- Control.cs
- AutomationPatternInfo.cs
- errorpatternmatcher.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- SqlProviderUtilities.cs
- WindowShowOrOpenTracker.cs
- Automation.cs
- PDBReader.cs
- RequestCachingSection.cs
- Lasso.cs
- XmlValueConverter.cs
- WebControlAdapter.cs
- StrokeCollection.cs
- SafeLocalAllocation.cs
- cookie.cs
- CodeGen.cs
- GetLastErrorDetailsRequest.cs
- Comparer.cs
- XamlFilter.cs
- StorageComplexTypeMapping.cs
- XpsSerializationException.cs
- SessionStateModule.cs
- HttpCookie.cs
- ImageField.cs
- CharacterHit.cs
- PriorityQueue.cs
- TokenBasedSetEnumerator.cs
- NamedPipeConnectionPoolSettingsElement.cs
- CompareInfo.cs
- DelimitedListTraceListener.cs
- QueueProcessor.cs
- DATA_BLOB.cs
- StrongName.cs
- _StreamFramer.cs
- Color.cs
- ThrowHelper.cs
- DataSourceXmlSerializationAttribute.cs
- Message.cs
- WebPartMenu.cs
- LogPolicy.cs
- GPStream.cs
- ParallelTimeline.cs
- ParallelDesigner.cs
- AttributeEmitter.cs
- Roles.cs
- Propagator.cs
- AuthenticatingEventArgs.cs
- RelationshipEndMember.cs
- NullableFloatAverageAggregationOperator.cs
- WebConfigurationHostFileChange.cs
- ColorContextHelper.cs
- MembershipValidatePasswordEventArgs.cs
- ExtentKey.cs
- ImageClickEventArgs.cs
- TypeSystemHelpers.cs
- OracleInternalConnection.cs
- ellipse.cs
- DynamicMethod.cs
- CompilerTypeWithParams.cs
- GenericTypeParameterBuilder.cs
- SystemTcpConnection.cs
- Point3DCollectionConverter.cs
- ChildTable.cs
- WebPartRestoreVerb.cs
- PathSegment.cs
- XmlCodeExporter.cs
- SingleResultAttribute.cs
- JsonClassDataContract.cs
- OutputCacheSettings.cs
- XmlSchemaFacet.cs
- externdll.cs
- OracleCommand.cs
- Image.cs
- RenderDataDrawingContext.cs
- shaperfactoryquerycachekey.cs
- TargetControlTypeAttribute.cs
- Expressions.cs
- ECDiffieHellmanCng.cs
- FixedPosition.cs
- ContextToken.cs
- MessageLogger.cs
- PerfCounterSection.cs
- ScopelessEnumAttribute.cs
- XpsDocument.cs
- SqlBulkCopy.cs
- WaitHandleCannotBeOpenedException.cs
- XmlExtensionFunction.cs
- securestring.cs
- PropertyRecord.cs