Inheritance: System.Attribute, System.Runtime.InteropServices._Attribute
Exemplo n.º 1
0
        public MyPropertyDescriptor(object component, string name, Attribute[] attributes)
            : base(name, attributes)
        {
            PropertyInfo propertyInfo = component.GetType().GetProperty(name);

            if (propertyInfo == null)
            {
                throw new ArgumentException(string.Format("Name:{0} is not a valid member of Type:{1}", name, component.GetType().ToString()));
            }

            Component = component;
            _Name     = name;

            DisplayNameAttribute nameAttribute = attributes.First(e => e is DisplayNameAttribute) as DisplayNameAttribute;

            if (nameAttribute != null)
            {
                _DisplayName = nameAttribute.DisplayName;
            }

            CategoryAttribute categoryAttribute = attributes.First(e => e is CategoryAttribute) as CategoryAttribute;

            if (categoryAttribute != null)
            {
                _Category = categoryAttribute.Category;
            }
        }
Exemplo n.º 2
0
        public void CategoryProperties_GetCategory_ReturnsExpected(Func <CategoryAttribute> attributeThunk, string expectedCategory)
        {
            CategoryAttribute attribute = attributeThunk();

            Assert.Same(attribute, attributeThunk());
            Assert.Equal(expectedCategory, attribute.Category);
        }
        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);
        }
        public void GetCategory()
        {
            var category = "test category";
            var attribute = new CategoryAttribute(category);

            Assert.Equal(category, attribute.Category);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns the Category Tree created from the Category Attributes on the properties in the model.
        /// </summary>
        /// <returns></returns>
        private CategoryTree GetPropertyCategories()
        {
            CategoryTree categories = new CategoryTree();

            Model firstChild = null;

            this.childrenWithSameType = this.GetChildModelsWithSameType(this.model);
            if (childrenWithSameType != null)
            {
                firstChild = this.childrenWithSameType.First() as Model;
            }

            if (firstChild != null)
            {
                foreach (PropertyInfo property in firstChild.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy))
                {
                    // Properties must have a [Description], not be called Name, and be read/write.
                    bool hasDescription  = property.IsDefined(typeof(DescriptionAttribute), false);
                    bool includeProperty = hasDescription &&
                                           property.Name != "Name" &&
                                           property.CanRead &&
                                           property.CanWrite;

                    // Only allow lists that are double[], int[] or string[]
                    if (includeProperty && property.PropertyType.GetInterface("IList") != null)
                    {
                        includeProperty = property.PropertyType == typeof(double[]) ||
                                          property.PropertyType == typeof(int[]) ||
                                          property.PropertyType == typeof(string[]);
                    }

                    if (includeProperty)
                    {
                        // Those properties with a [Catagory] attribute
                        bool hasCategory = property.IsDefined(typeof(CategoryAttribute), false);
                        if (hasCategory)
                        {
                            //get the attribute data
                            CategoryAttribute catAtt = (CategoryAttribute)property.GetCustomAttribute(typeof(CategoryAttribute));

                            //add the category name to the list of category items
                            categories.AddCategoryToTree(catAtt.Category);
                            //add the subcategory name to the list of subcategories for the category
                            CategoryItem catItem = categories.FindCategoryInTree(catAtt.Category);
                            catItem.AddSubcategoryName(catAtt.Subcategory);
                        }
                        else
                        {
                            //If there is not [Category] attribute at all on the property in the model.
                            //Add it to the "Unspecified" Category, and "Unspecified" Subcategory

                            categories.AddCategoryToTree("Unspecified");
                            CategoryItem catItem = categories.FindCategoryInTree("Unspecified");
                            catItem.AddSubcategoryName("Unspecified");
                        }
                    }
                }
            }
            return(categories);
        }
Exemplo n.º 6
0
        public void Register()
        {
            var workbook = new CategoryAttribute(WORKBOOK);

            ActivitiesAttributesBuilder.Build(Resources.ResourceManager, builder =>
            {
                builder.SetDefaultCategories(
                    Resources.Input_Category,
                    Resources.Output_Category,
                    Resources.InputOutput_Category,
                    Resources.Options_Category);

                builder.Register <GetSheetName, GetSheetNameDesigner>(workbook)
                .Register <GetSheetNames, GetSheetNamesDesigner>(workbook)
                .Register <GetHyperlinks, GetHyperlinksDesigner>(workbook)
                .Register <InsertHyperlink, InsertHyperlinkDesigner>(workbook)
                .Register <RemoveHyperlinks, RemoveHyperlinksDesigner>(workbook)
                .Register <WorkbookScope, WorkbookScopeDesigner>(workbook);

                builder.RegisterToMember(
                    new DescriptionAttribute(Resources.ScopeAwareCodeActivity_UseScope),
                    nameof(ScopeAwareCodeActivity <object, object> .UseScope),
                    typeof(ScopeAwareCodeActivity <,>).GetDerivedTypes());
            });
        }
        public void Equals_DifferentCategories()
        {
            var firstAttribute = new CategoryAttribute("category");
            var secondAttribute = new DescriptionAttribute(string.Empty);

            Assert.False(firstAttribute.Equals(secondAttribute));
        }
Exemplo n.º 8
0
        public void Ctor_Category(string category, bool expectedIsDefaultAttribute)
        {
            var attribute = new CategoryAttribute(category);

            Assert.Equal(category, attribute.Category);
            Assert.Equal(expectedIsDefaultAttribute, attribute.IsDefaultAttribute());
        }
