Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Core.Presentation / System / Activities / Presentation / ActivityDesignerHelper.cs / 1305376 / ActivityDesignerHelper.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation { using System.ComponentModel; using System.Activities.Statements; using System.Activities.Presentation.Metadata; using System.Activities.Presentation.Model; using System.Activities.Presentation.View; using System.Activities.Core.Presentation.Themes; using System.Linq; using System.Activities.Core.Presentation; using System.Diagnostics.CodeAnalysis; using System.ServiceModel.Activities; using System.Windows; using System.Runtime; using System.Globalization; static class ActivityDesignerHelper { public const string ChannelBasedCorrelationKey = "ChannelBasedCorrelation"; [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", Justification = "This is a TryGet pattern that requires out parameters")] public static bool IsItemInSequence(this ModelItem item, out ModelItem sequence) { if (null == item) { throw FxTrace.Exception.AsError(new ArgumentNullException("item")); } bool result = false; int level = 0; FuncisInSequencePredicate = (p) => { switch (level) { case 0: ++level; return (p is ModelItemCollection); case 1: ++level; result = typeof(Sequence).IsAssignableFrom(p.ItemType); return result; default: return false; }; }; ModelItem container = item.GetParentEnumerator(isInSequencePredicate).LastOrDefault(); sequence = result ? container : null; return result; } [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", Justification = "This is a TryGet pattern that requires out parameters")] public static bool IsItemInFlowchart(this ModelItem item, out ModelItem flowchart, out ModelItem flowStep) { if (null == item) { throw FxTrace.Exception.AsError(new ArgumentNullException("item")); } bool result = false; int level = 0; ModelItem flowStepContainer = null; flowchart = null; flowStep = null; Func isInFlowchartPredicate = (p) => { switch (level) { case 0: ++level; flowStepContainer = typeof(FlowStep).IsAssignableFrom(p.ItemType) ? p : null; return null != flowStepContainer; case 1: ++level; return (p is ModelItemCollection); case 2: ++level; result = (typeof(Flowchart).IsAssignableFrom(p.ItemType)); return result; default: return false; } }; ModelItem container = item.GetParentEnumerator(isInFlowchartPredicate).LastOrDefault(); if (result) { flowchart = container; flowStep = flowStepContainer; } return result; } public static bool IsMessagingActivity( this ModelItem item) { if (null == item) { throw FxTrace.Exception.ArgumentNull("item"); } bool result = item.IsAssignableFrom () || item.IsAssignableFrom () || item.IsAssignableFrom () || item.IsAssignableFrom (); return result; } public static string GenerateUniqueVariableNameForContext(DependencyObject context, string prefix) { if (null == context) { throw FxTrace.Exception.ArgumentNull("context"); } var viewElement = context as WorkflowViewElement; if (null == viewElement) { var msg = StringResourceDictionary.Instance.GetString("activityFactoryWrongTarget"); throw FxTrace.Exception.Argument("target", msg); } string name; var scope = VariableHelper.FindCommonVariableScope(viewElement.ModelItem, viewElement.ModelItem); if (null == scope) { name = string.Format(CultureInfo.CurrentUICulture, "{0}{1}", prefix, 1); } else { name = scope.GetVariableCollection().CreateUniqueVariableName(prefix, 1); } return name; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DocumentOrderQuery.cs
- SafeNativeMethodsOther.cs
- OleDbConnection.cs
- WorkflowOperationErrorHandler.cs
- GridErrorDlg.cs
- hresults.cs
- RawStylusInput.cs
- CustomErrorsSection.cs
- SafeBitVector32.cs
- FixedSOMTableCell.cs
- ComboBox.cs
- OleDbInfoMessageEvent.cs
- EffectiveValueEntry.cs
- WindowsButton.cs
- Speller.cs
- SQLInt32.cs
- TemplateInstanceAttribute.cs
- UniqueEventHelper.cs
- WebEventTraceProvider.cs
- SyntaxCheck.cs
- SupportsEventValidationAttribute.cs
- StreamGeometry.cs
- NetworkCredential.cs
- Parallel.cs
- FileSystemWatcher.cs
- Geometry3D.cs
- ProfilePropertySettings.cs
- IPEndPointCollection.cs
- EntityContainerEmitter.cs
- TrustManagerPromptUI.cs
- RtfToXamlLexer.cs
- ListChangedEventArgs.cs
- XamlPathDataSerializer.cs
- CalendarButton.cs
- SHA1CryptoServiceProvider.cs
- DesignerVerb.cs
- Condition.cs
- TrustLevel.cs
- QueryResponse.cs
- ReturnValue.cs
- HiddenField.cs
- WithParamAction.cs
- ColorTypeConverter.cs
- COM2ExtendedUITypeEditor.cs
- AnnouncementEndpoint.cs
- ResourceReferenceExpression.cs
- MouseWheelEventArgs.cs
- EncryptedType.cs
- CriticalFileToken.cs
- ModuleElement.cs
- TargetConverter.cs
- Calendar.cs
- serverconfig.cs
- ECDsa.cs
- CqlLexerHelpers.cs
- PaperSize.cs
- DataTableMapping.cs
- SignalGate.cs
- DbInsertCommandTree.cs
- ThreadAbortException.cs
- WebServiceData.cs
- SqlNodeAnnotation.cs
- AssociationTypeEmitter.cs
- UnaryNode.cs
- XmlEntityReference.cs
- QilParameter.cs
- XmlWriter.cs
- TextRange.cs
- SimpleType.cs
- SecurityTokenResolver.cs
- BufferedGraphicsContext.cs
- CodeTypeReferenceCollection.cs
- ExtensionQuery.cs
- SiteMapNodeCollection.cs
- WebBrowserDocumentCompletedEventHandler.cs
- PeerDuplexChannel.cs
- DependencyObjectType.cs
- UIElementParagraph.cs
- ThemeableAttribute.cs
- TextBox.cs
- ImmutableObjectAttribute.cs
- RegexParser.cs
- ValidatingPropertiesEventArgs.cs
- Stylesheet.cs
- XsdDateTime.cs
- UserControl.cs
- FtpRequestCacheValidator.cs
- DataGridViewTextBoxEditingControl.cs
- FilterQueryOptionExpression.cs
- PerformanceCounterManager.cs
- GridViewSortEventArgs.cs
- HttpChannelBindingToken.cs
- TransformDescriptor.cs
- XmlAttribute.cs
- ImpersonateTokenRef.cs
- DateTime.cs
- XmlSchemaAnnotation.cs
- Cursor.cs
- RemotingConfiguration.cs
- Int32Rect.cs