system.componentmodel

Is it possible to add custom properties to c# enum object?

陌路散爱 提交于 2020-08-20 05:42:46
问题 Using c# Is it possible using to associate properties for each enum items? I have used the Description Attribute to add English description to an enum item. To add English description to each item I have done the following public enum MyEnum { [Description("My First Item")] First, [Description("My Second Item")] Second, [Description("My Third Item")] Third } Then I added an extension method to my enum called GetDescription() which allows me to get the description like so public static string

Is it possible to add custom properties to c# enum object?

馋奶兔 提交于 2020-08-20 05:41:43
问题 Using c# Is it possible using to associate properties for each enum items? I have used the Description Attribute to add English description to an enum item. To add English description to each item I have done the following public enum MyEnum { [Description("My First Item")] First, [Description("My Second Item")] Second, [Description("My Third Item")] Third } Then I added an extension method to my enum called GetDescription() which allows me to get the description like so public static string

When and why we should to use class System.ComponentModel.Container?

喜夏-厌秋 提交于 2020-01-01 04:20:25
问题 Is anybody could explain when and why we should use System.ComponentModel.Container , please? Recently I have met using of this class here, but really cannot understand what a benefit can get us this class there. 回答1: In general, System.ComponentModel namespace exists for supporting component development - components can be visual (controls) and non-visuals. IMO, one should develop Components (in this context IComponent implementations) when design time support is needed. For example, you can

.NET: How do I invoke a delegate on a specific thread? (ISynchronizeInvoke, Dispatcher, AsyncOperation, SynchronizationContext, etc.)

蹲街弑〆低调 提交于 2019-12-31 10:02:05
问题 Note first of all that this question is not tagged winforms or wpf or anything else GUI-specific. This is intentional, as you will see shortly. Second, sorry if this question is somewhat long. I try to pull together various bits of information floating around here and there so as to also provide valuable information. My question, however, is right under "What I would like to know". I'm on a mission to finally understand the various ways offered by .NET to invoke a delegate on a specific

.NET: How do I invoke a delegate on a specific thread? (ISynchronizeInvoke, Dispatcher, AsyncOperation, SynchronizationContext, etc.)

落花浮王杯 提交于 2019-12-31 10:01:11
问题 Note first of all that this question is not tagged winforms or wpf or anything else GUI-specific. This is intentional, as you will see shortly. Second, sorry if this question is somewhat long. I try to pull together various bits of information floating around here and there so as to also provide valuable information. My question, however, is right under "What I would like to know". I'm on a mission to finally understand the various ways offered by .NET to invoke a delegate on a specific

Linq expressions and extension methods to get property name

坚强是说给别人听的谎言 提交于 2019-12-28 16:21:20
问题 I was looking at this post that describes a simple way to do databinding between POCO properties: Data Binding POCO Properties One of the comments by Bevan included a simple Binder class that can be used to accomplish such data binding. It works great for what I need but I would like to implement some of the suggestions that Bevan made to improve the class, namely: Checking that source and target are assigned Checking that the properties identified by sourcePropertyName and targetPropertyName

Linq expressions and extension methods to get property name

我的梦境 提交于 2019-12-28 16:21:09
问题 I was looking at this post that describes a simple way to do databinding between POCO properties: Data Binding POCO Properties One of the comments by Bevan included a simple Binder class that can be used to accomplish such data binding. It works great for what I need but I would like to implement some of the suggestions that Bevan made to improve the class, namely: Checking that source and target are assigned Checking that the properties identified by sourcePropertyName and targetPropertyName

Get Description Attributes From a Flagged Enum

折月煮酒 提交于 2019-12-22 08:27:56
问题 I am trying to create an extension method that will return a List<string> containing all the Description attributes for only the set values of a given [Flags] Enum . For example, suppose I have the following enum declared in my C# code: [Flags] public enum Result { [Description("Value 1 with spaces")] Value1 = 1, [Description("Value 2 with spaces")] Value2 = 2, [Description("Value 3 with spaces")] Value3 = 4, [Description("Value 4 with spaces")] Value4 = 8 } And then have a variable set as:

MEF and unit testing with NUnit

那年仲夏 提交于 2019-12-21 05:31:25
问题 A few weeks ago I jumped on the MEF (ComponentModel) bandwagon, and am now using it for a lot of my plugins and also shared libraries. Overall, it's been great aside from the frequent mistakes on my part, which result in frustrating debugging sessions. Anyhow, my app has been running great, but my MEF-related code changes have caused my automated builds to fail. Most of my unit tests were failing simply because the modules I was testing were dependent upon other modules that needed to be

Creating custom activity design without reference to Design DLL in Windows Workflow Foundation

[亡魂溺海] 提交于 2019-12-12 17:23:22
问题 I am using Windows Workflow Foundation with custom Activities , and I would like to create custom Design for these activities in my workflow. I am able to make the design project, and the designer xaml. Also I am able to see the custom design for them in the workflow, if I directly refer the Design project in my Workflow project . This is something that I would not like to do, because the Designer DLL should not be deployed to production environment. I would only like to have the custom