public override void SetValue(object component, object value) { NamespaceList namespaceList = value as NamespaceList; if (namespaceList != null) { if (namespaceList is VisualBasicNamespaceList) { VisualBasicNamespaceList visualBasicNamespaces = namespaceList as VisualBasicNamespaceList; VisualBasicSettings settings = new VisualBasicSettings(); settings.ImportReferences.UnionWith(visualBasicNamespaces.VisualBasicImports); NamespaceHelper.SetVisualBasicSettings(component, settings); } else { Fx.Assert(namespaceList is TextExpressionNamespaceList, "The namespace list must be either of VisualBaiscSettings or TextExpression attached properties."); TextExpressionNamespaceList textExpressionNamespace = namespaceList as TextExpressionNamespaceList; NamespaceHelper.SetTextExpressionNamespaces( component, textExpressionNamespace.TextExpressionNamespaces, textExpressionNamespace.TextExpressionReferences); } } else { this.ResetValue(component); } }
private static void ConvertNamespaces(object root, EditingContext context) { VisualBasicSettings settings = VisualBasic.GetSettings(root); IList <AssemblyReference> references; IList <string> importedNamespaces = NamespaceHelper.GetTextExpressionNamespaces(root, out references); FrameworkName targetFramework = WorkflowDesigner.GetTargetFramework(context); if (targetFramework.IsLessThan45()) { if (settings == null) { if ((importedNamespaces != null) && (importedNamespaces.Count > 0)) { NamespaceHelper.ConvertToVBSettings( importedNamespaces, references, context, out settings); } else { settings = new VisualBasicSettings(); } NamespaceHelper.SetVisualBasicSettings(root, settings); NamespaceHelper.SetTextExpressionNamespaces(root, null, null); } IDebuggableWorkflowTree debuggableWorkflowTree = root as IDebuggableWorkflowTree; if (debuggableWorkflowTree != null) { Activity rootActivity = debuggableWorkflowTree.GetWorkflowRoot(); if (rootActivity != null) { NamespaceHelper.SetVisualBasicSettings(rootActivity, settings); NamespaceHelper.SetTextExpressionNamespaces(rootActivity, null, null); } } } else { if ((importedNamespaces == null) || (importedNamespaces.Count == 0)) { if (settings != null) { NamespaceHelper.ConvertToTextExpressionImports(settings, out importedNamespaces, out references); NamespaceHelper.SetTextExpressionNamespaces(root, importedNamespaces, references); NamespaceHelper.SetVisualBasicSettings(root, null); } else { NamespaceHelper.SetTextExpressionNamespaces(root, new Collection <string>(), new Collection <AssemblyReference>()); } } } }
internal static void SetVisualBasicSettings(object root, VisualBasicSettings settings) { if (NamespaceHelper.ShouldUsePropertiesForImplementation(root)) { VisualBasic.SetSettingsForImplementation(root, settings); } else { VisualBasic.SetSettings(root, settings); } }
internal static void SetTextExpressionNamespaces(object root, IList <string> namespaces, IList <AssemblyReference> references) { if (NamespaceHelper.ShouldUsePropertiesForImplementation(root)) { TextExpression.SetNamespacesForImplementation(root, namespaces); TextExpression.SetReferencesForImplementation(root, references); } else { TextExpression.SetNamespaces(root, namespaces); TextExpression.SetReferences(root, references); } }
internal static IList <string> GetTextExpressionNamespaces(object root, out IList <AssemblyReference> references) { if (NamespaceHelper.ShouldUsePropertiesForImplementation(root)) { references = TextExpression.GetReferencesForImplementation(root); return(TextExpression.GetNamespacesForImplementation(root)); } else { references = TextExpression.GetReferences(root); return(TextExpression.GetNamespaces(root)); } }
public override void ResetValue(object component) { IList <AssemblyReference> references; IList <string> importedNamespaces = NamespaceHelper.GetTextExpressionNamespaces(component, out references); if (importedNamespaces != null) { NamespaceHelper.SetTextExpressionNamespaces(component, null, null); } else { NamespaceHelper.SetVisualBasicSettings(component, null); } }
public override object GetValue(object component) { VisualBasicSettings settings = VisualBasic.GetSettings(component); IList <AssemblyReference> references; IList <string> namespaces = NamespaceHelper.GetTextExpressionNamespaces(component, out references); if ((namespaces != null) && ((namespaces.Count > 0) || ((namespaces.Count == 0) && (settings == null)))) { return(new TextExpressionNamespaceList(namespaces, references)); } else { Fx.Assert(settings != null, "Either VB settings or new TextExpression attached properties should be set"); return(new VisualBasicNamespaceList(settings.ImportReferences)); } }
static void OnRootPropertyChanged(object sender, PropertyChangedEventArgs e) { ModelItem rootModel = sender as ModelItem; Fx.Assert(rootModel != null, "sender item could not be null"); ModelProperty changedProperty = rootModel.Properties[e.PropertyName]; if (changedProperty == null) { return; } object changedPropertyValue = changedProperty.ComputedValue; if (changedPropertyValue == null) { return; } Fx.Assert(rootModel.GetCurrentValue().GetType() == WorkflowServiceType, "This handler should only be attached when the root is WorkflowService"); IDebuggableWorkflowTree root = rootModel.GetCurrentValue() as IDebuggableWorkflowTree; Activity rootActivity = root.GetWorkflowRoot(); if (rootActivity == changedPropertyValue) { if (WorkflowDesigner.GetTargetFramework(rootModel.GetEditingContext()).IsLessThan45()) { VisualBasicSettings settings = VisualBasic.GetSettings(root); NamespaceHelper.SetVisualBasicSettings(changedPropertyValue, settings); } else { IList <AssemblyReference> referencedAssemblies; IList <string> namespaces = NamespaceHelper.GetTextExpressionNamespaces(root, out referencedAssemblies); NamespaceHelper.SetTextExpressionNamespaces(rootActivity, namespaces, referencedAssemblies); } } }