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
- ResourceManager.cs
- SingleKeyFrameCollection.cs
- ToolStripArrowRenderEventArgs.cs
- XmlSignificantWhitespace.cs
- BindableTemplateBuilder.cs
- SqlDataRecord.cs
- Type.cs
- ZoomPercentageConverter.cs
- ContentPropertyAttribute.cs
- BitmapEffectState.cs
- TranslateTransform.cs
- ListSortDescription.cs
- Component.cs
- DoubleStorage.cs
- Listbox.cs
- DateTimeValueSerializer.cs
- HashCoreRequest.cs
- EntityProviderFactory.cs
- PreservationFileWriter.cs
- RIPEMD160Managed.cs
- COM2PropertyBuilderUITypeEditor.cs
- XmlSchemaCompilationSettings.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- XmlSchemaNotation.cs
- DataGridViewAccessibleObject.cs
- ConnectionString.cs
- Track.cs
- HttpListenerContext.cs
- FlowDecision.cs
- ColorContext.cs
- WSIdentityFaultException.cs
- Boolean.cs
- DescendantOverDescendantQuery.cs
- StringBuilder.cs
- SoapBinding.cs
- MD5.cs
- Pkcs9Attribute.cs
- ProtectedConfigurationSection.cs
- Range.cs
- SolidBrush.cs
- DbDataSourceEnumerator.cs
- SpellerHighlightLayer.cs
- SqlConnectionStringBuilder.cs
- SendMailErrorEventArgs.cs
- MultiAsyncResult.cs
- StylusPlugInCollection.cs
- ElementProxy.cs
- ModelMemberCollection.cs
- IgnoreSectionHandler.cs
- InvocationExpression.cs
- DefaultClaimSet.cs
- securitycriticaldataClass.cs
- DataControlField.cs
- SubqueryTrackingVisitor.cs
- MatrixValueSerializer.cs
- TdsValueSetter.cs
- Grid.cs
- ReadOnlyDataSource.cs
- XmlCDATASection.cs
- MenuScrollingVisibilityConverter.cs
- XmlChoiceIdentifierAttribute.cs
- ObjectStateManager.cs
- COAUTHIDENTITY.cs
- TypeBrowserDialog.cs
- LZCodec.cs
- ToolStripGrip.cs
- CheckableControlBaseAdapter.cs
- StorageModelBuildProvider.cs
- XhtmlBasicLinkAdapter.cs
- TypedElement.cs
- BrushMappingModeValidation.cs
- TrackingProfile.cs
- CompiledQuery.cs
- WindowsNonControl.cs
- CorrelationToken.cs
- AxDesigner.cs
- OdbcDataAdapter.cs
- httpapplicationstate.cs
- ImportedNamespaceContextItem.cs
- UserNameSecurityTokenProvider.cs
- SqlRetyper.cs
- Util.cs
- IndependentlyAnimatedPropertyMetadata.cs
- DesignerTransaction.cs
- CodeGeneratorOptions.cs
- MetadataException.cs
- RegistrySecurity.cs
- COSERVERINFO.cs
- TemplatedAdorner.cs
- WebPartConnectionsDisconnectVerb.cs
- EnvelopedPkcs7.cs
- CodeCompiler.cs
- ClientApiGenerator.cs
- BindingBase.cs
- FlowDocumentPaginator.cs
- RadioButtonStandardAdapter.cs
- RequiredAttributeAttribute.cs
- JpegBitmapDecoder.cs
- Trace.cs
- HttpRawResponse.cs