public static PropertyValueEditor GetValueEditor(IEnumerable attributes, IMessageLogger exceptionLogger)
        {
            PropertyValueEditor propertyValueEditor = null;

            if (attributes != null)
            {
                foreach (Attribute attribute in attributes)
                {
                    EditorAttribute editorAttribute = attribute as EditorAttribute;
                    if (editorAttribute != null)
                    {
                        try
                        {
                            Type editorType = Type.GetType(editorAttribute.EditorTypeName);
                            if (editorType != null && typeof(PropertyValueEditor).IsAssignableFrom(editorType))
                            {
                                propertyValueEditor = (PropertyValueEditor)Activator.CreateInstance(editorType);
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                            if (exceptionLogger != null)
                            {
                                exceptionLogger.WriteLine(string.Format(CultureInfo.CurrentCulture, ExceptionStringTable.ValueEditorLoadFailed, ExtensibilityMetadataHelper.GetExceptionMessage(e)));
                            }
                        }
                    }
                }
            }
            return(propertyValueEditor);
        }
Exemplo n.º 2
0
        /// <summary>
        /// To register design time metadata for SSWCDC.Series.
        /// </summary>
        public SeriesMetadata()
            : base()
        {
            AddCallback(
                typeof(SSWCDC.Series),
                b =>
            {
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.Series>(x => x.Title),
                    new CategoryAttribute(Properties.Resources.CommonProperties));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.Series>(x => x.SeriesHost),
                    new CategoryAttribute(Properties.Resources.CommonProperties));

                b.AddCustomAttributes(
                    "LegendItems",
                    new CategoryAttribute(Properties.Resources.DataVisualization));

                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.Series>(x => x.Title),
                    PropertyValueEditor.CreateEditorAttribute(typeof(TextBoxEditor)));

#if MWD40
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.Series>(x => x.Title),
                    new AlternateContentPropertyAttribute());

                b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.DataVisualization, false));
#endif
            });
        }
        /// <summary>
        /// This will save a data type and it's pre-values in one transaction
        /// </summary>
        /// <param name="dataTypeDefinition"></param>
        /// <param name="values"></param>
        /// <param name="userId"></param>
        public void SaveDataTypeAndPreValues(IDataTypeDefinition dataTypeDefinition, IDictionary <string, PreValue> values, int userId = 0)
        {
            using (var uow = UowProvider.GetUnitOfWork())
            {
                var saveEventArgs = new SaveEventArgs <IDataTypeDefinition>(dataTypeDefinition);
                if (uow.Events.DispatchCancelable(Saving, this, saveEventArgs))
                {
                    uow.Commit();
                    return;
                }

                // if preValues contain the data type, override the data type definition accordingly
                if (values != null && values.ContainsKey(Constants.PropertyEditors.PreValueKeys.DataValueType))
                {
                    dataTypeDefinition.DatabaseType = PropertyValueEditor.GetDatabaseType(values[Constants.PropertyEditors.PreValueKeys.DataValueType].Value);
                }

                var repository = RepositoryFactory.CreateDataTypeDefinitionRepository(uow);

                dataTypeDefinition.CreatorId = userId;

                //add/update the dtd
                repository.AddOrUpdate(dataTypeDefinition);

                //add/update the prevalues
                repository.AddOrUpdatePreValues(dataTypeDefinition, values);

                Audit(uow, AuditType.Save, string.Format("Save DataTypeDefinition performed by user"), userId, dataTypeDefinition.Id);
                uow.Commit();
                saveEventArgs.CanCancel = false;
                uow.Events.Dispatch(Saved, this, saveEventArgs);
            }
        }
        internal static void RegisterMetadata(AttributeTableBuilder builder)
        {
            var serviceType       = typeof(WorkflowService);
            var advancedAttribute = new EditorBrowsableAttribute(EditorBrowsableState.Advanced);
            var categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(MiscellaneousCategoryLabelKey));

            builder.AddCustomAttributes(serviceType, new DesignerAttribute(typeof(ServiceDesigner)));
            builder.AddCustomAttributes(serviceType, "Name", new TypeConverterAttribute(typeof(XNameConverter)));
            builder.AddCustomAttributes(serviceType, serviceType.GetProperty("Endpoints"), BrowsableAttribute.No);
            builder.AddCustomAttributes(
                serviceType,
                "ImplementedContracts",
                advancedAttribute,
                categoryAttribute,
                PropertyValueEditor.CreateEditorAttribute(typeof(TypeCollectionPropertyEditor)),
                new EditorOptionAttribute {
                Name = TypeCollectionPropertyEditor.AllowDuplicate, Value = false
            },
                new EditorOptionAttribute {
                Name = TypeCollectionPropertyEditor.Filter, Value = ServiceContractImporter.FilterFunction
            },
                new EditorOptionAttribute {
                Name = TypeCollectionPropertyEditor.DefaultType, Value = null
            });
            builder.AddCustomAttributes(serviceType, serviceType.GetProperty("Body"), BrowsableAttribute.No);
        }
