Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / Microsoft / Scripting / Utils / Helpers.cs / 1305376 / Helpers.cs
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Microsoft Public License. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Microsoft Public License, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Microsoft Public License.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
using System.Collections.Generic;
using System.Linq.Expressions;
namespace System.Dynamic.Utils {
// Miscellaneous helpers that don't belong anywhere else
internal static class Helpers {
internal static T CommonNode(T first, T second, Func parent) where T : class {
var cmp = EqualityComparer.Default;
if (cmp.Equals(first, second)) {
return first;
}
var set = new Set(cmp);
for (T t = first; t != null; t = parent(t)) {
set.Add(t);
}
for (T t = second; t != null; t = parent(t)) {
if (set.Contains(t)) {
return t;
}
}
return null;
}
internal static void IncrementCount(T key, Dictionary dict) {
int count;
dict.TryGetValue(key, out count);
dict[key] = count + 1;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
/* ****************************************************************************
*
* Copyright (c) Microsoft Corporation.
*
* This source code is subject to terms and conditions of the Microsoft Public License. A
* copy of the license can be found in the License.html file at the root of this distribution. If
* you cannot locate the Microsoft Public License, please send an email to
* dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
* by the terms of the Microsoft Public License.
*
* You must not remove this notice, or any other, from this software.
*
*
* ***************************************************************************/
using System.Collections.Generic;
using System.Linq.Expressions;
namespace System.Dynamic.Utils {
// Miscellaneous helpers that don't belong anywhere else
internal static class Helpers {
internal static T CommonNode(T first, T second, Func parent) where T : class {
var cmp = EqualityComparer.Default;
if (cmp.Equals(first, second)) {
return first;
}
var set = new Set(cmp);
for (T t = first; t != null; t = parent(t)) {
set.Add(t);
}
for (T t = second; t != null; t = parent(t)) {
if (set.Contains(t)) {
return t;
}
}
return null;
}
internal static void IncrementCount(T key, Dictionary dict) {
int count;
dict.TryGetValue(key, out count);
dict[key] = count + 1;
}
}
}
// 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
- WebRequestModuleElementCollection.cs
- TreeViewHitTestInfo.cs
- TableLayoutPanelResizeGlyph.cs
- GridViewDeletedEventArgs.cs
- URL.cs
- SchemaCollectionPreprocessor.cs
- ImageAutomationPeer.cs
- SafeEventLogWriteHandle.cs
- ToolStripItem.cs
- XamlSerializationHelper.cs
- ContentType.cs
- Storyboard.cs
- FilterRepeater.cs
- Inline.cs
- _Rfc2616CacheValidators.cs
- MiniAssembly.cs
- MenuStrip.cs
- ScriptResourceAttribute.cs
- HtmlInputRadioButton.cs
- ResourceProperty.cs
- SafeBitVector32.cs
- updateconfighost.cs
- TextBoxBase.cs
- IndexedGlyphRun.cs
- DecoderFallback.cs
- TransformedBitmap.cs
- DataServiceRequestException.cs
- ConfigurationUtility.cs
- DataSourceViewSchemaConverter.cs
- ManifestResourceInfo.cs
- BevelBitmapEffect.cs
- ZipIOFileItemStream.cs
- FastEncoder.cs
- InternalResources.cs
- TypeElement.cs
- ProcessingInstructionAction.cs
- DataGridViewSortCompareEventArgs.cs
- SendActivityDesignerTheme.cs
- SoapExtensionImporter.cs
- ContextMenuAutomationPeer.cs
- NCryptNative.cs
- MimeMapping.cs
- StaticContext.cs
- PipeException.cs
- DbConnectionInternal.cs
- ExchangeUtilities.cs
- HtmlElementErrorEventArgs.cs
- SqlFormatter.cs
- MediaCommands.cs
- ToolStripItemTextRenderEventArgs.cs
- objectresult_tresulttype.cs
- ApplicationInfo.cs
- DataServiceQueryProvider.cs
- DispatcherFrame.cs
- EntryIndex.cs
- LoadRetryAsyncResult.cs
- PopupEventArgs.cs
- Collection.cs
- LinkUtilities.cs
- bidPrivateBase.cs
- CheckBoxBaseAdapter.cs
- EntitySqlException.cs
- BrowserCapabilitiesFactory.cs
- CompilationRelaxations.cs
- IndexingContentUnit.cs
- StreamWithDictionary.cs
- BufferedGraphicsManager.cs
- ObjectAnimationBase.cs
- DesignerOptionService.cs
- MD5CryptoServiceProvider.cs
- BooleanAnimationBase.cs
- Deserializer.cs
- ThreadNeutralSemaphore.cs
- RuleSettings.cs
- EventManager.cs
- RC2.cs
- ProviderCollection.cs
- _ListenerResponseStream.cs
- AssemblyGen.cs
- Mappings.cs
- SapiRecognizer.cs
- RandomNumberGenerator.cs
- Html32TextWriter.cs
- XmlSchemaRedefine.cs
- TypeSystemProvider.cs
- LocatorGroup.cs
- DocumentPageView.cs
- CanExecuteRoutedEventArgs.cs
- ApplyTemplatesAction.cs
- AppDomainEvidenceFactory.cs
- Paragraph.cs
- WebPartZone.cs
- precedingsibling.cs
- SqlFileStream.cs
- Soap.cs
- XmlUrlResolver.cs
- PathSegment.cs
- ManifestSignatureInformation.cs
- Int32AnimationUsingKeyFrames.cs
- Configuration.cs