Exemplo n.º 9
0
        private void AddMonthViewAttributes()
        {
            AddCallback(typeof(FXMonthView), builder =>
            {
                builder.AddCustomAttributes(FXMonthView.ButtonStyleProperty.Name, BrowsableAttribute.No);
                builder.AddCustomAttributes(FXMonthView.WeekDayHeaderStyleProperty.Name, BrowsableAttribute.No);
                builder.AddCustomAttributes(FXMonthView.HeaderMonthStyleProperty.Name, BrowsableAttribute.No);
                builder.AddCustomAttributes(FXMonthView.DayContainerStyleProperty.Name, BrowsableAttribute.No);
                builder.AddCustomAttributes(FXMonthView.HeaderYearStyleProperty.Name, BrowsableAttribute.No);
                builder.AddCustomAttributes(FXMonthView.DayContainerStyleSelectorProperty.Name, BrowsableAttribute.No);
                builder.AddCustomAttributes(FXMonthView.DayTemplateSelectorProperty.Name, BrowsableAttribute.No);
                builder.AddCustomAttributes(FXMonthView.DayTemplateProperty.Name, BrowsableAttribute.No);
                builder.AddCustomAttributes(FXMonthView.ViewPreChangeAnimationProperty.Name, BrowsableAttribute.No);
                builder.AddCustomAttributes(FXMonthView.ViewPostChangeAnimationProperty.Name, BrowsableAttribute.No);

                var behaviorCategory = new CategoryAttribute("Behavior");
                builder.AddCustomAttributes(FXMonthView.ViewDateTimeProperty.Name, behaviorCategory);
                builder.AddCustomAttributes(FXMonthView.SelectedDateTimeProperty.Name, behaviorCategory);
                builder.AddCustomAttributes(FXMonthView.ShowTodayButtonProperty.Name, behaviorCategory);
                builder.AddCustomAttributes(FXMonthView.ShowEmptyButtonProperty.Name, behaviorCategory);
                builder.AddCustomAttributes(FXMonthView.ShowWeekDayNamesProperty.Name, behaviorCategory);
                builder.AddCustomAttributes(FXMonthView.MaxDateProperty.Name, behaviorCategory);
                builder.AddCustomAttributes(FXMonthView.MinDateProperty.Name, behaviorCategory);

                builder.AddCustomAttributes();
            });
        }
Exemplo n.º 10
0
 protected void PrepareFields(SerializedProperty obj)
 {
     if (obj.NextVisible(true))
     {
         string       lastHeader = string.Empty;
         CategoryData tempCategoryData;
         do
         {
             CategoryAttribute category = GetPropertyAttribute <CategoryAttribute>(obj, false);
             if (category == null && string.IsNullOrEmpty(lastHeader))
             {
                 // Uncategorized
                 lastHeader       = UNCATEGORIZED_HEADER;
                 tempCategoryData = CreateOrGetCategoryData(categorizedProperties, lastHeader, UNCATEGORIZED_ORDER, false);
             }
             else if (category != null)
             {
                 // Categorized by header
                 lastHeader       = category.category;
                 tempCategoryData = CreateOrGetCategoryData(categorizedProperties, lastHeader, category.order, category.isFoldoutByDefault);
             }
             else
             {
                 // Get category data by previous header
                 tempCategoryData = CreateOrGetCategoryData(categorizedProperties, lastHeader, 0, false);
             }
             tempCategoryData.PropertyPaths.Add(obj.propertyPath);
         } while (obj.NextVisible(false));
     }
 }
Exemplo n.º 11
0
        public void DefaultConstructorTest()
        {
            string            category = "AssemblyName";
            CategoryAttribute target   = VisualStudio_Project_Samples_ResourcesCategoryAttributeAccessor.CreatePrivate(category);

            Assert.IsNotNull(target, "CategoryAttribute instance was not created successfully.");
        }
        public void Register()
        {
            CategoryAttribute category = new CategoryAttribute(Resources.DropboxActivitiesCategory);

            AttributeTableBuilder builder = new AttributeTableBuilder();
            ShowPropertyInOutlineViewAttribute hideFromOutlineAttribute = new ShowPropertyInOutlineViewAttribute()
            {
                CurrentPropertyVisible = false, DuplicatedChildNodesVisible = false
            };

            builder.AddCustomAttributes(typeof(WithDropboxSession), nameof(WithDropboxSession.Body), hideFromOutlineAttribute);

            builder.AddCustomAttributes(typeof(Copy), category);
            builder.AddCustomAttributes(typeof(CreateFile), category);
            builder.AddCustomAttributes(typeof(CreateFolder), category);
            builder.AddCustomAttributes(typeof(Delete), category);
            builder.AddCustomAttributes(typeof(DownloadFile), category);
            builder.AddCustomAttributes(typeof(DownloadFolderAsZip), category);
            builder.AddCustomAttributes(typeof(GetFolderContent), category);
            builder.AddCustomAttributes(typeof(Move), category);
            builder.AddCustomAttributes(typeof(UploadFile), category);
            builder.AddCustomAttributes(typeof(WithDropboxSession), category);

            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Exemplo n.º 13
0
        public void SetCategory(string category)
        {
            // If this thing already has a
            // category attribute then let's
            // replace it.  Otherwise add a new
            // instance
            bool found = false;
            for(int i = 0; i < Attributes.Count; i++)
            {
                Attribute attribute = Attributes[i];
                if (attribute is CategoryAttribute)
                {
                    CategoryAttribute categoryAttribute = new CategoryAttribute(category);
                    Attributes[i] = categoryAttribute;
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                CategoryAttribute categoryAttribute = new CategoryAttribute(category);
                Attributes.Add(categoryAttribute);
            }
        }
Exemplo n.º 14
0
        public void GetCategory()
        {
            var category  = "test category";
            var attribute = new CategoryAttribute(category);

            Assert.Equal(category, attribute.Category);
        }
Exemplo n.º 15
0
        public void Equals_DifferentCategories()
        {
            var firstAttribute  = new CategoryAttribute("category");
            var secondAttribute = new DescriptionAttribute(string.Empty);

            Assert.False(firstAttribute.Equals(secondAttribute));
        }
        public void Register()
        {
            var builder = new AttributeTableBuilder();

            builder.ValidateTable();

            var categoryAttribute = new CategoryAttribute($"{Resources.Category}");

            builder.AddCustomAttributes(typeof(ZendeskScope), categoryAttribute);
            builder.AddCustomAttributes(typeof(ZendeskScope), new DesignerAttribute(typeof(ZendeskScopeDesigner)));
            builder.AddCustomAttributes(typeof(ZendeskScope), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetTicket), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetTicket), new DesignerAttribute(typeof(GetTicketDesigner)));
            builder.AddCustomAttributes(typeof(GetTicket), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(UpdateTicket), categoryAttribute);
            builder.AddCustomAttributes(typeof(UpdateTicket), new DesignerAttribute(typeof(UpdateTicketDesigner)));
            builder.AddCustomAttributes(typeof(UpdateTicket), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetUser), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetUser), new DesignerAttribute(typeof(GetUserDesigner)));
            builder.AddCustomAttributes(typeof(GetUser), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetUserFields), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetUserFields), new DesignerAttribute(typeof(GetUserFieldsDesigner)));
            builder.AddCustomAttributes(typeof(GetUserFields), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetTicketFieldOption), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetTicketFieldOption), new DesignerAttribute(typeof(GetTicketFieldOptionDesigner)));
            builder.AddCustomAttributes(typeof(GetTicketFieldOption), new HelpKeywordAttribute(""));


            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Exemplo n.º 17