Exemplo n.º 5
0
        /// <summary>
        /// To register design time metadata for SSWCD.Legend.
        /// </summary>
        public LegendMetadata()
            : base()
        {
            AddCallback(
                typeof(SSWCD.Legend),
                b =>
            {
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCD.Legend>(x => x.Items),
                    new BrowsableAttribute(false));

                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCD.Legend>(x => x.Title),
                    new CategoryAttribute(Properties.Resources.CommonProperties));

                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCD.Legend>(x => x.Items),
                    new CategoryAttribute(Properties.Resources.DataVisualization));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCD.Legend>(x => x.TitleStyle),
                    new CategoryAttribute(Properties.Resources.DataVisualizationStyling));

                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCD.Legend>(x => x.Title),
                    PropertyValueEditor.CreateEditorAttribute(typeof(TextBoxEditor)));

#if MWD40
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCD.Legend>(x => x.Title),
                    new AlternateContentPropertyAttribute());

                b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.DataVisualizationControlParts, false));
#endif
            });
        }
        /// <summary>
        /// To register design time metadata for ChildWindow.
        /// </summary>
        public ChildWindowMetadata()
            : base()
        {
            AddCallback(
                typeof(SSWC.ChildWindow),
                b =>
            {
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.ChildWindow>(x => x.HasCloseButton),
                    new CategoryAttribute(Properties.Resources.Appearance));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.ChildWindow>(x => x.OverlayBrush),
                    new CategoryAttribute(Properties.Resources.Brushes));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.ChildWindow>(x => x.OverlayOpacity),
                    new CategoryAttribute(Properties.Resources.Appearance));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.ChildWindow>(x => x.Title),
                    new CategoryAttribute(Properties.Resources.CommonProperties));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.ChildWindow>(x => x.Title),
                    PropertyValueEditor.CreateEditorAttribute(typeof(TextBoxEditor)));

                b.AddCustomAttributes(
                    new DefaultEventAttribute("Closed"));
            });
        }
Exemplo n.º 7
0
        public static PropertyValueEditor GetCustomPropertyValueEditor(PropertyReferenceProperty property)
        {
            PropertyValueEditor propertyValueEditor = (PropertyValueEditor)null;
            object result;

            if (PlatformNeutralAttributeHelper.TryGetAttributeValue <object>((IEnumerable)property.Attributes, ProjectNeutralTypes.CustomPropertyValueEditorAttribute, "CustomPropertyValueEditor", out result))
            {
                switch (Enum.GetName(property.PropertyTypeId.PlatformMetadata.ResolveType(ProjectNeutralTypes.CustomPropertyValueEditor).RuntimeType, result))
                {
                case "Element":
                    propertyValueEditor = (PropertyValueEditor) new ElementPickerPropertyValueEditor();
                    break;

                case "Storyboard":
                    propertyValueEditor = (PropertyValueEditor) new StoryboardPickerPropertyValueEditor();
                    break;

                case "StateName":
                    propertyValueEditor = (PropertyValueEditor) new StatePickerPropertyValueEditor();
                    break;

                case "ElementBinding":
                    propertyValueEditor = (PropertyValueEditor) new ElementBindingPickerPropertyValueEditor();
                    break;

                case "PropertyBinding":
                    propertyValueEditor = (PropertyValueEditor) new PropertyBindingPickerPropertyValueEditor();
                    break;
                }
            }
            return(propertyValueEditor);
        }
