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
- DataContractJsonSerializer.cs
- ComponentCollection.cs
- DataControlPagerLinkButton.cs
- XmlDomTextWriter.cs
- UserControlCodeDomTreeGenerator.cs
- PassportPrincipal.cs
- ResolveCriteria.cs
- WindowsFont.cs
- MessageSmuggler.cs
- CallContext.cs
- XmlObjectSerializerWriteContextComplex.cs
- WebBrowsableAttribute.cs
- comcontractssection.cs
- RegexCode.cs
- TextTreeUndo.cs
- IInstanceContextProvider.cs
- PriorityItem.cs
- EventLogPermissionHolder.cs
- VisualTreeFlattener.cs
- WorkflowPrinting.cs
- ChtmlFormAdapter.cs
- DbConnectionStringCommon.cs
- DateTimeFormatInfoScanner.cs
- DebugView.cs
- StorageMappingItemCollection.cs
- XmlSchemaSimpleContent.cs
- LocationReference.cs
- XmlRawWriter.cs
- ClientSponsor.cs
- IdentityHolder.cs
- XslAst.cs
- PrimitiveType.cs
- ExtensionDataReader.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- MimeMapping.cs
- WaitHandleCannotBeOpenedException.cs
- DataMemberListEditor.cs
- XslTransformFileEditor.cs
- FacetValueContainer.cs
- CacheDependency.cs
- LineServicesCallbacks.cs
- coordinator.cs
- ConstructorBuilder.cs
- InputLangChangeRequestEvent.cs
- MessageQueueCriteria.cs
- Icon.cs
- Typography.cs
- SqlUtils.cs
- SelectionPatternIdentifiers.cs
- ValueUtilsSmi.cs
- SingleBodyParameterMessageFormatter.cs
- StringComparer.cs
- BindingBase.cs
- DependencyPropertyConverter.cs
- NonBatchDirectoryCompiler.cs
- UnsafeNativeMethods.cs
- Fonts.cs
- MimeMultiPart.cs
- DesignerAttributeInfo.cs
- UTF32Encoding.cs
- QuaternionKeyFrameCollection.cs
- MouseButtonEventArgs.cs
- ResourcesGenerator.cs
- RootBuilder.cs
- ThicknessAnimationBase.cs
- VariableQuery.cs
- MultipartContentParser.cs
- PageParser.cs
- CrossAppDomainChannel.cs
- NameValueFileSectionHandler.cs
- SchemaElementDecl.cs
- EventMappingSettingsCollection.cs
- hwndwrapper.cs
- RegionInfo.cs
- DataExpression.cs
- TaskFormBase.cs
- NameValuePermission.cs
- Error.cs
- SqlEnums.cs
- httpapplicationstate.cs
- PersonalizationAdministration.cs
- ComponentChangedEvent.cs
- Aggregates.cs
- StringDictionaryEditor.cs
- SuppressIldasmAttribute.cs
- BlockUIContainer.cs
- SizeAnimationUsingKeyFrames.cs
- ProfileModule.cs
- SQLMoneyStorage.cs
- CharUnicodeInfo.cs
- EncryptedPackage.cs
- MouseEvent.cs
- RSAPKCS1KeyExchangeFormatter.cs
- SecuritySessionFilter.cs
- SqlDataSourceRefreshSchemaForm.cs
- FormatterConverter.cs
- QilDataSource.cs
- Label.cs
- TextServicesCompartmentContext.cs
- TransformPattern.cs