0
        internal static string GetDisplayName(Type t)
        {
            string text = "";
            string str  = ObjectNames.NicifyVariableName(t.Name);

            object[] customAttributes = t.GetCustomAttributes(true);
            for (int i = 0; i < customAttributes.Length; i++)
            {
                object obj = customAttributes[i];
                if (obj is CategoryAttribute)
                {
                    CategoryAttribute categoryAttribute = obj as CategoryAttribute;
                    text = categoryAttribute.Category;
                }
                else if (obj is DisplayNameAttribute)
                {
                    DisplayNameAttribute displayNameAttribute = obj as DisplayNameAttribute;
                    str = displayNameAttribute.DisplayName;
                }
            }
            if (text.Length > 0 && text[text.Length - 1] != '/')
            {
                text += '/';
            }
            return(text + str);
        }
Exemplo n.º 18
0
                    public ObjectContainerPropertyDescriptor(Type componentType, Type propertyType)
                        : base(componentType, "Value", propertyType)
                    {
                        CategoryAttribute cat = new CategoryAttribute(propertyType.Name);

                        attributes = new AttributeCollection(new Attribute[] { cat });
                    }
Exemplo n.º 19
0
        private void GetMemberDisplayProperties(MemberInfo info, out string displayName, out string description, out string category)
        {
            displayName = string.Empty;
            description = string.Empty;
            category    = string.Empty;

            if (GetCustomAttribute(info, typeof(DescriptionAttribute)) is DescriptionAttribute descAttr)
            {
                description = descAttr.Description;
            }

            DisplayNameAttribute dispNameAttr = GetCustomAttribute(info, typeof(DisplayNameAttribute)) as DisplayNameAttribute;

            if (dispNameAttr != null)
            {
                displayName = dispNameAttr.DisplayName;
            }

            CategoryAttribute catAttr = GetCustomAttribute(info, typeof(CategoryAttribute)) as CategoryAttribute;

            if (dispNameAttr != null)
            {
                category = catAttr.Category;
            }

            if (string.IsNullOrEmpty(displayName))
            {
                displayName = info.Name;
            }
        }
Exemplo n.º 20
0
        public void Register()
        {
            #region Setup

            var builder = new AttributeTableBuilder();
            builder.ValidateTable();

            var categoryAttribute = new CategoryAttribute($"{Resources.Category}");

            #endregion Setup


            builder.AddCustomAttributes(typeof(BitbucketAPIScope), categoryAttribute);
            builder.AddCustomAttributes(typeof(BitbucketAPIScope), new DesignerAttribute(typeof(BitbucketAPIScopeDesigner)));
            builder.AddCustomAttributes(typeof(BitbucketAPIScope), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetRepositories), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetRepositories), new DesignerAttribute(typeof(GetRepositoriesDesigner)));
            builder.AddCustomAttributes(typeof(GetRepositories), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(ManageRepository), categoryAttribute);
            builder.AddCustomAttributes(typeof(ManageRepository), new DesignerAttribute(typeof(ManageRepositoryDesigner)));
            builder.AddCustomAttributes(typeof(ManageRepository), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(CommitFile), categoryAttribute);
            builder.AddCustomAttributes(typeof(CommitFile), new DesignerAttribute(typeof(CommitFileDesigner)));
            builder.AddCustomAttributes(typeof(CommitFile), new HelpKeywordAttribute(""));

            builder.AddCustomAttributes(typeof(GetWorkspaces), categoryAttribute);
            builder.AddCustomAttributes(typeof(GetWorkspaces), new DesignerAttribute(typeof(GetWorkspacesDesigner)));
            builder.AddCustomAttributes(typeof(GetWorkspaces), new HelpKeywordAttribute(""));


            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Exemplo n.º 21
0
 protected bool IsPropertySelected(PropertyInfo property)
 {
     if ((this.selectedCategory ?? "") != "") // a category has been selected
     {
         if (Attribute.IsDefined(property, typeof(CategoryAttribute), false))
         {
             CategoryAttribute catAtt = (CategoryAttribute)Attribute.GetCustomAttribute(property, typeof(CategoryAttribute));
             if (catAtt.Category.StartsWith("*") || Array.Exists(catAtt.Category.Split(':'), element => element == this.selectedCategory))
             {
                 if ((selectedSubCategory ?? "") != "") // a sub category has been selected
                 {
                     // The catAtt.Subcategory is by default given a value of
                     // "Unspecified" if the Subcategory is not assigned in the Category Attribute.
                     // so this line below will also handle "Unspecified" subcategories.
                     return(catAtt.Subcategory.StartsWith("*") || Array.Exists(catAtt.Subcategory.Split(':'), element => element == selectedSubCategory));
                 }
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             // if we are filtering on "Unspecified" category then there is no Category Attribute
             // just a Description Attribute on the property in the model.
             // So we still may need to include it in this case.
             return(this.selectedCategory == "Unspecified");
         }
     }
     return(true);
 }
Exemplo n.º 22
0
        /// <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 });
        }
Exemplo n.º 23
0
        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("DatePicker");
                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);
            });
        }