Exemplo n.º 8
0
        static SendReplyDesigner()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();
            Type sendType = typeof(SendReply);

            builder.AddCustomAttributes(sendType, sendType.GetProperty("CorrelationInitializers"), PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor)));

            var categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(CorrelationsCategoryLabelKey));

            builder.AddCustomAttributes(sendType, sendType.GetProperty("CorrelationInitializers"), categoryAttribute, BrowsableAttribute.Yes,
                                        PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor)));

            categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(MiscellaneousCategoryLabelKey));

            builder.AddCustomAttributes(sendType, sendType.GetProperty("DisplayName"), categoryAttribute);
            var descriptionAttribute = new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingValueHint", "<Value to bind>"));

            builder.AddCustomAttributes(sendType, sendType.GetProperty("Content"), categoryAttribute, descriptionAttribute, PropertyValueEditor.CreateEditorAttribute(typeof(SendContentPropertyEditor)));
            builder.AddCustomAttributes(sendType, sendType.GetProperty("Request"),
                                        categoryAttribute,
                                        PropertyValueEditor.CreateEditorAttribute(typeof(ActivityXRefPropertyEditor)));

            var advancedAttribute = new EditorBrowsableAttribute(EditorBrowsableState.Advanced);

            builder.AddCustomAttributes(sendType, sendType.GetProperty("Action"), categoryAttribute, advancedAttribute);

            Action = sendType.GetProperty("Action").Name;

            Type sendMessageContentType = typeof(SendMessageContent);

            Message             = sendMessageContentType.GetProperty("Message").Name;
            DeclaredMessageType = sendMessageContentType.GetProperty("DeclaredMessageType").Name;

            MetadataStore.AddAttributeTable(builder.CreateTable());

            Func <Activity, IEnumerable <ArgumentAccessor> > argumentAccessorGenerator = (activity) => new ArgumentAccessor[]
            {
                new ArgumentAccessor
                {
                    Getter = (ownerActivity) =>
                    {
                        SendReply          sendReply = (SendReply)ownerActivity;
                        SendMessageContent content   = sendReply.Content as SendMessageContent;
                        return(content != null ? content.Message : null);
                    },
                    Setter = (ownerActivity, arg) =>
                    {
                        SendReply          sendReply = (SendReply)ownerActivity;
                        SendMessageContent content   = sendReply.Content as SendMessageContent;
                        if (content != null)
                        {
                            content.Message = arg as InArgument;
                        }
                    },
                },
            };

            ActivityArgumentHelper.RegisterAccessorsGenerator(sendType, argumentAccessorGenerator);
        }
        private static void RegisterMetadataForMessagingActivitiesPropertyEditors(AttributeTableBuilder builder)
        {
            EndpointDesigner.RegisterMetadata(builder);

            builder.AddCustomAttributes(typeof(InArgument <CorrelationHandle>), new EditorReuseAttribute(false));
            builder.AddCustomAttributes(typeof(InArgument <Uri>), new EditorReuseAttribute(false));
            builder.AddCustomAttributes(typeof(MessageQuerySet), PropertyValueEditor.CreateEditorAttribute(typeof(CorrelatesOnValueEditor)));
        }
Exemplo n.º 10
0
        public static PropertyValueEditor GetPropertyEditorTemplate(PropertyReferenceProperty property)
        {
            bool                flag                = false;
            IProjectContext     projectContext      = property.ObjectSet.ProjectContext;
            PropertyValueEditor propertyValueEditor = PropertyEditorTemplateLookup.GetPropertyEditorTemplate(projectContext, property.ObjectSet.DesignerContext, property.PropertyTypeId);

            if (propertyValueEditor == PropertyEditorTemplateLookup.ObjectEditorTemplate && property.PropertyValue.CanConvertFromString)
            {
                flag = true;
                propertyValueEditor = (PropertyValueEditor)null;
            }
            SceneNodeProperty sceneNodeProperty = property as SceneNodeProperty;

            if (propertyValueEditor == null)
            {
                if (property.Converter != null && property.Converter.GetPropertiesSupported())
                {
                    return(PropertyEditorTemplateLookup.ObjectEditorTemplate);
                }
                if (sceneNodeProperty != null && UriEditor.IsPropertySupportedOnType((PropertyReferenceProperty)sceneNodeProperty, sceneNodeProperty.SceneNodeObjectSet.ObjectType))
                {
                    DataTemplate inlineEditorTemplate = new DataTemplate();
                    inlineEditorTemplate.VisualTree = new FrameworkElementFactory(typeof(UriEditor));
                    propertyValueEditor             = new PropertyValueEditor(inlineEditorTemplate);
                }
            }
            if (propertyValueEditor == null && !flag)
            {
                IType computedValueTypeId = property.ComputedValueTypeId;
                if (computedValueTypeId != null)
                {
                    propertyValueEditor = PropertyEditorTemplateLookup.GetPropertyEditorTemplate(projectContext, property.ObjectSet.DesignerContext, computedValueTypeId);
                    if (propertyValueEditor is PropertyEditorTemplateLookup.CollectionDialogPropertyValueEditor)
                    {
                        propertyValueEditor = (PropertyValueEditor)null;
                    }
                }
            }
            if (property.IsReadOnly && !(propertyValueEditor is PropertyEditorTemplateLookup.CollectionDialogPropertyValueEditor) && !ProjectNeutralTypes.LayoutPathCollection.IsAssignableFrom((ITypeId)property.PropertyTypeId))
            {
                return((PropertyValueEditor)null);
            }
            if (sceneNodeProperty != null && propertyValueEditor is PropertyEditorTemplateLookup.CollectionDialogPropertyValueEditor)
            {
                bool         isMixed;
                DocumentNode valueAsDocumentNode = sceneNodeProperty.GetLocalValueAsDocumentNode(true, out isMixed);
                if (valueAsDocumentNode != null && valueAsDocumentNode is DocumentPrimitiveNode)
                {
                    return((PropertyValueEditor)null);
                }
                if (property.PropertyTypeId.IsArray && !property.PropertyTypeId.PlatformMetadata.ResolveType(PlatformTypes.ArrayExtension).IsResolvable)
                {
                    return((PropertyValueEditor)null);
                }
            }
            return(propertyValueEditor);
        }
