コード例 #1
0
        void OnContextChanged()
        {
            this.targetFramework = WorkflowDesigner.GetTargetFramework(this.Context);

            AttachedPropertiesService attachedPropertyService = this.Context.Services.GetService <AttachedPropertiesService>();

            Fx.Assert(attachedPropertyService != null, "AttachedPropertiesService shouldn't be null in EditingContext.");
            attachedPropertyService.AddProperty(CreateAttachedPropertyForNamespace <string>(ErrorMessagePropertyName));
            attachedPropertyService.AddProperty(CreateAttachedPropertyForNamespace <bool>(IsInvalidPropertyName));
            //clear any defaults because it's meant to be set by host and not serialized to XAML
            VisualBasicSettings.Default.ImportReferences.Clear();

            ModelService modelService = this.Context.Services.GetService <ModelService>();

            Fx.Assert(modelService != null, "ModelService shouldn't be null in EditingContext.");
            Fx.Assert(modelService.Root != null, "model must have a root");
            this.importsModelItem = modelService.Root.Properties[NamespaceListPropertyDescriptor.ImportCollectionPropertyName].Collection;
            Fx.Assert(this.importsModelItem != null, "root must have imports");
            this.importsModelItem.CollectionChanged += this.OnImportsModelItemCollectionChanged;

            this.importedNamespacesItem = this.Context.Items.GetValue <ImportedNamespaceContextItem>();
            this.importedNamespacesItem.EnsureInitialized(this.Context);

            if (this.availableNamespaces == null)
            {
                //change to available namespace should not be a model change so we access the dictionary directly
                this.availableNamespaces = this.importsModelItem.Properties[NamespaceListPropertyDescriptor.AvailableNamespacesPropertyName].ComputedValue as Dictionary <string, List <string> >;
                Fx.Assert(this.availableNamespaces != null, "Available namespace dictionary is not in right format");
            }
            RefreshNamespaces();
        }
コード例 #2
0
        public override void Initialize(EditingContext context, Type modelType)
        {
            Fx.Assert(
                modelType.IsGenericType && (modelType.GetGenericTypeDefinition() == VisualBasicReferenceType),
                "This Feature should only apply to VisualBasicReference<>");

            ValidationService validationService = context.Services.GetService <ValidationService>();

            if (validationService != null && WorkflowDesigner.GetTargetFramework(context).IsLessThan45())
            {
                validationService.Settings.AdditionalConstraints.Add(VisualBasicReferenceType, new List <Constraint> {
                    VisualBasicDesignerHelper.NameShadowingConstraint
                });
            }
        }
コード例 #3
0
        private string GetExpressionEditorType()
        {
            object root = null;

            if (this.OwnerActivity != null)
            {
                ModelItem rootItem = this.Context.Services.GetService <ModelService>().Root;
                if (rootItem != null)
                {
                    root = rootItem.GetCurrentValue();
                }
            }

            return(this.ViewModel.GetExpressionEditorType(this.ExpressionActivityEditor, root, WorkflowDesigner.GetTargetFramework(this.Context)));
        }