當前位置: 首頁>>代碼示例>>C#>>正文


C# PropertyDescriptorCollection.Sort方法代碼示例

本文整理匯總了C#中System.ComponentModel.PropertyDescriptorCollection.Sort方法的典型用法代碼示例。如果您正苦於以下問題:C# PropertyDescriptorCollection.Sort方法的具體用法?C# PropertyDescriptorCollection.Sort怎麽用?C# PropertyDescriptorCollection.Sort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ComponentModel.PropertyDescriptorCollection的用法示例。


在下文中一共展示了PropertyDescriptorCollection.Sort方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetProperties

 public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
 {
     PropertyDescriptorCollection descriptors = new PropertyDescriptorCollection(null);
     descriptors.Add(new RuleConditionReferenceNamePropertyDescriptor(context, TypeDescriptor.CreateProperty(typeof(RuleConditionReference), "ConditionName", typeof(string), new Attribute[] { new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content), DesignOnlyAttribute.Yes })));
     descriptors.Add(new RuleConditionReferencePropertyDescriptor(context, TypeDescriptor.CreateProperty(typeof(RuleConditionReference), "Expression", typeof(CodeExpression), new Attribute[] { new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content), DesignOnlyAttribute.Yes })));
     return descriptors.Sort(new string[] { "ConditionName", "Expression" });
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:7,代碼來源:RuleConditionReferenceTypeConverter.cs

示例2: Vector2Converter

 public Vector2Converter()
 {
     Type typeFromHandle = typeof(Vector2);
     PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(new PropertyDescriptor[]
     {
         new FieldPropertyDescriptor(typeFromHandle.GetField("X")),
         new FieldPropertyDescriptor(typeFromHandle.GetField("Y"))
     });
     this.propertyDescriptions = propertyDescriptorCollection.Sort(new string[]
     {
         "X",
         "Y"
     });
 }
開發者ID:absturztaube,項目名稱:EngineTK,代碼行數:14,代碼來源:Vector2Converter.cs

示例3: RectangleFConverter

 public RectangleFConverter()
 {
     Type typeFromHandle = typeof(RectangleF);
     PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(new PropertyDescriptor[]
     {
         new PropertyPropertyDescriptor(typeFromHandle.GetProperty("X")),
         new PropertyPropertyDescriptor(typeFromHandle.GetProperty("Y")),
         new PropertyPropertyDescriptor(typeFromHandle.GetProperty("Width")),
         new PropertyPropertyDescriptor(typeFromHandle.GetProperty("Height"))
     });
     this.propertyDescriptions = propertyDescriptorCollection.Sort(new string[]
     {
         "X",
         "Y",
         "Width",
         "Height"
     });
 }
開發者ID:absturztaube,項目名稱:EngineTK,代碼行數:18,代碼來源:RectangleFConverter.cs

示例4: ColorConverter

 public ColorConverter()
 {
     Type typeFromHandle = typeof(Color);
     PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(new PropertyDescriptor[]
     {
         new PropertyPropertyDescriptor(typeFromHandle.GetProperty("R")),
         new PropertyPropertyDescriptor(typeFromHandle.GetProperty("G")),
         new PropertyPropertyDescriptor(typeFromHandle.GetProperty("B")),
         new PropertyPropertyDescriptor(typeFromHandle.GetProperty("A"))
     });
     this.propertyDescriptions = propertyDescriptorCollection.Sort(new string[]
     {
         "R",
         "G",
         "B",
         "A"
     });
 }
開發者ID:absturztaube,項目名稱:EngineTK,代碼行數:18,代碼來源:ColorConverter.cs