Exemplo n.º 11
0
        /// <summary>
        /// To register design time metadata for DatePicker.
        /// </summary>
        public DatePickerMetadata()
            : base()
        {
            AddCallback(
                typeof(SSWC.DatePicker),
                b =>
            {
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.DatePicker>(x => x.DisplayDate),
                    new CategoryAttribute(Properties.Resources.CommonProperties));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.DatePicker>(x => x.SelectedDate),
                    new CategoryAttribute(Properties.Resources.CommonProperties));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.DatePicker>(x => x.SelectedDateFormat),
                    new CategoryAttribute(Properties.Resources.CommonProperties));

                b.AddCustomAttributes(
                    "BlackoutDates",
                    new CategoryAttribute(Properties.Resources.DatePicker));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.DatePicker>(x => x.DisplayDateEnd),
                    new CategoryAttribute(Properties.Resources.DatePicker));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.DatePicker>(x => x.DisplayDateStart),
                    new CategoryAttribute(Properties.Resources.DatePicker));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.DatePicker>(x => x.FirstDayOfWeek),
                    new CategoryAttribute(Properties.Resources.DatePicker));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.DatePicker>(x => x.IsDropDownOpen),
                    new CategoryAttribute(Properties.Resources.DatePicker));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.DatePicker>(x => x.IsTodayHighlighted),
                    new CategoryAttribute(Properties.Resources.DatePicker));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWC.DatePicker>(x => x.Text),
                    new CategoryAttribute(Properties.Resources.DatePicker));

                b.AddCustomAttributes(new DefaultBindingPropertyAttribute("SelectedDate"));

#if MWD40
                b.AddCustomAttributes(
                    "BlackoutDates",
                    PropertyValueEditor.CreateEditorAttribute(typeof(EmptyEditor)));
                b.AddCustomAttributes(
                    "SelectedDates",
                    PropertyValueEditor.CreateEditorAttribute(typeof(EmptyEditor)));

                b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Controls, true));

                b.AddCustomAttributes(new FeatureAttribute(typeof(DatePickerIsDropDownOpenDesignModeValueProvider)));
                b.AddCustomAttributes(new FeatureAttribute(typeof(DatePickerIsDropDownOpenDesignModeValueProvider.AdornerProxy)));
