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
- DashStyle.cs
- RegexRunner.cs
- ProfessionalColors.cs
- PerformanceCounterPermissionEntryCollection.cs
- CryptoKeySecurity.cs
- SoapSchemaMember.cs
- DeferredTextReference.cs
- SqlFileStream.cs
- SystemSounds.cs
- WmiEventSink.cs
- ComboBoxRenderer.cs
- IntSecurity.cs
- SystemIPAddressInformation.cs
- formatter.cs
- StrongNameIdentityPermission.cs
- XmlCountingReader.cs
- DataSourceExpression.cs
- ExpressionNormalizer.cs
- WorkflowServiceHostFactory.cs
- XmlDictionaryReaderQuotas.cs
- NonParentingControl.cs
- XamlSerializerUtil.cs
- WebPartDisplayModeCancelEventArgs.cs
- OpCellTreeNode.cs
- JournalNavigationScope.cs
- ExtenderControl.cs
- LassoSelectionBehavior.cs
- TdsParameterSetter.cs
- SynchronizingStream.cs
- TableLayoutSettingsTypeConverter.cs
- MailWebEventProvider.cs
- QueryIntervalOp.cs
- SoapSchemaImporter.cs
- InvalidPipelineStoreException.cs
- DataGridViewCellStyle.cs
- FormsAuthenticationTicket.cs
- XamlClipboardData.cs
- ExtendedPropertyDescriptor.cs
- CodeCompiler.cs
- SolidColorBrush.cs
- SqlClientMetaDataCollectionNames.cs
- DbLambda.cs
- StyleXamlParser.cs
- Page.cs
- XmlIlGenerator.cs
- TreeViewEvent.cs
- Fx.cs
- ChoiceConverter.cs
- Utils.cs
- PeerContact.cs
- FixedMaxHeap.cs
- OdbcConnectionHandle.cs
- DynamicDataRoute.cs
- __ComObject.cs
- PauseStoryboard.cs
- ExtensionQuery.cs
- NotImplementedException.cs
- DataViewManagerListItemTypeDescriptor.cs
- Ops.cs
- CodeMemberMethod.cs
- SharedStatics.cs
- MemberAssignmentAnalysis.cs
- RequestCacheManager.cs
- SafeTimerHandle.cs
- SoapIncludeAttribute.cs
- dbdatarecord.cs
- Random.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- SyndicationElementExtensionCollection.cs
- SettingsProviderCollection.cs
- ConstraintCollection.cs
- ItemsChangedEventArgs.cs
- ProviderSettings.cs
- ActivityExecutionContext.cs
- AutomationProperty.cs
- UITypeEditor.cs
- HtmlWindowCollection.cs
- Int32Converter.cs
- RowParagraph.cs
- XmlChildNodes.cs
- AuthenticationService.cs
- SapiRecoInterop.cs
- DataRelation.cs
- BindingExpressionUncommonField.cs
- SizeConverter.cs
- BitSet.cs
- ProvidePropertyAttribute.cs
- PerformanceCountersElement.cs
- JavaScriptObjectDeserializer.cs
- ProxyWebPart.cs
- XmlTextReader.cs
- ObjectStateFormatter.cs
- SettingsSavedEventArgs.cs
- Memoizer.cs
- _StreamFramer.cs
- ColorDialog.cs
- UnsafeNativeMethodsCLR.cs
- SmtpReplyReaderFactory.cs
- CheckBoxPopupAdapter.cs
- UrlPropertyAttribute.cs