Exemplo n.º 24
0
        public void SetCategory(string category)
        {
            // If this thing already has a
            // category attribute then let's
            // replace it.  Otherwise add a new
            // instance
            bool found = false;

            for (int i = 0; i < Attributes.Count; i++)
            {
                Attribute attribute = Attributes[i];
                if (attribute is CategoryAttribute)
                {
                    CategoryAttribute categoryAttribute = new CategoryAttribute(category);
                    Attributes[i] = categoryAttribute;
                    found         = true;
                    break;
                }
            }

            if (!found)
            {
                CategoryAttribute categoryAttribute = new CategoryAttribute(category);
                Attributes.Add(categoryAttribute);
            }
        }
Exemplo n.º 25
0
        static public int CategorySort(Type p_type1, Type p_type2)
        {
            CategoryAttribute attribute1      = p_type1.GetCustomAttribute <CategoryAttribute>();
            CategoryAttribute attribute2      = p_type2.GetCustomAttribute <CategoryAttribute>();
            string            categoryString1 = attribute1 == null ? "Other" : NodeUtils.CategoryToString(attribute1.type);
            string            categoryString2 = attribute2 == null ? "Other" : NodeUtils.CategoryToString(attribute2.type);
            string            nodeString1     = p_type1.ToString().Substring(p_type1.ToString().IndexOf(".") + 1);
            string            nodeString2     = p_type2.ToString().Substring(p_type2.ToString().IndexOf(".") + 1);

            if (categoryString1 == categoryString2)
            {
                return(nodeString1.CompareTo(nodeString2));
            }

            if (categoryString1 == "Graph")
            {
                return(1);
            }

            if (categoryString2 == "Graph")
            {
                return(-1);
            }

            return(categoryString1.CompareTo(categoryString2));
        }
Exemplo n.º 26
0
        static void ShowAnimationNodeTypesMenu()
        {
            RuntimeGenericMenu menu = new RuntimeGenericMenu();

            if (DashEditorCore.EditorConfig.editingGraph != null)
            {
                Type[] nodeTypes = ReflectionUtils.GetAllTypes(typeof(NodeBase)).ToArray();
                foreach (Type type in nodeTypes)
                {
                    CategoryAttribute attribute = type.GetCustomAttribute <CategoryAttribute>();
                    if (attribute == null || attribute.type != NodeCategoryType.ANIMATION)
                    {
                        continue;
                    }

                    TooltipAttribute tooltipAttribute = type.GetCustomAttribute <TooltipAttribute>();
                    string           tooltip          = tooltipAttribute != null ? tooltipAttribute.help : "";

                    string node = type.ToString().Substring(type.ToString().IndexOf(".") + 1);
                    node = node.Substring(0, node.Length - 4);

                    menu.AddItem(new GUIContent(node, tooltip), false, CreateAnimationNodesFromSelection, type);
                }
            }

            GenericMenuPopup.Show(menu, "", Event.current.mousePosition, 240, 300, false);
        }
Exemplo n.º 27
0
        public void IsDefaultAttribute_NullCategory_ThrowsNullReferenceException()
        {
            var attribute = new CategoryAttribute(null);

            Assert.Null(attribute.Category);
            Assert.Throws <NullReferenceException>(() => attribute.IsDefaultAttribute());
        }
Exemplo n.º 28
0
        public async Task <IHttpActionResult> PutCategoryAttribute(Guid id, CategoryAttribute categoryAttribute)
        {
            Entities.Attribute attribute = await db.Attributes.FirstOrDefaultAsync(x => x.Value == categoryAttribute.Target.Value && x.Code == categoryAttribute.Target.Code);

            if (attribute == null)
            {
                categoryAttribute.Target.Id = Guid.NewGuid();
                categoryAttribute.TargetId  = categoryAttribute.Target.Id;
                db.Attributes.Add(categoryAttribute.Target);
                await db.SaveChangesAsync();

                attribute = await db.Attributes.FindAsync(categoryAttribute.TargetId);
            }
            else
            {
                db.Entry(attribute).CurrentValues.SetValues(categoryAttribute.Target);
                await db.SaveChangesAsync();
            }
            CategoryAttribute existedCategoryAttribute = await db.CategoryAttributes.FindAsync(id);

            db.Entry(existedCategoryAttribute).CurrentValues.SetValues(categoryAttribute);
            await db.SaveChangesAsync();

            return(Ok(existedCategoryAttribute));
        }
Exemplo n.º 29
0
        public ReflectionPropertyInfo(PropertyInfo propertyInfo)
        {
            this.propertyInfo = propertyInfo;

            this.category = new Lazy <string> (() => {
                CategoryAttribute categoryAttribute = this.propertyInfo.GetCustomAttribute <CategoryAttribute> ();
                return(categoryAttribute?.Category);
            });

            this.typeConverter = new Lazy <List <TypeConverter> > (() => {
                List <TypeConverter> converters = new List <TypeConverter> ();

                var attributes = this.propertyInfo.GetCustomAttributes <TypeConverterAttribute> ().Concat(this.propertyInfo.PropertyType.GetCustomAttributes <TypeConverterAttribute> ());
                foreach (TypeConverterAttribute attribute in attributes)
                {
                    Type type = System.Type.GetType(attribute.ConverterTypeName);
                    if (type == null)
                    {
                        continue;
                    }

                    converters.Add((TypeConverter)Activator.CreateInstance(type));
                }

                return(converters);
            });
        }
