Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Xaml / ActivityBuilderHelper.cs / 1407647 / ActivityBuilderHelper.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.Xaml { using System.Activities.Debugger; using System.Activities.Presentation.Model; using System.Collections.Generic; using System.ComponentModel; using System.Runtime; using System.Windows.Markup; internal class ActivityBuilderHelper { internal static bool IsActivityBuilderType(ModelItem modelItem) { if (null == modelItem) { throw FxTrace.Exception.AsError(new ArgumentNullException("modelItem")); } return modelItem.ItemType.IsAssignableFrom(typeof(ActivityBuilder)); } internal static ListGetVariables(object input) { if (null == input) { throw FxTrace.Exception.AsError(new ArgumentNullException("input")); } ModelItem astAsModelItem = input as ModelItem; ActivityBuilder instance = input as ActivityBuilder; if (null != astAsModelItem) { if (!astAsModelItem.ItemType.IsAssignableFrom(typeof(ActivityBuilder))) { throw FxTrace.Exception.AsError(new InvalidCastException(astAsModelItem.ItemType.FullName)); } instance = (ActivityBuilder)astAsModelItem.GetCurrentValue(); } else if (null == instance) { throw FxTrace.Exception.AsError(new InvalidCastException(input.GetType().FullName)); } List variables = new List (); foreach (DynamicActivityProperty property in instance.Properties) { if (property != null) { Variable autoVariable = GetVariableFromProperty(property); if (autoVariable != null) { variables.Add(autoVariable); } } } return variables; } internal static Variable GetVariableFromProperty(DynamicActivityProperty property) { Type variableType = null; Variable autoVariable = null; if (property.Type != null) { Type propertyType = property.Type; // if the property is an Argument create a variable of type T if (propertyType != null && typeof(Argument).IsAssignableFrom(propertyType)) { if (propertyType.IsGenericType) { variableType = propertyType.GetGenericArguments()[0]; } else { variableType = typeof(object); } } } if (variableType != null) { autoVariable = Variable.Create(property.Name, variableType, VariableModifiers.None); Argument argument = property.Value as Argument; if (argument != null) { autoVariable.Default = argument.Expression; } } return autoVariable; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.Xaml { using System.Activities.Debugger; using System.Activities.Presentation.Model; using System.Collections.Generic; using System.ComponentModel; using System.Runtime; using System.Windows.Markup; internal class ActivityBuilderHelper { internal static bool IsActivityBuilderType(ModelItem modelItem) { if (null == modelItem) { throw FxTrace.Exception.AsError(new ArgumentNullException("modelItem")); } return modelItem.ItemType.IsAssignableFrom(typeof(ActivityBuilder)); } internal static List GetVariables(object input) { if (null == input) { throw FxTrace.Exception.AsError(new ArgumentNullException("input")); } ModelItem astAsModelItem = input as ModelItem; ActivityBuilder instance = input as ActivityBuilder; if (null != astAsModelItem) { if (!astAsModelItem.ItemType.IsAssignableFrom(typeof(ActivityBuilder))) { throw FxTrace.Exception.AsError(new InvalidCastException(astAsModelItem.ItemType.FullName)); } instance = (ActivityBuilder)astAsModelItem.GetCurrentValue(); } else if (null == instance) { throw FxTrace.Exception.AsError(new InvalidCastException(input.GetType().FullName)); } List variables = new List (); foreach (DynamicActivityProperty property in instance.Properties) { if (property != null) { Variable autoVariable = GetVariableFromProperty(property); if (autoVariable != null) { variables.Add(autoVariable); } } } return variables; } internal static Variable GetVariableFromProperty(DynamicActivityProperty property) { Type variableType = null; Variable autoVariable = null; if (property.Type != null) { Type propertyType = property.Type; // if the property is an Argument create a variable of type T if (propertyType != null && typeof(Argument).IsAssignableFrom(propertyType)) { if (propertyType.IsGenericType) { variableType = propertyType.GetGenericArguments()[0]; } else { variableType = typeof(object); } } } if (variableType != null) { autoVariable = Variable.Create(property.Name, variableType, VariableModifiers.None); Argument argument = property.Value as Argument; if (argument != null) { autoVariable.Default = argument.Expression; } } return autoVariable; } } } // 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
- SelfIssuedAuthRSAPKCS1SignatureDeformatter.cs
- DynamicResourceExtension.cs
- InternalCompensate.cs
- AllMembershipCondition.cs
- SamlSecurityTokenAuthenticator.cs
- CommonXSendMessage.cs
- ManagementClass.cs
- TransportOutputChannel.cs
- KeyNameIdentifierClause.cs
- XmlToDatasetMap.cs
- IncrementalReadDecoders.cs
- ExtendedProperty.cs
- DataTableClearEvent.cs
- MissingSatelliteAssemblyException.cs
- DeploymentSection.cs
- HandleRef.cs
- OlePropertyStructs.cs
- SubMenuStyleCollection.cs
- ExpressionBuilder.cs
- IdentitySection.cs
- ResourceExpression.cs
- DelegateTypeInfo.cs
- Vector3DCollectionValueSerializer.cs
- ProxyWebPart.cs
- Transform3D.cs
- Point3DAnimation.cs
- SessionPageStatePersister.cs
- uribuilder.cs
- PerformanceCounterManager.cs
- XamlDesignerSerializationManager.cs
- LightweightEntityWrapper.cs
- OleServicesContext.cs
- TraceLevelStore.cs
- BindableAttribute.cs
- EventHandlingScope.cs
- OracleConnectionFactory.cs
- ViewPort3D.cs
- SuppressIldasmAttribute.cs
- FixedPage.cs
- TextBreakpoint.cs
- ExpandCollapseProviderWrapper.cs
- MDIClient.cs
- AdornerHitTestResult.cs
- SeekableReadStream.cs
- WizardSideBarListControlItem.cs
- HighlightVisual.cs
- ReadOnlyPropertyMetadata.cs
- DictionarySectionHandler.cs
- TraceHwndHost.cs
- GenericQueueSurrogate.cs
- DetailsViewDeletedEventArgs.cs
- DrawListViewColumnHeaderEventArgs.cs
- EventManager.cs
- ResourceAttributes.cs
- ImageSourceValueSerializer.cs
- ConfigurationStrings.cs
- IPGlobalProperties.cs
- WorkflowView.cs
- UIntPtr.cs
- TemplateField.cs
- UIPropertyMetadata.cs
- TracingConnectionListener.cs
- ClaimTypes.cs
- HttpPostedFile.cs
- MergePropertyDescriptor.cs
- SystemFonts.cs
- ApplicationDirectory.cs
- PropertyFilterAttribute.cs
- AssemblyCache.cs
- LinkLabelLinkClickedEvent.cs
- ReaderOutput.cs
- ConstraintEnumerator.cs
- TransformerInfo.cs
- PanelDesigner.cs
- TextSpan.cs
- AuthenticateEventArgs.cs
- ToolBarPanel.cs
- ISO2022Encoding.cs
- ChangePassword.cs
- SiteMapNode.cs
- EmptyEnumerator.cs
- ChannelHandler.cs
- WebPartMenuStyle.cs
- PageHandlerFactory.cs
- HttpCapabilitiesEvaluator.cs
- ObfuscationAttribute.cs
- TextServicesContext.cs
- SessionPageStateSection.cs
- PropertyMetadata.cs
- OdbcConnectionPoolProviderInfo.cs
- Wizard.cs
- RegularExpressionValidator.cs
- FixedPageProcessor.cs
- XamlPathDataSerializer.cs
- FileInfo.cs
- StructuralType.cs
- DynamicEndpointElement.cs
- GregorianCalendar.cs
- XmlAttributeCache.cs
- BinaryMethodMessage.cs