当前位置: 首页>>代码示例>>C#>>正文


C# ITypeDescriptorContext类代码示例

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


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


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