Exemplo n.º 30
0
        public void Register()
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            // Designers
            builder.AddCustomAttributes(typeof(PythonScope), new DesignerAttribute(typeof(PythonScopeDesigner)));
            builder.AddCustomAttributes(typeof(LoadScript), new DesignerAttribute(typeof(LoadScriptDesigner)));
            builder.AddCustomAttributes(typeof(RunScript), new DesignerAttribute(typeof(RunScriptDesigner)));

            // Browsable false

            // DisplayNames

            //Categories
            CategoryAttribute pythonCategoryAttribute =
                new CategoryAttribute($"{Resources.CategoryAppInvoker}.{Resources.CategoryPython}");

            builder.AddCustomAttributes(typeof(PythonScope), pythonCategoryAttribute);
            builder.AddCustomAttributes(typeof(RunScript), pythonCategoryAttribute);
            builder.AddCustomAttributes(typeof(LoadScript), pythonCategoryAttribute);
            builder.AddCustomAttributes(typeof(InvokeMethod), pythonCategoryAttribute);
            builder.AddCustomAttributes(typeof(GetObject <>), pythonCategoryAttribute);

            // Generic TypeArgument
            Type attrType            = Type.GetType("System.Activities.Presentation.FeatureAttribute, System.Activities.Presentation");
            Type argType             = Type.GetType("System.Activities.Presentation.UpdatableGenericArgumentsFeature, System.Activities.Presentation");
            var  genericTypeArgument = Activator.CreateInstance(attrType, new object[] { argType }) as Attribute;

            builder.AddCustomAttributes(typeof(GetObject <>), genericTypeArgument);
            builder.AddCustomAttributes(typeof(GetObject <>), new DefaultTypeArgumentAttribute(typeof(object)));

            AddDisplayNameToActivities(builder, typeof(PythonScope).Assembly, nameof(Activity.DisplayName), new DisplayNameAttribute(Resources.DisplayName));

            MetadataStore.AddAttributeTable(builder.CreateTable());
        }
Exemplo n.º 31
0
        protected string ExtractCategory()
        {
            AttributeCollection attribs = TypeDescriptor.GetAttributes(this.GetType());
            CategoryAttribute   attr    = (CategoryAttribute)attribs[typeof(CategoryAttribute)];

            return(attr.Category);
        }
Exemplo n.º 32
0
        public void Ctor_Default()
        {
            var attribute = new CategoryAttribute();

            Assert.Equal("Misc", attribute.Category);
            Assert.True(attribute.IsDefaultAttribute());
        }
