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
- LoginDesigner.cs
- DbConnectionPoolGroupProviderInfo.cs
- TextEffect.cs
- DrawingVisual.cs
- Attributes.cs
- XmlDownloadManager.cs
- TreeNodeEventArgs.cs
- HwndMouseInputProvider.cs
- XhtmlStyleClass.cs
- TextEditorLists.cs
- HttpWebRequest.cs
- Attribute.cs
- SiteMapNodeItem.cs
- TypeSemantics.cs
- VScrollProperties.cs
- RenderingEventArgs.cs
- HtmlEncodedRawTextWriter.cs
- _NativeSSPI.cs
- ProfileEventArgs.cs
- MetadataArtifactLoaderResource.cs
- QueryServiceConfigHandle.cs
- XmlHierarchyData.cs
- BitFlagsGenerator.cs
- CreateParams.cs
- XPathItem.cs
- ResXResourceWriter.cs
- StatusBar.cs
- CheckBoxRenderer.cs
- localization.cs
- _MultipleConnectAsync.cs
- ISCIIEncoding.cs
- ReleaseInstanceMode.cs
- VectorAnimationUsingKeyFrames.cs
- ItemMap.cs
- CommandValueSerializer.cs
- ApplicationSecurityInfo.cs
- SystemNetworkInterface.cs
- Point4D.cs
- CheckoutException.cs
- Attributes.cs
- TypeConstant.cs
- UrlRoutingHandler.cs
- Normalization.cs
- WindowsScroll.cs
- ScriptBehaviorDescriptor.cs
- OperationResponse.cs
- XNodeValidator.cs
- _emptywebproxy.cs
- BaseTransportHeaders.cs
- SystemThemeKey.cs
- HtmlTableRowCollection.cs
- EventRouteFactory.cs
- TableItemProviderWrapper.cs
- URLString.cs
- DataViewListener.cs
- LocatorPartList.cs
- DiagnosticTrace.cs
- ITreeGenerator.cs
- SmtpNetworkElement.cs
- IProvider.cs
- BoolExpressionVisitors.cs
- ExpressionSelection.cs
- VScrollBar.cs
- HostingPreferredMapPath.cs
- Base64Decoder.cs
- MulticastDelegate.cs
- TypeReference.cs
- InstanceCreationEditor.cs
- AnimationClock.cs
- SectionXmlInfo.cs
- ZipIOModeEnforcingStream.cs
- XmlEntityReference.cs
- SafeNativeMethods.cs
- TextProviderWrapper.cs
- TextBoxLine.cs
- PreProcessor.cs
- StreamGeometry.cs
- ImplicitInputBrush.cs
- SafeNativeMemoryHandle.cs
- ProvideValueServiceProvider.cs
- XmlSchemaType.cs
- DataTemplateKey.cs
- IConvertible.cs
- TextRunCache.cs
- DataPagerFieldCommandEventArgs.cs
- SubpageParagraph.cs
- NavigationFailedEventArgs.cs
- Int64AnimationUsingKeyFrames.cs
- CompiledRegexRunner.cs
- PriorityQueue.cs
- PenContexts.cs
- HtmlForm.cs
- RegexCompiler.cs
- HotCommands.cs
- PasswordPropertyTextAttribute.cs
- MdImport.cs
- BitmapEffect.cs
- EDesignUtil.cs
- SwitchAttribute.cs
- UnsafeNativeMethods.cs