custom-attributes

Custom Attribute is executed at compile time

我与影子孤独终老i 提交于 2021-02-07 18:36:13
问题 I'm trying to create a custom attribute that will work in a sort-of AOP way (I don't have access to postsharp, unfortunately and I'm not very familiar with Unity). It has AttributeUsage.Method and in its constructor it configures some parts of the test environment (pulls some info out of app.config and calls some exes that config the environment). It works, except that right now, when I build the solution, the attribute is executed - which is undesireable. Is there a way to create a custom

Custom Attribute is executed at compile time

旧街凉风 提交于 2021-02-07 18:36:07
问题 I'm trying to create a custom attribute that will work in a sort-of AOP way (I don't have access to postsharp, unfortunately and I'm not very familiar with Unity). It has AttributeUsage.Method and in its constructor it configures some parts of the test environment (pulls some info out of app.config and calls some exes that config the environment). It works, except that right now, when I build the solution, the attribute is executed - which is undesireable. Is there a way to create a custom

Laravel relationship based on custom attribute not working both directions

て烟熏妆下的殇ゞ 提交于 2021-01-29 10:53:33
问题 Models Product and Category. Product model has this custom attribute: getCategoryIdAttribute() . because the way to get category id is a bit complex. With that attribute I can define the relationship (Product -> Category): public function category() { return $this->belongsTo(Category::class, 'category_id', 'id'); } This relationship works fine! But now on the Category model: public function products() { return $this->hasMany(Product::class, 'category_id', 'id'); } If I use this relationship

Mapping component attributes without a value

假如想象 提交于 2021-01-27 12:11:29
问题 I am after providing a property for my Angular component. By property I mean a toggle-style boolean attribute that you put in HTML without specifying the attribute's value: as opposed to an input (this is not what I want): If compact is present then the component should coerce its value it to a boolean: <my-component compact="compact"> // <= true <my-component compact="true> // <= true <my-component compact="false"> // <= true? If compact has no value then it maps to true: <my-component

Mapping component attributes without a value

点点圈 提交于 2021-01-27 12:10:39
问题 I am after providing a property for my Angular component. By property I mean a toggle-style boolean attribute that you put in HTML without specifying the attribute's value: as opposed to an input (this is not what I want): If compact is present then the component should coerce its value it to a boolean: <my-component compact="compact"> // <= true <my-component compact="true> // <= true <my-component compact="false"> // <= true? If compact has no value then it maps to true: <my-component

Debugger is not entering custom attribute class

本秂侑毒 提交于 2020-06-14 06:47:07
问题 This is a C# WPF application for a desktop. I've created a custom attribute class but in debug it never goes in there. Do I need to add something else to this class? [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public class Authentication : Attribute, IPrincipal { public Authentication(string id) { throw new NotImplementedException(); } public IIdentity Identity { get; private set; } public bool IsInRole(string role) { throw new NotImplementedException();

Add metadata to an XSD definition

旧时模样 提交于 2020-01-24 11:15:31
问题 Not all that familiar with XSD, I wonder if it is possible to do the following: <xs:group name="SomeGroup"> <xs:sequence> <xs:element name="Groupingcode" type="OurType" origin="DB" /> <xs:element name="Description" type="StringType" origin="XML" /> To explain: I have an XSD schema file. I need to generate an XML file according to the XSD (this part works fine) containing database data. However, some elements need additional data to be able to find the proper field to get from the database.

Add metadata to an XSD definition

╄→гoц情女王★ 提交于 2020-01-24 11:15:05
问题 Not all that familiar with XSD, I wonder if it is possible to do the following: <xs:group name="SomeGroup"> <xs:sequence> <xs:element name="Groupingcode" type="OurType" origin="DB" /> <xs:element name="Description" type="StringType" origin="XML" /> To explain: I have an XSD schema file. I need to generate an XML file according to the XSD (this part works fine) containing database data. However, some elements need additional data to be able to find the proper field to get from the database.

Type constraints in Attributes

*爱你&永不变心* 提交于 2020-01-24 03:20:08
问题 I want to write my enum with custom attributes, for example: public enum SomeEnum: long { [SomeAttribute<MyClass1>] Sms = 1, [SomeAttribute<MyClass2>] Email = 2 } but attributes doesn't support generics. Well, the most similar solution is: public enum SomeEnum: long { [SomeAttribute(typeof(MyClass1))] Sms = 1, [SomeAttribute(typeof(MyClass2))] Email = 2 } And here is problem: I want Class1 to be inherited from ICustomInterface , so with generics I can write constraint: [AttributeUsage

Disabling items in PropertyGrid using Custom Attributes

烂漫一生 提交于 2020-01-17 04:19:35
问题 I am able to selectively enable / disable items in a PropertyGrid by setting BrowsableAttributes to an array containing CategoryAttribute objects. However, I wish to enable some items within a category and disable others within the same category, so I thought I would create my own custom attribute class and apply this to the properties in my object, but this does not seem to work. Here is my custom attribute class: Public Enum HeadType DMA = 1 TMA = 2 Both = 0 End Enum <AttributeUsage