#endif
            });
        }
 public PropertyValueEditorWrapper(PropertyValueEditor wrapped)
 {
     this.HideLabel = wrapped.HideLabel;
     this.View      = wrapped.View;
     this.ValueType = wrapped.ValueType;
     foreach (var v in wrapped.Validators)
     {
         Validators.Add(v);
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// reconstruct values from original (default) property value editor
 /// </summary>
 /// <param name="propertyValueEditor"></param>
 public SaveFormatPropertyValueEditor(PropertyValueEditor propertyValueEditor)
 {
     this.HideLabel = propertyValueEditor.HideLabel;
     this.View      = propertyValueEditor.View;
     this.ValueType = propertyValueEditor.ValueType;
     foreach (IPropertyValidator propertyValidator in propertyValueEditor.Validators)
     {
         this.Validators.Add(propertyValidator);
     }
 }
Exemplo n.º 14
0
        public void Value_Editor_Can_Convert_To_Clr_Type(string valueType, string val, object expected)
        {
            var valueEditor = new PropertyValueEditor
                {
                    ValueType = valueType
                };

            var result = valueEditor.TryConvertValueToCrlType(val);
            Assert.IsTrue(result.Success);
            Assert.AreEqual(expected, result.Result);
        }
Exemplo n.º 15
0
        public void Value_Editor_Can_Convert_To_Decimal_Clr_Type_With_Other_Separator()
        {
            var valueEditor = new PropertyValueEditor
            {
                ValueType = PropertyEditorValueTypes.Decimal
            };

            var result = valueEditor.TryConvertValueToCrlType("12,34");
            Assert.IsTrue(result.Success);
            Assert.AreEqual(12.34M, result.Result);
        }
Exemplo n.º 16
0
        public void Value_Editor_Can_Convert_To_Decimal_Clr_Type_With_Empty_String()
        {
            var valueEditor = new PropertyValueEditor
            {
                ValueType = PropertyEditorValueTypes.Decimal
            };

            var result = valueEditor.TryConvertValueToCrlType(string.Empty);
            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Result);
        }
Exemplo n.º 17
0
        public void Value_Editor_Can_Convert_To_Date_Clr_Type()
        {
            var valueEditor = new PropertyValueEditor
                {
                    ValueType = PropertyEditorValueTypes.Date
            };

            var result = valueEditor.TryConvertValueToCrlType("2010-02-05");
            Assert.IsTrue(result.Success);
            Assert.AreEqual(new DateTime(2010, 2, 5), result.Result);
        }
Exemplo n.º 18
0
        public void Value_Editor_Can_Convert_To_Json_Object_For_Editor(string value, bool isOk)
        {
            var prop = new Property(1, Guid.NewGuid(), new PropertyType("test", DataTypeDatabaseType.Nvarchar), value);

            var valueEditor = new PropertyValueEditor
                {
                    ValueType = PropertyEditorValueTypes.String
            };

            var result = valueEditor.ConvertDbToEditor(prop, prop.PropertyType, new Mock<IDataTypeService>().Object);
            Assert.AreEqual(isOk, !(result is string));
        }
Exemplo n.º 19
0
        public void Value_Editor_Can_Serialize_Decimal_Value_With_Empty_String()
        {
            var valueEditor = new PropertyValueEditor
                {
                    ValueType = PropertyEditorValueTypes.Decimal
            };

            var prop = new Property(1, Guid.NewGuid(), new PropertyType("test", DataTypeDatabaseType.Decimal), string.Empty);

            var result = valueEditor.ConvertDbToEditor(prop, prop.PropertyType, new Mock<IDataTypeService>().Object);
            Assert.AreEqual(string.Empty, result);
        }
Exemplo n.º 20
0
        public void Value_Editor_Can_Serialize_Value(string valueType, object val, string expected)
        {
            var prop = new Property(1, Guid.NewGuid(), new PropertyType("test", DataTypeDatabaseType.Nvarchar), val);

            var valueEditor = new PropertyValueEditor
                {
                    ValueType = valueType
                };

            var result = valueEditor.ConvertDbToEditor(prop, prop.PropertyType, new Mock<IDataTypeService>().Object);
            Assert.AreEqual(expected, result);
        }
Exemplo n.º 21
0
        public void Value_Editor_Can_Convert_Decimal_To_Decimal_Clr_Type()
        {
            var valueEditor = new PropertyValueEditor
            {
                ValueType = PropertyEditorValueTypes.Decimal
            };

            var result = valueEditor.TryConvertValueToCrlType(12.34d);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(12.34d, result.Result);
        }
Exemplo n.º 22
0
        void AddEntriesForProperty(ModelProperty property, ModelItem modelItem, string propertyPath)
        {
            if (!string.IsNullOrEmpty(propertyPath))
            {
                propertyPath += ",";
                propertyPath += property.Name;
            }
            else
            {
                propertyPath = property.Name;
            }

            entries.Add(CreateSearchableEntry(
                            SearchableEntryOption.Property, modelItem, property, TypeNameHelper.GetDisplayName(property.PropertyType, false), propertyPath));

            entries.Add(CreateSearchableEntry(
                            SearchableEntryOption.Property, modelItem, property, property.Name, propertyPath));

            if (property.ComputedValue != null)
            {
                PropertyValueEditor propertyValueEditor = null;
                try
                {
                    propertyValueEditor = ExtensibilityAccessor.GetSubPropertyEditor(property);
                }
                catch (TargetInvocationException exception)
                {
                    // To workaround 181412.If the current property's property type is a generic type and the activity
                    // is also a generic type Calling to ExtensibilityAccessor.GetSubPropertyEditor will get this exception.
                    if (exception.InnerException is ArgumentException)
                    {
                        propertyValueEditor = null;
                    }
                }
                if (propertyValueEditor != null)
                {
                    IList <ModelProperty> properties = ExtensibilityAccessor.GetSubProperties(property);
                    foreach (ModelProperty propertyItem in properties)
                    {
                        AddEntriesForProperty(propertyItem, modelItem, propertyPath);
                    }
                }
                else
                {
                    // We don't search the value of an expandable property.
                    AddEntriesForPropertyValue(property.ComputedValue, modelItem, property, SearchableEntryOption.Property, propertyPath);
                }
            }
            else if (property.Reference != null)
            {
                AddEntriesForPropertyReference(property.Reference, modelItem, property, SearchableEntryOption.Property, propertyPath);
            }
        }
Exemplo n.º 23
0
        public void Value_Editor_Can_Serialize_Date_Value()
        {
            var now = DateTime.Now;
            var valueEditor = new PropertyValueEditor
                {
                    ValueType = PropertyEditorValueTypes.Date
            };

            var prop = new Property(1, Guid.NewGuid(), new PropertyType("test", DataTypeDatabaseType.Date), now);

            var result = valueEditor.ConvertDbToEditor(prop, prop.PropertyType, new Mock<IDataTypeService>().Object);
            Assert.AreEqual(now.ToIsoString(), result);
        }
Exemplo n.º 24
0
        /// <summary>
        /// To register design time metadata for SSWCDC.DataPoint.
        /// </summary>
        public DataPointMetadata()
            : base()
        {
            AddCallback(
                typeof(SSWCDC.DataPoint),
                b =>
            {
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.ActualDependentValue),
                    new CategoryAttribute(Properties.Resources.DataVisualization));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.ActualIndependentValue),
                    new CategoryAttribute(Properties.Resources.DataVisualization));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.DependentValue),
                    new CategoryAttribute(Properties.Resources.DataVisualization));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.DependentValueStringFormat),
                    new CategoryAttribute(Properties.Resources.DataVisualization));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.FormattedDependentValue),
                    new CategoryAttribute(Properties.Resources.DataVisualization));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.FormattedIndependentValue),
                    new CategoryAttribute(Properties.Resources.DataVisualization));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.IndependentValue),
                    new CategoryAttribute(Properties.Resources.DataVisualization));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.IndependentValueStringFormat),
                    new CategoryAttribute(Properties.Resources.DataVisualization));

                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.IsSelectionEnabled),
                    new BrowsableAttribute(false));

                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.ActualIndependentValue),
                    PropertyValueEditor.CreateEditorAttribute(typeof(TextBoxEditor)));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.DependentValue),
                    PropertyValueEditor.CreateEditorAttribute(typeof(TextBoxEditor)));
                b.AddCustomAttributes(
                    Extensions.GetMemberName <SSWCDC.DataPoint>(x => x.IndependentValue),
                    PropertyValueEditor.CreateEditorAttribute(typeof(TextBoxEditor)));

