• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ITypeDescriptorContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ITypeDescriptorContext的典型用法代码示例。如果您正苦于以下问题:C# ITypeDescriptorContext类的具体用法?C# ITypeDescriptorContext怎么用?C# ITypeDescriptorContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ITypeDescriptorContext类属于命名空间,在下文中一共展示了ITypeDescriptorContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ConvertFrom

		public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
			if (value is string) {
				var vs = ((string)value).Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
				return vs.Select(v => v.Trim('"')).ToList();
			}
			return base.ConvertFrom(context, culture, value);
		}
开发者ID:dkeetonx,项目名称:ccmaps-net,代码行数:7,代码来源:CsvConverter.cs


示例2: ConvertTo

		public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
		{
			if (context == null)
				return null;
			var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;
			return p != null ? p.GetName (value) : null;
		}
开发者ID:nagyist,项目名称:XamlForIphone,代码行数:7,代码来源:NameReferenceConverter.cs


示例3: ConvertTo

            public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
                if (destinationType == typeof(string)) {
                    return "EmbeddedMailObject";
                }

                return base.ConvertTo(context, culture, value, destinationType);
            }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:7,代码来源:EmbeddedMailObject.cs


示例4: EditValue

        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            if (context != null && provider != null)
            {
                edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                if (edSvc != null)
                {
                    lb = new ListBox();
                    lb.Items.AddRange(new object[] {
                        "Sunday",
                        "Monday",
                        "Tuesday",
                        "Wednesday",
                        "Thursday",
                        "Friday",
                        "Saturday"});
                    lb.SelectedIndexChanged += new System.EventHandler(lb_SelectedIndexChanged);
                    edSvc.DropDownControl(lb);
                }
                return text;

            }

            return base.EditValue(context, provider, value);
        }
开发者ID:harpreetoxyent,项目名称:pnl,代码行数:25,代码来源:EIBSchedular.cs


示例5: CanConvertTo

		public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
		{
			if (context == null)
				return false;
			var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;
			return p != null && destinationType == typeof (string);
		}
开发者ID:nagyist,项目名称:XamlForIphone,代码行数:7,代码来源:NameReferenceConverter.cs


示例6: ConvertTo

		// Overrides the ConvertTo method of TypeConverter.
		public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
			var v = value as IEnumerable<String>;
			if (destinationType == typeof(string)) {
				return string.Join(", ", v.Select(AddQuotes).ToArray());
			}
			return base.ConvertTo(context, culture, value, destinationType);
		}
开发者ID:dkeetonx,项目名称:ccmaps-net,代码行数:8,代码来源:CsvConverter.cs


示例7: EditValue

        /// <summary>
        /// <para>Edits the specified object's value using the editor style indicated by <see cref="GetEditStyle"/>. This should be a <see cref="DpapiSettings"/> object.</para>
        /// </summary>
        /// <param name="context"><para>An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</para></param>
        /// <param name="provider"><para>An <see cref="IServiceProvider"/> that this editor can use to obtain services.</para></param>
        /// <param name="value"><para>The object to edit. This should be a <see cref="Password"/> object.</para></param>
        /// <returns><para>The new value of the <see cref="Password"/> object.</para></returns>
        /// <seealso cref="UITypeEditor.EditValue(ITypeDescriptorContext, IServiceProvider, object)"/>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            Debug.Assert(provider != null, "No service provider; we cannot edit the value");
            if (provider != null)
            {
                IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

                Debug.Assert(edSvc != null, "No editor service; we cannot edit the value");
                if (edSvc != null)
                {
                    IWindowsFormsEditorService service =(IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                    using (PasswordEditorUI dialog = new PasswordEditorUI())
                    {
                        if (DialogResult.OK == service.ShowDialog(dialog))
                        {
                            return new Password(dialog.Password);
                        }
                        else
                        {
                            return value;
                        }
                    }
                }
            }
            return value;
        }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:34,代码来源:PasswordEditor.cs


示例8: ConvertTo

		/// <summary>
		/// Converts a <see cref="Color"/> instance to the specified <paramref name="destinationType"/>
		/// </summary>
		/// <param name="context">Context of the conversion</param>
		/// <param name="culture">Culture to use for the conversion</param>
		/// <param name="value"><see cref="Color"/> value to convert</param>
		/// <param name="destinationType">Type to convert the <paramref name="value"/> to</param>
		/// <returns>An object of type <paramref name="destinationType"/> converted from <paramref name="value"/></returns>
		public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
		{
			if (destinationType == typeof (string)) {
				return ((Color)value).ToHex ();
			}
			return base.ConvertTo (context, culture, value, destinationType);
		}