示例5: SortProperties

		protected PropertyDescriptorCollection SortProperties (PropertyDescriptorCollection props, string[] names)
		{
			props.Sort (names);
			return props; 
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:5,代碼來源:TypeConverter.cs

示例6: GetChildProperties

        public override PropertyDescriptorCollection GetChildProperties( object instance, Attribute[] filter )
        {
            PropertyDescriptorCollection pdc = null;
            var tc = this.Converter;
            if (tc.GetPropertiesSupported(null) == false)
            {
                pdc = base.GetChildProperties(instance, filter);
            }
            else
            {

            }
            if (propertyDescriptor != null)
            {
                tc = propertyDescriptor.Converter;
            }
            else
            {
                //pdc = base.GetChildProperties(instance, filter);// this gives us a readonly collection, no good
                tc = TypeDescriptor.GetConverter(instance, true);
            }
            if (pdc == null || pdc.Count == 0)
            {
                return pdc;
            }
            if (pdc[0] is CustomPropertyDescriptor)
            {
                return pdc;
            }
            // now wrap these properties with our CustomPropertyDescriptor
            var pdl = new PropertyDescriptorList( );

            foreach (PropertyDescriptor pd in pdc)
            {
                if (pd is CustomPropertyDescriptor)
                {
                    pdl.Add(pd as CustomPropertyDescriptor);
                }
                else
                {
                    pdl.Add(new CustomPropertyDescriptor(instance, pd));
                }
            }

            pdl.Sort(new PropertySorter( ));
            var pdcReturn = new PropertyDescriptorCollection(pdl.ToArray( ));
            pdcReturn.Sort( );
            return pdcReturn;
        }
開發者ID:ssuing8825,項目名稱:ServiceBusExplorer,代碼行數:49,代碼來源:CustomPropertyDescriptor.cs

示例7: Sort

		[Test] // Sort (String [], IComparer)
		public void Sort4 ()
		{
			PropertyDescriptorCollection descriptors;
			PropertyDescriptorCollection sorted;

			PropertyDescriptor descA = new MockPropertyDescriptor ("Foo", 2);
			PropertyDescriptor descB = new MockPropertyDescriptor ("Aim", 3);
			PropertyDescriptor descC = new MockPropertyDescriptor ("Bim", 1);
			PropertyDescriptor descD = new MockPropertyDescriptor ("AIm", 5);
			PropertyDescriptor descE = new MockPropertyDescriptor ("Boo", 4);
			PropertyDescriptor descF = new MockPropertyDescriptor ("FOo", 6);

			PropertyDescriptor [] props = new PropertyDescriptor [] {
				descA, descB, descC, descD, descE, descF };
			descriptors = new PropertyDescriptorCollection (props);

			Assert.AreSame (descA, descriptors [0], "#A1");
			Assert.AreSame (descB, descriptors [1], "#A2");
			Assert.AreSame (descC, descriptors [2], "#A3");
			Assert.AreSame (descD, descriptors [3], "#A4");
			Assert.AreSame (descE, descriptors [4], "#A5");
			Assert.AreSame (descF, descriptors [5], "#A6");

			sorted = descriptors.Sort (new string [] { "B", "Foo", null, "A", "Boo" },
				new ComparableComparer ());

			Assert.AreSame (descA, descriptors [0], "#B1");
			Assert.AreSame (descB, descriptors [1], "#B2");
			Assert.AreSame (descC, descriptors [2], "#B3");
			Assert.AreSame (descD, descriptors [3], "#B4");
			Assert.AreSame (descE, descriptors [4], "#B5");
			Assert.AreSame (descF, descriptors [5], "#B6");

			Assert.AreSame (descA, sorted [0], "#C1");
			Assert.AreSame (descE, sorted [1], "#C2");
			Assert.AreSame (descC, sorted [2], "#C3");
			Assert.AreSame (descB, sorted [3], "#C4");
			Assert.AreSame (descD, sorted [4], "#C5");
			Assert.AreSame (descF, sorted [5], "#C6");

			sorted = descriptors.Sort ((string []) null, new ComparableComparer ());

			Assert.AreSame (descA, descriptors [0], "#D1");
			Assert.AreSame (descB, descriptors [1], "#D2");
			Assert.AreSame (descC, descriptors [2], "#D3");
			Assert.AreSame (descD, descriptors [3], "#D4");
			Assert.AreSame (descE, descriptors [4], "#D5");
			Assert.AreSame (descF, descriptors [5], "#D6");

			Assert.AreSame (descC, sorted [0], "#E1");
			Assert.AreSame (descA, sorted [1], "#E2");
			Assert.AreSame (descB, sorted [2], "#E3");
			Assert.AreSame (descE, sorted [3], "#E4");
			Assert.AreSame (descD, sorted [4], "#E5");
			Assert.AreSame (descF, sorted [5], "#E6");

			sorted = descriptors.Sort (new string [] { "B", "Foo", null, "A", "Boo" },
				(Comparer) null);

			Assert.AreSame (descA, descriptors [0], "#F1");
			Assert.AreSame (descB, descriptors [1], "#F2");
			Assert.AreSame (descC, descriptors [2], "#F3");
			Assert.AreSame (descD, descriptors [3], "#F4");
			Assert.AreSame (descE, descriptors [4], "#F5");
			Assert.AreSame (descF, descriptors [5], "#F6");

			Assert.AreSame (descA, sorted [0], "#G1");
			Assert.AreSame (descE, sorted [1], "#G2");
			Assert.AreSame (descB, sorted [2], "#G3");
			Assert.AreSame (descD, sorted [3], "#G4");
			Assert.AreSame (descC, sorted [4], "#G5");
			Assert.AreSame (descF, sorted [5], "#G6");

			sorted = descriptors.Sort ((string []) null, (Comparer) null);

			Assert.AreSame (descA, descriptors [0], "#H1");
			Assert.AreSame (descB, descriptors [1], "#H2");
			Assert.AreSame (descC, descriptors [2], "#H3");
			Assert.AreSame (descD, descriptors [3], "#H4");
			Assert.AreSame (descE, descriptors [4], "#H5");
			Assert.AreSame (descF, descriptors [5], "#H6");

			Assert.AreSame (descB, sorted [0], "#I1");
			Assert.AreSame (descD, sorted [1], "#I2");
			Assert.AreSame (descC, sorted [2], "#I3");
			Assert.AreSame (descE, sorted [3], "#I4");
			Assert.AreSame (descA, sorted [4], "#I5");
			Assert.AreSame (descF, sorted [5], "#I6");
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:90,代碼來源:PropertyDescriptorCollectionTests.cs

示例8: GetProperties

		/// <summary>Retrieves the set of properties for this type. By default, a type does not return any properties. </summary>
		/// <returns>The set of properties that should be exposed for this data type. If no properties should be exposed, this may return null. The default implementation always returns null.</returns>
		/// <param name="context">A <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> through which additional context can be provided. </param>
		/// <param name="value">The value of the object to get the properties for. </param>
		/// <param name="attributes">An array of <see cref="T:System.Attribute" /> objects that describe the properties. </param>
		/// <filterpriority>1</filterpriority>
		public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
		{
            Type typeFromHandle = typeof(FloatRectangle);
            PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(new PropertyDescriptor[]
			{
				new FieldPropertyDescriptor(typeFromHandle.GetField("X")),
				new FieldPropertyDescriptor(typeFromHandle.GetField("Y")),
				new FieldPropertyDescriptor(typeFromHandle.GetField("Width")),
				new FieldPropertyDescriptor(typeFromHandle.GetField("Height"))
			});

            propertyDescriptorCollection = propertyDescriptorCollection.Sort(new string[]
			{
				"X",
				"Y",
				"Width",
				"Height",

			});

            return propertyDescriptorCollection;


		}
開發者ID:vchelaru,項目名稱:FlatRedBall,代碼行數:30,代碼來源:FloatRectangleTypeConverter.cs

示例9: GetEditableProperties

        private PropertyDescriptorCollection GetEditableProperties(object editableObject)
        {
            if (editableObject == null)
                throw new ArgumentNullException("editableObject");

            var webBrowsableFilter = new Attribute[] {WebBrowsableAttribute.Yes};
            var properties = TypeDescriptor.GetProperties(editableObject, webBrowsableFilter);
            var editableProperties = new PropertyDescriptorCollection(null);
            foreach (PropertyDescriptor descriptor in properties)
            {
                if (CanEditProperty(descriptor))
                    editableProperties.Add(descriptor);
            }
            return editableProperties.Sort(new WebCategoryComparer());
        }
開發者ID:maxpavlov,項目名稱:FlexNet,代碼行數:15,代碼來源:PropertyEditorPart.cs


注:本文中的System.ComponentModel.PropertyDescriptorCollection.Sort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。