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
- TypeForwardedToAttribute.cs
- SkipStoryboardToFill.cs
- CodeTypeParameterCollection.cs
- OdbcConnectionString.cs
- Matrix3D.cs
- CatalogZone.cs
- ClassHandlersStore.cs
- TraceInternal.cs
- HostedHttpRequestAsyncResult.cs
- ParameterReplacerVisitor.cs
- AccessorTable.cs
- AtomPub10CategoriesDocumentFormatter.cs
- CodeGenerator.cs
- NameValueConfigurationElement.cs
- RelationshipNavigation.cs
- DPTypeDescriptorContext.cs
- ToolStripComboBox.cs
- XmlArrayAttribute.cs
- HMACSHA512.cs
- FixedTextPointer.cs
- HtmlLink.cs
- MsmqTransportElement.cs
- PipelineModuleStepContainer.cs
- Variant.cs
- NamedPipeProcessProtocolHandler.cs
- __Filters.cs
- RelationalExpressions.cs
- CodeBlockBuilder.cs
- BroadcastEventHelper.cs
- Clipboard.cs
- SparseMemoryStream.cs
- IUnknownConstantAttribute.cs
- TemplateKey.cs
- ButtonColumn.cs
- MLangCodePageEncoding.cs
- SettingsPropertyIsReadOnlyException.cs
- ClientType.cs
- KeyEventArgs.cs
- SignalGate.cs
- Typography.cs
- FilterFactory.cs
- MarshalByValueComponent.cs
- base64Transforms.cs
- AutomationPattern.cs
- SerialErrors.cs
- ColorAnimationBase.cs
- TemplateContentLoader.cs
- ControlPropertyNameConverter.cs
- Main.cs
- BamlResourceSerializer.cs
- TypefaceCollection.cs
- FixedSOMImage.cs
- NextPreviousPagerField.cs
- LicenseManager.cs
- EntityDataSourceQueryBuilder.cs
- ExceptionValidationRule.cs
- PlainXmlDeserializer.cs
- ReflectionUtil.cs
- Visual.cs
- CompiledQuery.cs
- TaskFactory.cs
- TransactionInformation.cs
- UidManager.cs
- LocationSectionRecord.cs
- HtmlTableCell.cs
- NamespaceList.cs
- ExtractedStateEntry.cs
- DateTimeFormat.cs
- XmlILAnnotation.cs
- AutomationEvent.cs
- TypeKeyValue.cs
- SerializationStore.cs
- CryptoConfig.cs
- Comparer.cs
- xmlsaver.cs
- LinkUtilities.cs
- DataControlFieldCell.cs
- DictionaryBase.cs
- Point3DAnimation.cs
- KeyedHashAlgorithm.cs
- GenericTextProperties.cs
- LocalizabilityAttribute.cs
- AxisAngleRotation3D.cs
- StateItem.cs
- ListItemCollection.cs
- ProvidersHelper.cs
- RoleManagerSection.cs
- Graph.cs
- SimpleColumnProvider.cs
- ExtendedProperty.cs
- ActivityUtilities.cs
- InvalidCommandTreeException.cs
- PathHelper.cs
- UidManager.cs
- TreeNodeCollection.cs
- GridViewRowEventArgs.cs
- ListBox.cs
- FixedSOMPageConstructor.cs
- StackBuilderSink.cs
- SessionState.cs