开发者ID:JohnACarruthers,项目名称:Eto,代码行数:15,代码来源:ColorConverter.cs


示例9: CanConvertTo

        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            if (destinationType == typeof(char) || destinationType == typeof(string))
                return true;

            return false;
        }
开发者ID:borisblizzard,项目名称:arcreator,代码行数:7,代码来源:WhitespaceStringConverter.cs


示例10: CanConvertTo

        ///<summary>Standard type converter method</summary>
        public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) {
            if (destinationType == typeof(AtomSource) || destinationType == typeof(AtomFeed)) {
                return true;
            }

            return base.CanConvertTo(context, destinationType);
        }
开发者ID:saeedesmaeili,项目名称:google-gdata,代码行数:8,代码来源:atomsource.cs


示例11: EditValue

 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     IDesignerHost service = (IDesignerHost)context.GetService(typeof(IDesignerHost));
     DeluxeTree component = (DeluxeTree)context.Instance;
     ((DeluxeTreeItemsDesigner)service.GetDesigner(component)).InvokeMenuItemCollectionEditor();
     return value;
 }
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:7,代码来源:DeluxeTreeCollectionItemsEditor.cs


示例12: ConvertFrom

        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
            if (value is string) {
                return new TypeAndName((string) value);
            }

            return base.ConvertFrom(context, culture, value);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:TypeElement.cs


示例13: ConvertFrom

        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var valueString = value as string;
            if (valueString != null)
            {
                var values = valueString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                var l = new List<Brush>();

                foreach (var s in values.Select(x => x.Trim()))
                {
                    if (Regex.IsMatch(s, @"^#[0-9a-fA-F]+"))
                    {
                        l.Add(
                            new SolidColorBrush((Color) (ColorConverter.ConvertFromString(s) ??
                                                         Colors.Transparent)));
                        continue;
                    }
                    l.Add(new ImageBrush(new BitmapImage(new Uri(s, UriKind.Relative))));
                }

                return l.ToArray();
            }
            return base.ConvertFrom(context, culture, value);
        }
开发者ID:mpostol,项目名称:Live-Charts,代码行数:25,代码来源:BrushesCollectionConverter.cs


示例14: GetProperties

        /// <summary>
        /// Returns the property descriptors for this instance.
        /// </summary>
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            Guard.NotNull(() => context, context);

            var descriptors = base.GetProperties(context, value, attributes).Cast<PropertyDescriptor>();

            // Remove descriptors for the data type of this property (string)
            descriptors = descriptors.Where(descriptor => descriptor.ComponentType != typeof(string));

            // Get the model element being described
            var selection = context.Instance;
            ModelElement mel = selection as ModelElement;
            var pel = selection as PresentationElement;
            if (pel != null)
            {
                mel = pel.Subject;
            }

            var element = ExtensionElement.GetExtension<ArtifactExtension>(mel);
            if (element != null)
            {
                // Copy descriptors from owner (make Browsable)
                var descriptor1 = new DelegatingPropertyDescriptor(element, TypedDescriptor.CreateProperty(element, extension => extension.OnArtifactActivation),
                    new BrowsableAttribute(true), new DefaultValueAttribute(element.GetPropertyDefaultValue<ArtifactExtension, ArtifactActivatedAction>(e => e.OnArtifactActivation)));
                var descriptor2 = new DelegatingPropertyDescriptor(element, TypedDescriptor.CreateProperty(element, extension => extension.OnArtifactDeletion),
                    new BrowsableAttribute(true), new DefaultValueAttribute(element.GetPropertyDefaultValue<ArtifactExtension, ArtifactDeletedAction>(e => e.OnArtifactDeletion)));
                descriptors = descriptors.Concat(new[] { descriptor1, descriptor2 });
            }

            return new PropertyDescriptorCollection(descriptors.ToArray());
        }
开发者ID:NuPattern,项目名称:NuPattern,代码行数:34,代码来源:AssociatedArtifactsTypeConverter.cs


示例15: GetStandardValues

 public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
   if (charSets == null)
     PopulateList(context.Instance);
   StandardValuesCollection coll = new StandardValuesCollection(charSets);
   return coll;
 }
开发者ID:jimmy00784,项目名称:mysql-connector-net,代码行数:7,代码来源:CharacterSetTypeConverter.cs


