Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / System / Windows / LocalValueEnumerator.cs / 1305600 / LocalValueEnumerator.cs
using System; using System.Collections; using System.Diagnostics; using MS.Internal.WindowsBase; #pragma warning disable 1634, 1691 // suppressing PreSharp warnings namespace System.Windows { ////// Local value enumeration object /// ////// Modifying local values (via SetValue or ClearValue) during enumeration /// is unsupported /// public struct LocalValueEnumerator : IEnumerator { ////// Overrides Object.GetHashCode /// ///An integer that represents the hashcode for this object public override int GetHashCode() { return base.GetHashCode(); } ////// Determine equality /// public override bool Equals(object obj) { if(obj is LocalValueEnumerator) { LocalValueEnumerator other = (LocalValueEnumerator) obj; return (_count == other._count && _index == other._index && _snapshot == other._snapshot); } else { // being compared against something that isn't a LocalValueEnumerator. return false; } } ////// Determine equality /// public static bool operator ==(LocalValueEnumerator obj1, LocalValueEnumerator obj2) { return obj1.Equals(obj2); } ////// Determine inequality /// public static bool operator !=(LocalValueEnumerator obj1, LocalValueEnumerator obj2) { return !(obj1 == obj2); } ////// Get current entry /// public LocalValueEntry Current { get { if(_index == -1 ) { #pragma warning suppress 6503 // IEnumerator.Current is documented to throw this exception throw new InvalidOperationException(SR.Get(SRID.LocalValueEnumerationReset)); } if(_index >= Count ) { #pragma warning suppress 6503 // IEnumerator.Current is documented to throw this exception throw new InvalidOperationException(SR.Get(SRID.LocalValueEnumerationOutOfBounds)); } return _snapshot[_index]; } } ////// Get current entry (object reference based) /// object IEnumerator.Current { get { return Current; } } ////// Move to the next item in the enumerator /// ///Success of the method public bool MoveNext() { _index++; return _index < Count; } ////// Reset enumeration /// public void Reset() { _index = -1; } ////// Return number of items represented in the collection /// public int Count { get { return _count; } } internal LocalValueEnumerator(LocalValueEntry[] snapshot, int count) { _index = -1; _count = count; _snapshot = snapshot; } private int _index; private LocalValueEntry[] _snapshot; private int _count; } ////// Represents a Property-Value pair for local value enumeration /// public struct LocalValueEntry { ////// Overrides Object.GetHashCode /// ///An integer that represents the hashcode for this object public override int GetHashCode() { return base.GetHashCode(); } ////// Determine equality /// public override bool Equals(object obj) { LocalValueEntry other = (LocalValueEntry) obj; return (_dp == other._dp && _value == other._value); } ////// Determine equality /// public static bool operator ==(LocalValueEntry obj1, LocalValueEntry obj2) { return obj1.Equals(obj2); } ////// Determine inequality /// public static bool operator !=(LocalValueEntry obj1, LocalValueEntry obj2) { return !(obj1 == obj2); } ////// Dependency property /// public DependencyProperty Property { get { return _dp; } } ////// Value of the property /// public object Value { get { return _value; } } internal LocalValueEntry(DependencyProperty dp, object value) { _dp = dp; _value = value; } // Internal here because we need to change these around when building // the snapshot for the LocalValueEnumerator, and we can't make internal // setters when we have public getters. internal DependencyProperty _dp; internal object _value; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections; using System.Diagnostics; using MS.Internal.WindowsBase; #pragma warning disable 1634, 1691 // suppressing PreSharp warnings namespace System.Windows { ////// Local value enumeration object /// ////// Modifying local values (via SetValue or ClearValue) during enumeration /// is unsupported /// public struct LocalValueEnumerator : IEnumerator { ////// Overrides Object.GetHashCode /// ///An integer that represents the hashcode for this object public override int GetHashCode() { return base.GetHashCode(); } ////// Determine equality /// public override bool Equals(object obj) { if(obj is LocalValueEnumerator) { LocalValueEnumerator other = (LocalValueEnumerator) obj; return (_count == other._count && _index == other._index && _snapshot == other._snapshot); } else { // being compared against something that isn't a LocalValueEnumerator. return false; } } ////// Determine equality /// public static bool operator ==(LocalValueEnumerator obj1, LocalValueEnumerator obj2) { return obj1.Equals(obj2); } ////// Determine inequality /// public static bool operator !=(LocalValueEnumerator obj1, LocalValueEnumerator obj2) { return !(obj1 == obj2); } ////// Get current entry /// public LocalValueEntry Current { get { if(_index == -1 ) { #pragma warning suppress 6503 // IEnumerator.Current is documented to throw this exception throw new InvalidOperationException(SR.Get(SRID.LocalValueEnumerationReset)); } if(_index >= Count ) { #pragma warning suppress 6503 // IEnumerator.Current is documented to throw this exception throw new InvalidOperationException(SR.Get(SRID.LocalValueEnumerationOutOfBounds)); } return _snapshot[_index]; } } ////// Get current entry (object reference based) /// object IEnumerator.Current { get { return Current; } } ////// Move to the next item in the enumerator /// ///Success of the method public bool MoveNext() { _index++; return _index < Count; } ////// Reset enumeration /// public void Reset() { _index = -1; } ////// Return number of items represented in the collection /// public int Count { get { return _count; } } internal LocalValueEnumerator(LocalValueEntry[] snapshot, int count) { _index = -1; _count = count; _snapshot = snapshot; } private int _index; private LocalValueEntry[] _snapshot; private int _count; } ////// Represents a Property-Value pair for local value enumeration /// public struct LocalValueEntry { ////// Overrides Object.GetHashCode /// ///An integer that represents the hashcode for this object public override int GetHashCode() { return base.GetHashCode(); } ////// Determine equality /// public override bool Equals(object obj) { LocalValueEntry other = (LocalValueEntry) obj; return (_dp == other._dp && _value == other._value); } ////// Determine equality /// public static bool operator ==(LocalValueEntry obj1, LocalValueEntry obj2) { return obj1.Equals(obj2); } ////// Determine inequality /// public static bool operator !=(LocalValueEntry obj1, LocalValueEntry obj2) { return !(obj1 == obj2); } ////// Dependency property /// public DependencyProperty Property { get { return _dp; } } ////// Value of the property /// public object Value { get { return _value; } } internal LocalValueEntry(DependencyProperty dp, object value) { _dp = dp; _value = value; } // Internal here because we need to change these around when building // the snapshot for the LocalValueEnumerator, and we can't make internal // setters when we have public getters. internal DependencyProperty _dp; internal object _value; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ImportCatalogPart.cs
- DataContext.cs
- HtmlElement.cs
- EvidenceBase.cs
- Button.cs
- StreamReader.cs
- FacetChecker.cs
- WebBrowserNavigatingEventHandler.cs
- UseLicense.cs
- TextSpanModifier.cs
- DataControlField.cs
- FixUp.cs
- BindToObject.cs
- WebConfigurationHost.cs
- CompilationUtil.cs
- Solver.cs
- XmlSchemaExporter.cs
- ButtonColumn.cs
- ByValueEqualityComparer.cs
- SchemaSetCompiler.cs
- XdrBuilder.cs
- XamlFilter.cs
- IriParsingElement.cs
- HtmlTernaryTree.cs
- ProgressBarHighlightConverter.cs
- RepeatButtonAutomationPeer.cs
- OracleConnection.cs
- AnimatedTypeHelpers.cs
- PropertyTabAttribute.cs
- WindowsStatic.cs
- OutputCacheSettings.cs
- RemoteWebConfigurationHostServer.cs
- StrokeNodeData.cs
- Membership.cs
- AnnotationResourceCollection.cs
- StrokeNode.cs
- Matrix3DValueSerializer.cs
- ProviderException.cs
- DynamicPhysicalDiscoSearcher.cs
- InputProviderSite.cs
- AuthenticationConfig.cs
- ComplexType.cs
- ObjectToken.cs
- DbConnectionFactory.cs
- ObjectCloneHelper.cs
- Rules.cs
- MenuAutomationPeer.cs
- BitmapEffectOutputConnector.cs
- ModelFunction.cs
- TemplatePartAttribute.cs
- WhitespaceRule.cs
- SqlVisitor.cs
- TreeSet.cs
- WhitespaceRuleLookup.cs
- MarkerProperties.cs
- TemplateColumn.cs
- KeyTime.cs
- ApplicationHost.cs
- Types.cs
- JapaneseCalendar.cs
- UpDownEvent.cs
- ConfigXmlWhitespace.cs
- DashStyles.cs
- RelatedImageListAttribute.cs
- ISAPIApplicationHost.cs
- HttpSessionStateWrapper.cs
- MatrixTransform.cs
- SqlOuterApplyReducer.cs
- ArithmeticException.cs
- DotExpr.cs
- BrowserCapabilitiesCompiler.cs
- XmlSchemaDocumentation.cs
- CompModSwitches.cs
- DataTrigger.cs
- XmlChildEnumerator.cs
- SecurityCriticalDataForSet.cs
- RequestCachePolicy.cs
- AssemblySettingAttributes.cs
- ParallelForEach.cs
- EmptyEnumerable.cs
- SqlUnionizer.cs
- GenericTypeParameterBuilder.cs
- ImagingCache.cs
- SHA1.cs
- DataPagerFieldCollection.cs
- XmlElementAttributes.cs
- StoreItemCollection.Loader.cs
- MULTI_QI.cs
- PrinterUnitConvert.cs
- WinEventWrap.cs
- IPGlobalProperties.cs
- ContentPosition.cs
- DataServiceRequest.cs
- DocumentViewerConstants.cs
- TextEditorParagraphs.cs
- NativeMethods.cs
- EDesignUtil.cs
- XmlQueryStaticData.cs
- TypeNameHelper.cs
- GraphicsState.cs