Exemplo n.º 33
0
        /// <summary>
        /// Sets the user configurable value from the <see cref="OnlineVideoSettings.UserStore "/> to the given field
        /// when it is attributed with the <see cref="CategoryAttribute"/> and the <see cref="ONLINEVIDEOS_USERCONFIGURATION_CATEGORY"/>.
        /// </summary>
        /// <param name="field"></param>
        /// <param name="categoryAttribute"></param>
        protected virtual void SetUserConfigurationValue(FieldInfo field, CategoryAttribute categoryAttribute)
        {
            if (categoryAttribute != null &&
                categoryAttribute.Category == ONLINEVIDEOS_USERCONFIGURATION_CATEGORY &&
                OnlineVideoSettings.Instance.UserStore != null)
            {
                try
                {
                    // values marked as password must be decrypted
                    bool     decrypt = false;
                    object[] attrs   = field.GetCustomAttributes(typeof(PasswordPropertyTextAttribute), false);
                    if (attrs != null && attrs.Length > 0)
                    {
                        decrypt = ((PasswordPropertyTextAttribute)attrs[0]).Password;
                    }

                    string value = OnlineVideoSettings.Instance.UserStore.GetValue(GetConfigurationKey(field.Name), decrypt);
                    if (value != null)
                    {
                        if (field.FieldType.IsEnum)
                        {
                            field.SetValue(this, Enum.Parse(field.FieldType, value));
                        }
                        else
                        {
                            field.SetValue(this, Convert.ChangeType(value, field.FieldType));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Warn("{0} - could not set User Configuration Value: {1}. Error: {2}", ToString(), field.Name, ex.Message);
                }
            }
        }
Exemplo n.º 34
0
 public ExpressionDocumentation(ResourceKeyStack messagePath, IExpressionParser expr, Type type)
 {
     GatherTokens(expr);
     _name = type.Name;
     _messagePath = messagePath.BranchFor(expr);
     _category = CategoryHelper.GetCategory(type);
     _description = _messagePath.Description;
 }
        /// <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 });            
        }
Exemplo n.º 36
0
        private CategoryAttributeValue GetCategoryAttributeValuesForMultiselect(CategoryAttribute attribute, AttributeValueModel attributeValue)
        {
            var selectedOptions = new Collection<CategoryAttributeOption>();
            for (var i = 0; i < attribute.Options.Count; i++)
                if (bool.Parse(attributeValue.Values[i]))
                    selectedOptions.Add(attribute.Options.ElementAt(i));

            return selectedOptions.Any() ? new CategoryAttributeValue { Attribute = attribute, SelectedOptions = selectedOptions } : null;
        }
 public ActionResult Edit(CategoryAttribute categoryattribute)
 {
     if (ModelState.IsValid)
     {
         context.Entry(categoryattribute).State = EntityState.Modified;
         context.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(categoryattribute);
 }
Exemplo n.º 38
0
 public FunctionDocumentation(string libName, ResourceKeyStack messagePath, IFunctionDefinition func)
 {
     _libName = libName;
     _name = func.Name;
     _arguments = func.Arguments;
     _returnType = func.ReturnType;
     _messagePath = messagePath.BranchFor(func);
     _description=_messagePath.Description;
     _category = CategoryHelper.GetCategory(func.GetType());
 }
        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 ActionResult Create(CategoryAttribute categoryattribute)
        {
            if (ModelState.IsValid)
            {
                context.CategoryAttributes.Add(categoryattribute);
                context.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(categoryattribute);
        }
Exemplo n.º 41
0
 public FilteredPropertyGrid()
 {
     base.SelectedObject = m_Wrapper;
     attributes[0] = new CategoryAttribute("Layout");
     attributes[1] = new CategoryAttribute("Data");
     attributes[2] = new CategoryAttribute("Appearance");
     attributes[3] = new CategoryAttribute("Behavior");
     this.BrowsableAttributes = new
        AttributeCollection(attributes);
     this.PropertyValueChanged += new PropertyValueChangedEventHandler(FilteredPropertyGrid_PropertyValueChanged);
 }
Exemplo n.º 42
0
        public ActionResult Create(FormCollection form)
        {
            try
            {
                using (var context = new CatalogueContainer())
                {
                    var attribute = new CategoryAttribute();
                    TryUpdateModel(attribute, new[] { "Title", "Name" });
                    context.AddToCategoryAttribute(attribute);
                    context.SaveChanges();
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public ObjectPropertyDescriptor(MemberDescriptor descr, IContext context, IPropertyMap propertyMap, object obj, Attribute[] attrs)
            : base(descr, attrs)
        {
            this.realPropertyDescriptor = (PropertyDescriptor) descr;
            this.name = propertyMap.Name;
            this.displayName = propertyMap.Name;

            Attribute[] attribs = new Attribute[descr.Attributes.Count + 4];

            int i = 0;
            foreach (Attribute attrib in descr.Attributes)
            {
                attribs[i] = attrib;
                i++;
            }
            attribs[i] = new DescriptionAttribute(propertyMap.Name + " is a property.");
            attribs[i + 1] = new CategoryAttribute("");
            attribs[i + 2] = new DefaultValueAttribute(context.ObjectManager.GetOriginalPropertyValue(obj, propertyMap.Name));
            attribs[i + 3] = new ReadOnlyAttribute(propertyMap.IsReadOnly);

            attributes = new AttributeCollection(attribs);
        }
Exemplo n.º 44
0
        public WrappedProperty(MemberDescriptor descr, PropertyView propertyView, Attribute[] attrs)
            : base(descr, attrs)
        {
            this.realPropertyDescriptor = (PropertyDescriptor) descr;
            this.name = propertyView.Name;
            this.displayName = propertyView.DisplayName;

            Attribute[] attribs = new Attribute[descr.Attributes.Count + 4];

            int i = 0;
            foreach (Attribute attrib in descr.Attributes)
            {
                attribs[i] = attrib;
                i++;
            }
            attribs[i] = new DescriptionAttribute(propertyView.Description);
            attribs[i + 1] = new CategoryAttribute(propertyView.Category);
            attribs[i + 2] = new DescriptionAttribute(propertyView.Description);
            attribs[i + 3] = new ReadOnlyAttribute(propertyView.IsReadOnly);

            attributes = new AttributeCollection(attribs);
        }
        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);
                });
        }
Exemplo n.º 46
0
        /// <summary>
        /// 保存模块的功能分类
        /// </summary>
        /// <param name="session"></param>
        /// <param name="category"></param>
        /// <param name="parentId"></param>
        /// <returns></returns>
        private long SaveNavigation(Session session, CategoryAttribute category, long parentId)
        {
            if (category == null || string.IsNullOrEmpty(category.Name)) return parentId;
            var nav = session.Load<Navigation>(m => m.Name.Equals(category.Name) && m.ParentId.Equals(parentId));
            if (nav != null) return nav.Id;

            nav = new Navigation { Id = GetNavIdByName(session, category.Name), Name = category.Name, Type = NavigationType.Category, ParentId = parentId, OrderId = category.Position, CreatedAt = DateTime.Now, CreatedBy = "SYSTEM" };
            if (session.Create(nav)) { return nav.Id; }

            throw new Exception(string.Format("保存导航失败:Name - {0}, ParentId - {1}", category.Name, parentId));
        }
 static DataPackPropertyCollectionEditor()
 {
     _customPropertyAttr
     = new CategoryAttribute(DataPack.CATEGORY_CUSTOMPROPERTY);
 }
Exemplo n.º 48
0
        private void AddDataGridColumnAttributes() 
        {
            AddCallback(
                typeof(DataGridColumn), 
                delegate(AttributeCallbackBuilder builder) 
                {
                    // Only add the Sort Category in VS because it causes problems in Blend               
                    CategoryAttribute sortCategory = new CategoryAttribute(SR.Get(SRID.SortCategoryTitle));
                    builder.AddCustomAttributes(DataGridColumn.CanUserSortProperty, sortCategory);
                    builder.AddCustomAttributes(DataGridColumn.SortDirectionProperty, sortCategory);
                    builder.AddCustomAttributes(DataGridColumn.SortMemberPathProperty, sortCategory);

                    builder.AddCustomAttributes(DataGridColumn.CellStyleProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGridColumn.DragIndicatorStyleProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGridColumn.HeaderStyleProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGridColumn.HeaderTemplateProperty, BrowsableAttribute.No);
                    
                    builder.AddCustomAttributes(DataGridColumn.HeaderProperty, new TypeConverterAttribute(typeof(StringConverter)));
                });
        }
Exemplo n.º 49
0
 private void AddDataGridComboBoxColumnAttributes()
 {
     AddCallback(
         typeof(DataGridComboBoxColumn), 
         delegate(AttributeCallbackBuilder builder)
         {
             // Only add the Selection Category in VS because it causes problems in Blend               
             CategoryAttribute comboBoxCategory = new CategoryAttribute(SR.Get(SRID.SelectionCategoryTitle));
             builder.AddCustomAttributes(DataGridComboBoxColumn.DisplayMemberPathProperty, comboBoxCategory);
             builder.AddCustomAttributes(DataGridComboBoxColumn.SelectedValuePathProperty, comboBoxCategory);
             
             builder.AddCustomAttributes(DataGridComboBoxColumn.EditingElementStyleProperty, BrowsableAttribute.No);
             builder.AddCustomAttributes(DataGridComboBoxColumn.ElementStyleProperty, BrowsableAttribute.No);
             builder.AddCustomAttributes(DataGridComboBoxColumn.ItemsSourceProperty, BrowsableAttribute.No);
         });
 }
Exemplo n.º 50
0
		/// <summary>
		///     Initializes a new instance of the <see cref="CategoryItem" /> class.
		/// </summary>
		/// <param name="owner">The owner.</param>
		/// <param name="category">The category.</param>
		public CategoryItem(EffectPropertyEditorGrid owner, CategoryAttribute category)
			: this(owner, category.Category)
		{
			Attribute = category;
		}
        private void AddDataGridColumnAttributes() 
        {
            AddCallback(
                typeof(DataGridColumn), 
                delegate(AttributeCallbackBuilder builder) 
                {
                    builder.AddCustomAttributes("ActualWidth", BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGridColumn.HeaderTemplateSelectorProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGridColumn.IsAutoGeneratedProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGridColumn.IsFrozenProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGridColumn.IsFrozenProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGridColumn.HeaderTemplateSelectorProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGridColumn.DisplayIndexProperty, BrowsableAttribute.No);

                    // Fix the serialization of ClipboardContentBinding when it is null
                    builder.AddCustomAttributes("ClipboardContentBinding", new DefaultValueAttribute(null));
                    builder.AddCustomAttributes("ClipboardContentBinding", BrowsableAttribute.No);

                    // builder.AddCustomAttributes(DataGridColumn.HeaderProperty, new TypeConverterAttribute(typeof(StringConverter)));
                    builder.AddCustomAttributes(DataGridColumn.CanUserResizeProperty, CategoryAttribute.Layout);
                    builder.AddCustomAttributes(DataGridColumn.MaxWidthProperty, CategoryAttribute.Layout);
                    builder.AddCustomAttributes(DataGridColumn.MaxWidthProperty, new EditorBrowsableAttribute(EditorBrowsableState.Always));
                    builder.AddCustomAttributes(DataGridColumn.MinWidthProperty, CategoryAttribute.Layout);
                    builder.AddCustomAttributes(DataGridColumn.MinWidthProperty, new EditorBrowsableAttribute(EditorBrowsableState.Always));
                    builder.AddCustomAttributes(DataGridColumn.WidthProperty, CategoryAttribute.Layout);

                    // Note In Blend for some reason I don't understand these properties end up in the "Sort" category.
                    // This looks like a bug in Blend
                    // So for Blend leave the sort properties in "Misc" and then these in Header - Sort category moved to 
                    // VS metadata
                    CategoryAttribute headerCategory = new CategoryAttribute(SR.Get(SRID.HeaderCategoryTitle));
                    builder.AddCustomAttributes(DataGridColumn.HeaderProperty, headerCategory);
                    builder.AddCustomAttributes(DataGridColumn.HeaderStringFormatProperty, headerCategory);
                    builder.AddCustomAttributes(DataGridColumn.HeaderStyleProperty, headerCategory);
                    builder.AddCustomAttributes(DataGridColumn.HeaderTemplateProperty, headerCategory);

                    builder.AddCustomAttributes(DataGridColumn.VisibilityProperty, CategoryAttribute.Appearance);
                });
        }
 private void AddDataGridTextColumnAttributes()
 {
     AddCallback(
         typeof(DataGridTextColumn), 
         delegate(AttributeCallbackBuilder builder)
         {
             CategoryAttribute textCategory = new CategoryAttribute(SR.Get(SRID.TextCategoryTitle));
             builder.AddCustomAttributes(DataGridTextColumn.FontStyleProperty, textCategory);
             builder.AddCustomAttributes(DataGridTextColumn.FontFamilyProperty, textCategory);
             builder.AddCustomAttributes(DataGridTextColumn.FontSizeProperty, textCategory);
             builder.AddCustomAttributes(DataGridTextColumn.FontWeightProperty, textCategory);
             builder.AddCustomAttributes(DataGridTextColumn.ForegroundProperty, textCategory);
         });
 }
        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 AxHost()
 {
     CategoryAttribute[] attributeArray = new CategoryAttribute[12];
     attributeArray[1] = new WinCategoryAttribute("Default");
     attributeArray[2] = new WinCategoryAttribute("Default");
     attributeArray[3] = new WinCategoryAttribute("Font");
     attributeArray[4] = new WinCategoryAttribute("Layout");
     attributeArray[5] = new WinCategoryAttribute("Appearance");
     attributeArray[6] = new WinCategoryAttribute("Behavior");
     attributeArray[7] = new WinCategoryAttribute("Data");
     attributeArray[8] = new WinCategoryAttribute("List");
     attributeArray[9] = new WinCategoryAttribute("Text");
     attributeArray[10] = new WinCategoryAttribute("Scale");
     attributeArray[11] = new WinCategoryAttribute("DDE");
     categoryNames = attributeArray;
 }
 private CategoryAttribute GetCategoryForDispid(int dispid)
 {
     System.Windows.Forms.NativeMethods.ICategorizeProperties categorizeProperties = this.GetCategorizeProperties();
     if (categorizeProperties != null)
     {
         CategoryAttribute attribute = null;
         int categoryID = 0;
         try
         {
             categorizeProperties.MapPropertyToCategory(dispid, ref categoryID);
             if (categoryID != 0)
             {
                 int index = -categoryID;
                 if (((index > 0) && (index < categoryNames.Length)) && (categoryNames[index] != null))
                 {
                     return categoryNames[index];
                 }
                 index = -index;
                 int key = index;
                 if (this.objectDefinedCategoryNames != null)
                 {
                     attribute = (CategoryAttribute) this.objectDefinedCategoryNames[key];
                     if (attribute != null)
                     {
                         return attribute;
                     }
                 }
                 string categoryName = null;
                 if ((categorizeProperties.GetCategoryName(index, CultureInfo.CurrentCulture.LCID, out categoryName) == 0) && (categoryName != null))
                 {
                     attribute = new CategoryAttribute(categoryName);
                     if (this.objectDefinedCategoryNames == null)
                     {
                         this.objectDefinedCategoryNames = new Hashtable();
                     }
                     this.objectDefinedCategoryNames.Add(key, attribute);
                     return attribute;
                 }
             }
         }
         catch (Exception)
         {
         }
     }
     return null;
 }
 public void SetCategory( string category )
 {
     var attr = (CategoryAttribute)attributes.FirstOrDefault(a => a is CategoryAttribute);
     if (attr != null)
     {
         attributes.RemoveAll(a => a is CategoryAttribute);
     }
     attr = new CategoryAttribute(category);
     attributes.Add(attr);
 }
        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);
        }