#if MWD40
                b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.DataVisualizationControlParts, false));
#endif
            });
        }
        public static void RegisterMetadata(AttributeTableBuilder builder)
        {
            Type type = typeof(InvokeMethod);

            builder.AddCustomAttributes(type, new DesignerAttribute(typeof(InvokeMethodDesigner)));
            builder.AddCustomAttributes(
                type,
                "GenericTypeArguments",
                PropertyValueEditor.CreateEditorAttribute(typeof(TypeCollectionPropertyEditor)),
                new EditorOptionAttribute {
                Name = TypeCollectionPropertyEditor.AllowDuplicate, Value = true
            });
            builder.AddCustomAttributes(
                type,
                "Parameters",
                PropertyValueEditor.CreateEditorAttribute(typeof(ArgumentCollectionPropertyEditor)));
            builder.AddCustomAttributes(
                type,
                "TargetType",
                new EditorOptionAttribute {
                Name = TypePropertyEditor.AllowNull, Value = true
            },
                new EditorOptionAttribute {
                Name = TypePropertyEditor.BrowseTypeDirectly, Value = false
            });
            builder.AddCustomAttributes(type, new ActivityDesignerOptionsAttribute {
                AllowDrillIn = false
            });

            Func <Activity, IEnumerable <ArgumentAccessor> > argumentAccessorGenerator = (activity) => new ArgumentAccessor[]
            {
                new ArgumentAccessor
                {
                    Getter = (ownerActivity) => ((InvokeMethod)ownerActivity).TargetObject,
                    Setter = (ownerActivity, arg) =>
                    {
                        ((InvokeMethod)ownerActivity).TargetObject = arg as InArgument;
                    },
                },
                new ArgumentAccessor
                {
                    Getter = (ownerActivity) => ((InvokeMethod)ownerActivity).Result,
                    Setter = (ownerActivity, arg) =>
                    {
                        ((InvokeMethod)ownerActivity).Result = arg as OutArgument;
                    },
                },
            };

            ActivityArgumentHelper.RegisterAccessorsGenerator(type, argumentAccessorGenerator);
        }