示例16: ConvertFrom

        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            // If the type is a string or a double, it's ok to proceed with conversion.
            if (value is string || value is double || value is int || value is float)
            {
                // Try to resolve the target property type
                Type DestinationType = null;

                if (context != null)
                {
                    DestinationType = context.PropertyDescriptor.PropertyType;
                }
                else
                {
                    DestinationType = Type.GetType(HandledTypeName);
                    if (DestinationType == null && Environment.OSVersion.Platform == PlatformID.Win32NT)
                    {
#if PocketPC
                        DestinationType = Type.GetType(HandledTypeName + ", GeoFramework.PocketPC, Version=" + HandledAssemblyVersion.ToString(4) + ", Culture=neutral, PublicKeyToken=3ed3cdf4fdda3400");
#else
                        DestinationType = Type.GetType(HandledTypeName + ", GeoFramework, Version=" + HandledAssemblyVersion.ToString(4) + ", Culture=neutral, PublicKeyToken=3ed3cdf4fdda3400");
#endif
                    }
                }

                // If a destination type was found, go ahead and create a new instance!
                if (DestinationType != null)
                {
                    return Activator.CreateInstance(DestinationType, new object[] { value });
                }
            }

            // Defer to the base class
            return base.ConvertFrom(context, culture, value);
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:35,代码来源:GeoFrameworkNumericObjectConverter.cs


示例17: CreateInstance

        /// <summary>Creates an instance of the type that this BoundingBoxConverter is associated with, using the specified context, given a set of property values for the object.</summary>
        /// <param name="context">The format context.</param>
        /// <param name="propertyValues">The new property values.</param>
        public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues)
        {
            if (propertyValues == null)
                throw new ArgumentNullException("propertyValues", FrameworkMessages.NullNotAllowed);

            return new BoundingBox((Vector3)propertyValues["Min"], (Vector3)propertyValues["Max"]);
        }
开发者ID:wtfcolt,项目名称:game,代码行数:10,代码来源:BoundingBoxConverter.cs


示例18: ConvertFrom

 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (!(value is string))
     {
         return base.ConvertFrom(context, culture, value);
     }
     string s = ((string) value).Replace('%', ' ').Trim();
     double num = double.Parse(s, CultureInfo.CurrentCulture);
     if (((((string) value).IndexOf("%") > 0) && (num >= 0.0)) && (num <= 1.0))
     {
         s = (num / 100.0).ToString(CultureInfo.CurrentCulture);
     }
     double num3 = 1.0;
     try
     {
         num3 = (double) TypeDescriptor.GetConverter(typeof(double)).ConvertFrom(context, culture, s);
         if (num3 > 1.0)
         {
             num3 /= 100.0;
         }
     }
     catch (FormatException exception)
     {
         throw new FormatException(System.Windows.Forms.SR.GetString("InvalidBoundArgument", new object[] { "Opacity", s, "0%", "100%" }), exception);
     }
     if ((num3 < 0.0) || (num3 > 1.0))
     {
         throw new FormatException(System.Windows.Forms.SR.GetString("InvalidBoundArgument", new object[] { "Opacity", s, "0%", "100%" }));
     }
     return num3;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:OpacityConverter.cs


示例19: ConvertFrom

    public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
    {
      string data;
      ZoomLevelCollection result;

      data = value as string;
      if (!string.IsNullOrEmpty(data))
      {
        char separator;
        string[] items;
        TypeConverter converter;

        if (culture == null)
          culture = CultureInfo.CurrentCulture;

        result = new ZoomLevelCollection();
        separator = culture.TextInfo.ListSeparator[0];
        items = data.Split(separator);
        converter = TypeDescriptor.GetConverter(typeof(int));

        foreach (string item in items)
          result.Add((int)converter.ConvertFromString(context, culture, item));
      }
      else
        result = null;

      return result;
    }
开发者ID:FrankGITDeveloper,项目名称:Landsknecht_GreenScreen,代码行数:28,代码来源:ZoomLevelCollectionConverter.cs


示例20: ConvertFrom

 /// <summary>
 /// Converts the given object to the type of this converter, using the specified context and culture information.
 /// </summary>
 /// <param name="context">An System.ComponentModel.ITypeDescriptorContext that provides a format context.</param>
 /// <param name="culture">The System.Globalization.CultureInfo to use as the current culture.</param>
 /// <param name="value">The System.Object to convert.</param>
 /// <returns>An System.Object that represents the converted value.</returns>
 public override object ConvertFrom(ITypeDescriptorContext context, Globalization.CultureInfo culture, object value)
 {
     Type type = ((EntityValueConverterContext)context).Property.Property.PropertyType;
     if (value is int)
         return Enum.ToObject(type, (int)value);
     return Enum.Parse(type, (string)value);
 }
开发者ID:liny4cn,项目名称:ComBoost,代码行数:14,代码来源:EnumConverter.cs



注:本文中的ITypeDescriptorContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ITypeElement类代码示例发布时间:2022-05-24
下一篇:
C# ITypeDescriptor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap