/// <summary> /// Add design time attributes. /// </summary> /// <param name="builder">The assembly attribute table builder.</param> private static void AddAttributes(AttributeTableBuilder builder) { builder.AddCustomAttributes( typeof(SignInButton), new Attribute[] { new DefaultPropertyAttribute("ClientId"), new DefaultEventAttribute("SessionChanged"), new ToolboxBrowsableAttribute(true), new ToolboxCategoryAttribute(LiveServicesCategory), new ToolboxTabNameAttribute(LiveServicesCategory)}); EditorBrowsableAttribute browsableAlways = new EditorBrowsableAttribute(EditorBrowsableState.Always); CategoryAttribute categoryLive = new CategoryAttribute(LiveServicesCategory); DescriptionAttribute description = new DescriptionAttribute(StringResources.DescriptionBrandingType); builder.AddCustomAttributes( typeof(SignInButton), "Branding", new Attribute[] { browsableAlways, categoryLive, description }); description = new DescriptionAttribute(StringResources.DescriptionClientId); builder.AddCustomAttributes( typeof(SignInButton), "ClientId", new Attribute[] { browsableAlways, categoryLive, description }); description = new DescriptionAttribute(StringResources.DescriptionRedirectUri); builder.AddCustomAttributes( typeof(SignInButton), "RedirectUri", new Attribute[] { browsableAlways, categoryLive, description }); description = new DescriptionAttribute(StringResources.DescriptionScopes); DefaultValueAttribute defaultValue = new DefaultValueAttribute("wl.signin"); builder.AddCustomAttributes( typeof(SignInButton), "Scopes", new Attribute[] { browsableAlways, categoryLive, description, defaultValue }); description = new DescriptionAttribute(StringResources.DescriptionTextType); builder.AddCustomAttributes( typeof(SignInButton), "TextType", new Attribute[] { browsableAlways, categoryLive, description }); description = new DescriptionAttribute(StringResources.DescriptionSigninText); builder.AddCustomAttributes( typeof(SignInButton), "SignInText", new Attribute[] { browsableAlways, categoryLive, description }); description = new DescriptionAttribute(StringResources.DescriptionSignoutText); builder.AddCustomAttributes( typeof(SignInButton), "SignOutText", new Attribute[] { browsableAlways, categoryLive, description }); }
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); }
public override bool Equals(object obj) { if (obj == this) { return(true); } EditorBrowsableAttribute other = obj as EditorBrowsableAttribute; return((other != null) && other.browsableState == browsableState); }
public void TestComponentModel() { WarningException we = new WarningException("a message"); we = new WarningException(null); AreEqual(EditorBrowsableState.Advanced.ToString(), "Advanced"); EditorBrowsableAttribute eba = new EditorBrowsableAttribute(EditorBrowsableState.Advanced); Assert(eba.GetType().IsSubclassOf(typeof(System.Attribute))); #if !SILVERLIGHT //SilverlightProxies.cs does not define the State property AreEqual(eba.State, EditorBrowsableState.Advanced); #endif }
public static void TestEqual() { var attr = new EditorBrowsableAttribute(EditorBrowsableState.Advanced); Assert.Equal(attr, attr); Assert.True(attr.Equals(attr)); Assert.Equal(attr.GetHashCode(), attr.GetHashCode()); Assert.Equal(new EditorBrowsableAttribute(EditorBrowsableState.Advanced), attr); Assert.Equal(new EditorBrowsableAttribute(EditorBrowsableState.Advanced).GetHashCode(), attr.GetHashCode()); Assert.NotEqual(new EditorBrowsableAttribute(EditorBrowsableState.Always), attr); Assert.NotEqual(new EditorBrowsableAttribute(EditorBrowsableState.Never).GetHashCode(), attr.GetHashCode()); Assert.False(attr.Equals(null)); }
public override bool Equals(object obj) { if (obj == this) { return(true); } EditorBrowsableAttribute attribute1 = obj as EditorBrowsableAttribute; if (attribute1 != null) { return(attribute1.browsableState == this.browsableState); } return(false); }
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); }
private void AddCalendarAttributes() { AddCallback( typeof(Calendar), delegate(AttributeCallbackBuilder builder) { // Set the default property and event builder.AddCustomAttributes(new DefaultPropertyAttribute("SelectedDate")); builder.AddCustomAttributes(new DefaultEventAttribute("SelectedDatesChanged")); // Add the Calendar properties to a Calendar category CategoryAttribute calendarCategory = new CategoryAttribute(SR.Get(SRID.CalendarCategoryTitle)); builder.AddCustomAttributes("BlackoutDates", calendarCategory); builder.AddCustomAttributes(Calendar.CalendarButtonStyleProperty, calendarCategory); builder.AddCustomAttributes(Calendar.CalendarDayButtonStyleProperty, calendarCategory); builder.AddCustomAttributes(Calendar.CalendarItemStyleProperty, calendarCategory); builder.AddCustomAttributes(Calendar.DisplayDateEndProperty, calendarCategory); builder.AddCustomAttributes(Calendar.DisplayDateProperty, calendarCategory); builder.AddCustomAttributes(Calendar.DisplayDateStartProperty, calendarCategory); builder.AddCustomAttributes(Calendar.DisplayModeProperty, calendarCategory); builder.AddCustomAttributes(Calendar.FirstDayOfWeekProperty, calendarCategory); builder.AddCustomAttributes(Calendar.IsTodayHighlightedProperty, calendarCategory); builder.AddCustomAttributes(Calendar.SelectedDateProperty, calendarCategory); builder.AddCustomAttributes("SelectedDates", calendarCategory); builder.AddCustomAttributes(Calendar.SelectionModeProperty, calendarCategory); // Put the Style properties in the "Advanced" part of the category EditorBrowsableAttribute advanced = new EditorBrowsableAttribute(EditorBrowsableState.Advanced); builder.AddCustomAttributes(Calendar.CalendarButtonStyleProperty, advanced); builder.AddCustomAttributes(Calendar.CalendarDayButtonStyleProperty, advanced); builder.AddCustomAttributes(Calendar.CalendarItemStyleProperty, advanced); // SelectedDates and BlackoutDates conflict with each other for now hide them both // to avoid the result of setting a property being an error in the designer builder.AddCustomAttributes("BlackoutDates", BrowsableAttribute.No); builder.AddCustomAttributes("SelectedDates", BrowsableAttribute.No); }); }
private void AddDatePickerAttributes() { AddCallback( typeof(DatePicker), delegate(AttributeCallbackBuilder builder) { // Set the default property and event builder.AddCustomAttributes(new DefaultPropertyAttribute("SelectedDate")); builder.AddCustomAttributes(new DefaultEventAttribute("SelectedDateChanged")); // Add the Calendar properties to a Calendar category CategoryAttribute datePickerCategory = new CategoryAttribute(SR.Get(SRID.DatePickerCategoryTitle)); builder.AddCustomAttributes("BlackoutDates", datePickerCategory); builder.AddCustomAttributes(DatePicker.CalendarStyleProperty, datePickerCategory); builder.AddCustomAttributes(DatePicker.DisplayDateEndProperty, datePickerCategory); builder.AddCustomAttributes(DatePicker.DisplayDateProperty, datePickerCategory); builder.AddCustomAttributes(DatePicker.DisplayDateStartProperty, datePickerCategory); builder.AddCustomAttributes(DatePicker.FirstDayOfWeekProperty, datePickerCategory); builder.AddCustomAttributes(DatePicker.IsTodayHighlightedProperty, datePickerCategory); builder.AddCustomAttributes(DatePicker.SelectedDateProperty, datePickerCategory); builder.AddCustomAttributes(DatePicker.SelectedDateFormatProperty, datePickerCategory); builder.AddCustomAttributes(DatePicker.TextProperty, datePickerCategory); // Put the Style properties in the "Advanced" part of the category EditorBrowsableAttribute advanced = new EditorBrowsableAttribute(EditorBrowsableState.Advanced); builder.AddCustomAttributes(DatePicker.CalendarStyleProperty, advanced); builder.AddCustomAttributes(DatePicker.IsDropDownOpenProperty, BrowsableAttribute.No); // SelectedDate and BlackoutDates conflict with each other so hide BlackoutDates for now // to avoid the result of setting a property being an error in the designer builder.AddCustomAttributes("BlackoutDates", BrowsableAttribute.No); }); }
static ReceiveDesigner() { AttributeTableBuilder builder = new AttributeTableBuilder(); Type receiveType = typeof(Receive); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelationInitializers"), PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor))); var categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(CorrelationsCategoryLabelKey)); var descriptionAttribute = new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingCorrelatesWithHint", "<Correlation handle>")); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelatesWith"), categoryAttribute, descriptionAttribute); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelatesOn"), categoryAttribute, BrowsableAttribute.Yes, PropertyValueEditor.CreateEditorAttribute(typeof(CorrelatesOnValueEditor))); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CorrelationInitializers"), categoryAttribute, BrowsableAttribute.Yes, PropertyValueEditor.CreateEditorAttribute(typeof(CorrelationInitializerValueEditor))); categoryAttribute = new CategoryAttribute(EditorCategoryTemplateDictionary.Instance.GetCategoryTitle(MiscellaneousCategoryLabelKey)); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("DisplayName"), categoryAttribute); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("OperationName"), categoryAttribute); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("ServiceContractName"), categoryAttribute, new TypeConverterAttribute(typeof(XNameConverter))); descriptionAttribute = new DescriptionAttribute(StringResourceDictionary.Instance.GetString("messagingValueHint", "<Value to bind>")); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("Content"), categoryAttribute, descriptionAttribute, PropertyValueEditor.CreateEditorAttribute(typeof(ReceiveContentPropertyEditor))); var advancedAttribute = new EditorBrowsableAttribute(EditorBrowsableState.Advanced); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("Action"), advancedAttribute, categoryAttribute); builder.AddCustomAttributes( receiveType, "KnownTypes", advancedAttribute, categoryAttribute, PropertyValueEditor.CreateEditorAttribute(typeof(TypeCollectionPropertyEditor)), new EditorOptionAttribute { Name = TypeCollectionPropertyEditor.AllowDuplicate, Value = false }); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("ProtectionLevel"), advancedAttribute, categoryAttribute); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("SerializerOption"), advancedAttribute, categoryAttribute); builder.AddCustomAttributes(receiveType, receiveType.GetProperty("CanCreateInstance"), advancedAttribute, categoryAttribute); Action = receiveType.GetProperty("Action").Name; Type receiveMessageContentType = typeof(ReceiveMessageContent); Message = receiveMessageContentType.GetProperty("Message").Name; DeclaredMessageType = receiveMessageContentType.GetProperty("DeclaredMessageType").Name; MetadataStore.AddAttributeTable(builder.CreateTable()); Func<Activity, IEnumerable<ArgumentAccessor>> argumentAccessorGenerator = (activity) => new ArgumentAccessor[] { new ArgumentAccessor { Getter = (ownerActivity) => { Receive receive = (Receive)ownerActivity; ReceiveMessageContent content = receive.Content as ReceiveMessageContent; return content != null ? content.Message : null; }, Setter = (ownerActivity, arg) => { Receive receive = (Receive)ownerActivity; ReceiveMessageContent content = receive.Content as ReceiveMessageContent; if (content != null) { content.Message = arg as OutArgument; } }, }, }; ActivityArgumentHelper.RegisterAccessorsGenerator(receiveType, argumentAccessorGenerator); }