Exemplo n.º 26
0
        private void OnChildrenViewCurrentChanged(object sender, EventArgs e)
        {
            this.model.Categories.Clear();
            PropertyValue activePropertyValue = this.childrenView.CurrentItem as PropertyValue;

            this.removeItemCommand.IsEnabled = this.IsRemoveEnabled;
            this.moveUpCommand.IsEnabled     = this.IsMoveUpEnabled;
            this.moveDownCommand.IsEnabled   = this.IsMoveDownEnabled;
            this.primitiveEditorContent      = null;
            this.primitiveEditorVisibility   = Visibility.Collapsed;
            if (activePropertyValue != null)
            {
                Type   selectedType = activePropertyValue.get_ParentProperty().get_PropertyType();
                object obj          = activePropertyValue.get_Value();
                if (obj != null)
                {
                    selectedType = obj.GetType();
                }
                if (selectedType.IsPrimitive || selectedType == typeof(string) || activePropertyValue.get_SubProperties().get_Count() == 0)
                {
                    this.primitiveEditorVisibility = Visibility.Visible;
                    PropertyValueEditor propertyValueEditor = activePropertyValue.get_ParentProperty().get_PropertyValueEditor();
                    this.primitiveEditorContent  = (object)activePropertyValue;
                    this.primitiveEditorTemplate = propertyValueEditor == null?this.TryFindResource((object)"PropertyContainerDefaultInlineTemplate") as DataTemplate : propertyValueEditor.get_InlineEditorTemplate();
                }
                else
                {
                    using (IEnumerator <PropertyEntry> enumerator = activePropertyValue.get_SubProperties().GetEnumerator())
                    {
                        while (((IEnumerator)enumerator).MoveNext())
                        {
                            PropertyEntry current          = enumerator.Current;
                            CategoryBase  orCreateCategory = this.model.FindOrCreateCategory(current.get_CategoryName(), selectedType);
                            if (current.get_IsAdvanced())
                            {
                                orCreateCategory.AdvancedProperties.Add(current);
                            }
                            else
                            {
                                orCreateCategory.BasicProperties.Add(current);
                            }
                        }
                    }
                }
            }
            this.OnPropertyChanged("PrimitiveEditorVisibility");
            this.OnPropertyChanged("PrimitiveEditorContent");
            this.OnPropertyChanged("PrimitiveEditorTemplate");
            this.model.OnRebuildComplete(activePropertyValue);
            this.indexToSelect = this.childrenView.CurrentPosition;
        }
        static InitializeCorrelationDesigner()
        {
            Type type = typeof(InitializeCorrelation);
            AttributeTableBuilder builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(type, type.GetProperty("Correlation"),
                                        new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingCorrelatesWithHint")));

            builder.AddCustomAttributes(type, type.GetProperty("CorrelationData"),
                                        PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationDataValueEditor)),
                                        new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingCorrelationDataHint")));

            builder.AddCustomAttributes(type, "CorrelationData", BrowsableAttribute.Yes);
            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Exemplo n.º 28
0
        internal static void RegisterMetadata(AttributeTableBuilder builder)
        {
            Type endpointType = typeof(Endpoint);

            var browsableAttribute = new BrowsableAttribute(false);

            builder.AddCustomAttributes(endpointType, endpointType.GetProperty("BehaviorConfigurationName"), browsableAttribute);
            builder.AddCustomAttributes(endpointType, endpointType.GetProperty("Headers"), browsableAttribute);
            builder.AddCustomAttributes(endpointType, endpointType.GetProperty("Identity"), browsableAttribute);
            builder.AddCustomAttributes(endpointType, endpointType.GetProperty("Name"), browsableAttribute);
            builder.AddCustomAttributes(endpointType, endpointType.GetProperty("ListenUri"), browsableAttribute);
            builder.AddCustomAttributes(endpointType, endpointType.GetProperty("ServiceContractName"), browsableAttribute);

            builder.AddCustomAttributes(endpointType, endpointType.GetProperty("Binding"),
                                        PropertyValueEditor.CreateEditorAttribute(typeof(BindingPropertyValueEditor)));
        }
Exemplo n.º 29
0
 private void OnChildrenViewCurrentChanged(object sender, EventArgs e)
 {
     this.model.Categories.Clear();
     Microsoft.Windows.Design.PropertyEditing.PropertyValue activePropertyValue = this.childrenView.CurrentItem as Microsoft.Windows.Design.PropertyEditing.PropertyValue;
     this.removeItemCommand.IsEnabled = this.IsRemoveEnabled;
     this.moveUpCommand.IsEnabled     = this.IsMoveUpEnabled;
     this.moveDownCommand.IsEnabled   = this.IsMoveDownEnabled;
     this.primitiveEditorContent      = (object)null;
     this.primitiveEditorVisibility   = Visibility.Collapsed;
     if (activePropertyValue != null)
     {
         Type   selectedType = activePropertyValue.ParentProperty.PropertyType;
         object obj          = activePropertyValue.Value;
         if (obj != null)
         {
             selectedType = obj.GetType();
         }
         if (selectedType.IsPrimitive || selectedType == typeof(string) || activePropertyValue.SubProperties.Count == 0)
         {
             this.primitiveEditorVisibility = Visibility.Visible;
             PropertyValueEditor propertyValueEditor = activePropertyValue.ParentProperty.PropertyValueEditor;
             this.primitiveEditorContent  = (object)activePropertyValue;
             this.primitiveEditorTemplate = propertyValueEditor == null?this.TryFindResource((object)"PropertyContainerDefaultInlineTemplate") as DataTemplate : propertyValueEditor.InlineEditorTemplate;
         }
         else
         {
             foreach (PropertyEntry propertyEntry in activePropertyValue.SubProperties)
             {
                 CategoryBase orCreateCategory = this.model.FindOrCreateCategory(propertyEntry.CategoryName, selectedType);
                 if (propertyEntry.IsAdvanced)
                 {
                     orCreateCategory.AdvancedProperties.Add(propertyEntry);
                 }
                 else
                 {
                     orCreateCategory.BasicProperties.Add(propertyEntry);
                 }
             }
         }
     }
     this.OnPropertyChanged("PrimitiveEditorVisibility");
     this.OnPropertyChanged("PrimitiveEditorContent");
     this.OnPropertyChanged("PrimitiveEditorTemplate");
     this.model.OnRebuildComplete(activePropertyValue);
     this.indexToSelect = this.childrenView.CurrentPosition;
 }
Exemplo n.º 30
0
        // <summary>
        // Look for and return any custom PropertyValueEditor defined for the specified ModelProperty
        // </summary>
        // <param name="property">ModelProperty to examine</param>
        // <returns>A custom PropertyValueEditor for the specified ModelProperty (may be null)</returns>
        public static PropertyValueEditor GetCustomPropertyValueEditor(ModelProperty property)
        {
            if (property == null)
            {
                return(null);
            }

            PropertyValueEditor editor = ExtensibilityMetadataHelper.GetValueEditor(property.Attributes, MessageLogger.Instance);

            //if property is a generic type, check for designer defined at generic type definition
            if (editor == null && property.PropertyType.IsGenericType)
            {
                Type genericType = property.PropertyType.GetGenericTypeDefinition();
                editor = ExtensibilityMetadataHelper.GetValueEditor(TypeDescriptor.GetAttributes(genericType), MessageLogger.Instance);
            }

            return(editor);
        }