Exemplo n.º 58
0
 private CategoryAttribute GetCategoryForDispid(int dispid) {
     NativeMethods.ICategorizeProperties icp = GetCategorizeProperties();
     if (icp == null) return null;
     CategoryAttribute rval = null;
     int propcat = 0;
     try {
         icp.MapPropertyToCategory(dispid, ref propcat);
         if (propcat != 0) {
             int cat = -propcat;
             if (cat > 0 && cat < categoryNames.Length && categoryNames[cat] != null) {
                 return categoryNames[cat];
             }
             cat = - cat;
             Int32 key = cat;
             if (objectDefinedCategoryNames != null) {
                 rval = (CategoryAttribute) objectDefinedCategoryNames[key];
                 if (rval != null) return rval;
             }
             
             string name = null;
             int hr = icp.GetCategoryName(cat, CultureInfo.CurrentCulture.LCID, out name);
             if (hr == NativeMethods.S_OK && name != null) {
                 rval = new CategoryAttribute(name);
                 if (objectDefinedCategoryNames == null) {
                     objectDefinedCategoryNames = new Hashtable();
                 }
                 objectDefinedCategoryNames.Add(key, rval);
                 return rval;
             }
         }
     }
     catch (Exception t) {
         Debug.Fail(t.ToString());
     }
     return null;
 }
Exemplo n.º 59
0
 public WorkaroundCategoryAttribute(CategoryAttribute baseCategoryAttribute, string category)
     : base(category) 
 {
     _baseCategoryAttribute = baseCategoryAttribute;
 }
        private void AddDataGridAttributes() 
        {
            AddCallback(
                typeof(DataGrid), 
                delegate(AttributeCallbackBuilder builder) 
                {
                    // Set the default property. The default event is inherited - SelectionChanged
                    builder.AddCustomAttributes(new DefaultPropertyAttribute("Columns"));

                    // In Blend these properties need to be browsable to be accessible from the CategoryEditor
                    builder.AddCustomAttributes(DataGrid.AutoGenerateColumnsProperty, BrowsableAttribute.Yes);
                    builder.AddCustomAttributes(DataGrid.ItemsSourceProperty, BrowsableAttribute.Yes);

                    builder.AddCustomAttributes(DataGrid.CurrentCellProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGrid.CurrentColumnProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGrid.CurrentItemProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGrid.RowStyleSelectorProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes("SelectedItems", BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGrid.RowDetailsTemplateSelectorProperty, BrowsableAttribute.No);
                    builder.AddCustomAttributes(DataGrid.RowHeaderTemplateSelectorProperty, BrowsableAttribute.No);

                    // Add Column types that can be added
                    NewItemTypesAttribute attr = new NewItemTypesAttribute(
                                                        typeof(DataGridTextColumn),
                                                        typeof(DataGridCheckBoxColumn),
                                                        typeof(DataGridHyperlinkColumn),
                                                        typeof(DataGridComboBoxColumn),
                                                        typeof(DataGridTemplateColumn));
                    attr.FactoryType = typeof(DataGridColumnFactory);
                    builder.AddCustomAttributes("Columns", attr);

                    // Enable addition of RowValidationRules
                    builder.AddCustomAttributes("RowValidationRules", new NewItemTypesAttribute(typeof(ExceptionValidationRule), typeof(DataErrorValidationRule)));

                    CategoryAttribute columnsCategory = new CategoryAttribute(SR.Get(SRID.ColumnsCategoryTitle));
                    builder.AddCustomAttributes(DataGrid.AutoGenerateColumnsProperty, columnsCategory);
                    builder.AddCustomAttributes(DataGrid.CanUserReorderColumnsProperty, columnsCategory);
                    builder.AddCustomAttributes(DataGrid.CanUserResizeColumnsProperty, columnsCategory);
                    builder.AddCustomAttributes(DataGrid.CanUserSortColumnsProperty, columnsCategory);
                    builder.AddCustomAttributes(DataGrid.CellStyleProperty, columnsCategory);
                    builder.AddCustomAttributes("Columns", columnsCategory);
                    builder.AddCustomAttributes(DataGrid.ColumnWidthProperty, columnsCategory);
                    builder.AddCustomAttributes(DataGrid.FrozenColumnCountProperty, columnsCategory);
                    builder.AddCustomAttributes(DataGrid.MaxColumnWidthProperty, columnsCategory);
                    builder.AddCustomAttributes(DataGrid.MinColumnWidthProperty, columnsCategory);

                    CategoryAttribute rowsCategory = new CategoryAttribute(SR.Get(SRID.RowsCategoryTitle));
                    builder.AddCustomAttributes(DataGrid.ItemsSourceProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.AlternationCountProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.AlternatingRowBackgroundProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.AreRowDetailsFrozenProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.CanUserAddRowsProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.CanUserDeleteRowsProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.CanUserResizeRowsProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.MinRowHeightProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.RowBackgroundProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.RowDetailsTemplateProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.RowDetailsVisibilityModeProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.RowHeightProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.RowStyleProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.RowValidationErrorTemplateProperty, rowsCategory);
                    builder.AddCustomAttributes("RowValidationRules", rowsCategory);
                    builder.AddCustomAttributes(DataGrid.SelectionModeProperty, rowsCategory);
                    builder.AddCustomAttributes(DataGrid.SelectionUnitProperty, rowsCategory);

                    CategoryAttribute headersCategory = new CategoryAttribute(SR.Get(SRID.HeadersCategoryTitle));
                    builder.AddCustomAttributes(DataGrid.ColumnHeaderHeightProperty, headersCategory);
                    builder.AddCustomAttributes(DataGrid.ColumnHeaderStyleProperty, headersCategory);
                    builder.AddCustomAttributes(DataGrid.HeadersVisibilityProperty, headersCategory);
                    builder.AddCustomAttributes(DataGrid.RowHeaderTemplateProperty, headersCategory);
                    builder.AddCustomAttributes(DataGrid.RowHeaderStyleProperty, headersCategory);
                    builder.AddCustomAttributes(DataGrid.RowHeaderWidthProperty, headersCategory);

                    CategoryAttribute gridLinesCategory = new CategoryAttribute(SR.Get(SRID.GridLinesCategoryTitle));
                    builder.AddCustomAttributes(DataGrid.GridLinesVisibilityProperty, gridLinesCategory);
                    builder.AddCustomAttributes(DataGrid.HorizontalGridLinesBrushProperty, gridLinesCategory);
                    builder.AddCustomAttributes(DataGrid.VerticalGridLinesBrushProperty, gridLinesCategory);
                });
        }