Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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>());
                    }
                }
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
                }
            }
        }