custom-attributes

Windows 7: Property Handler works in Explorer but Not FileOpenDialog?

元气小坏坏 提交于 2019-12-03 02:37:09
Working on writing a custom property Handler for our custom file type in windows 7. I have installed the Windows 7 SDK and built the sample Property Handler. After registering the handler, it works great in Windows Explorer, but in the common file open dialog the custom values do not appear. Does anyone know if there is something special I need to do to get the properties to appear in common dialogs? Explorer: File Open Dialog: OK, figured it out. Here is the deal. My app is 32 bit and I am on a x64 system. Because the PropertyHandler is written in x64 to support the shell out of process. But

How can I implement permission-based authorization in ASP.NET?

可紊 提交于 2019-12-02 21:03:21
I'm working an a ASP.NET application (not using MVC) and need a User-Role-Permission based authorization scheeme, where pages and/or methods can demand the specific permission they require (instead of which role the user has). Is there a way to extend Forms Authentication (or building something) to solve this? If possible I would like to be able to use attributes: [RequirePermission("UserEdit")] public partial class EditUser : System.Web.UI.Page { } Perhaps even for methods: public class MyClass { ... [RequirePermission("UserEdit")] public void Save() { ... } } Is this possible? I found this

How to check if C# class has security attribute used

醉酒当歌 提交于 2019-12-02 07:11:46
问题 How can I check and make sure that a class uses my own custom security attribute? I know that I can use reflection to get normal attributes, but if the custom attribute is based on a security attribute as shown below reflection doesn't show it. Is there any way to check that? Why I would need this is to make sure that a plugin that is loaded to a cloud based system must use security attribute so the class that get's loaded cannot access any restricted files and so on. Here is the custom

Custom Attribute not being hit

核能气质少年 提交于 2019-12-02 06:26:24
I've created a custom attribute which writes to the console when it's hit, however it doesn't seem to be hit. It's the microsoft tutorial (http://msdn.microsoft.com/en-us/library/sw480ze8.aspx) and is being run on 2010, .net 4. I'm guessing it must be me that's doing something wrong, but I can't see what it is. Can anyone help? This is the attribute, whose code is never being hit [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] public class Author : Attribute { private string _name; private double _version; public Author(string name) { Console.WriteLine(string.Format("author

Get overridden property attribute

二次信任 提交于 2019-12-02 02:41:54
问题 I have a custom attribute like this: public class PropertyInfoAttribute : Attribute { public bool IsAutoComplete { get; set; } } And there is a class like this: public class Article { public virtual int Order { get; set; } //other properties } In another class,which inherits from Article, I override Order property and declare the attribute for it like this: public class ArticleDetails : Article { [PropertyInfo(IsAutoCompele = true)] public override int Order { get; set; } } The problem

Aurelia Custom Attribute with setAttribute method()

萝らか妹 提交于 2019-12-02 02:03:24
It seems Aurelia is not aware when I create and append an element in javascript and set a custom attribute (unless I am doing something wrong). For example, const e = document.createElement('div'); e.setAttribute('custom-attr', 'some value'); body.appendChild(e); Is there a way to make Aurelia aware of this custom attribute when it gets appended? A little background: I am creating an app where the user can select their element type (e.g. input, select, checkbox etc.) and drag it around (the dragging is done in the custom attribute). I thought about creating a wrapper <div custom-attr repeat

.NET Flag Enum get Attributes from values

六月ゝ 毕业季﹏ 提交于 2019-12-01 22:57:52
问题 Greetings StackOverflow, If I've got an enum type with the Flag attribute as well as the values in this enum type with their own attributes, how can I retrieve all of the appropriate attributes? For example: [Flags()] enum MyEnum { [EnumDisplayName("Enum Value 1")] EnumValue1 = 1, [EnumDisplayName("Enum Value 2")] EnumValue2 = 2, [EnumDisplayName("Enum Value 3")] EnumValue3 = 4, } void Foo() { var enumVar = MyEnum.EnumValue2 | MyEnum.EnumValue3; // get a collection of EnumDisplayName

.NET Flag Enum get Attributes from values

心不动则不痛 提交于 2019-12-01 20:15:56
Greetings StackOverflow, If I've got an enum type with the Flag attribute as well as the values in this enum type with their own attributes, how can I retrieve all of the appropriate attributes? For example: [Flags()] enum MyEnum { [EnumDisplayName("Enum Value 1")] EnumValue1 = 1, [EnumDisplayName("Enum Value 2")] EnumValue2 = 2, [EnumDisplayName("Enum Value 3")] EnumValue3 = 4, } void Foo() { var enumVar = MyEnum.EnumValue2 | MyEnum.EnumValue3; // get a collection of EnumDisplayName attribute objects from enumVar ... } A quick and dirty way using Linq: IEnumerable<EnumDisplayNameAttribute>

c#: what is a constant expression?

假如想象 提交于 2019-12-01 18:45:10
问题 I'm working with attributes at the moment. I often run into the error 'An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type.' I don't really know what 'constant expression' means. It would have been really useful to be able to pass in a Func<MyType, bool> to the attribute (to be consumed by the code which executes when the attribute is present). But alas, no. I don't understand why that type cannot be placed in

How to determine the attached type from within a custom attribute?

牧云@^-^@ 提交于 2019-12-01 18:17:59
I have a custom attribute which can be assigned to a class, [FooAttribute] . What I would like to do, from within the attribute, is determine which type has actually used me. e.g. If I have: [FooAttribute] public class Bar { } In the code for FooAttribute, how can I determine it was Bar class that added me? I'm not specifically looking for the Bar type, I just want to set a friendly name using reflection. e.g. [FooAttribute(Name="MyFriendlyNameForThisClass")] public class Bar { } public class FooAttribute() { public FooAttribute() { // How do I get the target types name? (as a default) } }