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
- ImpersonationContext.cs
- ContextStack.cs
- ValueSerializerAttribute.cs
- CodeDOMUtility.cs
- OracleTransaction.cs
- EncoderFallback.cs
- FormsAuthenticationUser.cs
- DataSetFieldSchema.cs
- HttpCacheVaryByContentEncodings.cs
- NextPreviousPagerField.cs
- MemberHolder.cs
- SecurityTokenResolver.cs
- WebPartDescriptionCollection.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- WinEventTracker.cs
- ServiceInstanceProvider.cs
- SchemaCollectionPreprocessor.cs
- JsonReaderWriterFactory.cs
- Empty.cs
- QilBinary.cs
- RouteUrlExpressionBuilder.cs
- SafeNativeMethods.cs
- ObjectDataSourceSelectingEventArgs.cs
- EntityDataSourceStatementEditor.cs
- DBCommand.cs
- SqlTopReducer.cs
- StaticExtension.cs
- XmlSchemaSimpleTypeList.cs
- ObjectDataSourceStatusEventArgs.cs
- WindowsNonControl.cs
- View.cs
- FieldNameLookup.cs
- SurrogateEncoder.cs
- TextModifierScope.cs
- TargetParameterCountException.cs
- TableRow.cs
- TextLineResult.cs
- ConstructorBuilder.cs
- OLEDB_Enum.cs
- InputManager.cs
- XpsViewerException.cs
- DataGridTextBox.cs
- FormClosedEvent.cs
- WorkflowServiceBuildProvider.cs
- invalidudtexception.cs
- ReadOnlyDataSource.cs
- HttpCachePolicyWrapper.cs
- MultipartIdentifier.cs
- CallTemplateAction.cs
- TableLayoutPanelCodeDomSerializer.cs
- ValidationErrorCollection.cs
- EdgeModeValidation.cs
- ActivityTypeCodeDomSerializer.cs
- ViewEvent.cs
- CompleteWizardStep.cs
- AuthenticatedStream.cs
- FloatAverageAggregationOperator.cs
- LicFileLicenseProvider.cs
- RequestCachePolicyConverter.cs
- EventLogPermission.cs
- CodeAccessSecurityEngine.cs
- X509InitiatorCertificateServiceElement.cs
- OracleParameterCollection.cs
- PerspectiveCamera.cs
- X509ClientCertificateCredentialsElement.cs
- UserMapPath.cs
- StorageInfo.cs
- TextSegment.cs
- AssemblyFilter.cs
- InvalidCastException.cs
- GlyphInfoList.cs
- DeferredTextReference.cs
- MembershipPasswordException.cs
- Properties.cs
- UITypeEditors.cs
- WebPartManager.cs
- BmpBitmapDecoder.cs
- Adorner.cs
- OletxEnlistment.cs
- DecoderReplacementFallback.cs
- Keyboard.cs
- SQLDouble.cs
- NameValueCollection.cs
- TransactionManager.cs
- SafeFindHandle.cs
- ThreadStartException.cs
- SecurityException.cs
- SizeChangedInfo.cs
- AnnotationDocumentPaginator.cs
- Span.cs
- _Rfc2616CacheValidators.cs
- BitmapFrame.cs
- Brushes.cs
- GenerateHelper.cs
- SmtpNetworkElement.cs
- InkCanvasFeedbackAdorner.cs
- EncryptedPackage.cs
- RtfControls.cs
- FixedDocumentSequencePaginator.cs
- FlowLayoutPanel.cs