custom-attributes

Imagebutton change source property

别等时光非礼了梦想. 提交于 2019-12-11 17:09:18
问题 I'm developing a Windows Phone app. I have a custom button with an image inside. This is its XAML code: <ControlTemplate x:Key="ImageButton" TargetType="Button"> <Grid> <Image Margin="45,8,35,8" Source="Images/Delete.png"/> </Grid> </ControlTemplate> How can I change Image Source property programmatically? 回答1: To change the source of an image you need to make a new bitmap of your asset and set it as a souce BitmapImage myBitmapImage = new BitmapImage(new Uri("/Images/foo.png", UriKind

How can I get my custom backend Magento Customer Checkbox Attribute to save my selection?

喜夏-厌秋 提交于 2019-12-11 15:33:05
问题 Magento CE 1.5.1.0 I'm trying to create a new customer attribute on the installation file for a Magento Module. I have it working fine for text inputs, but I would like to add a checkbox to the customer "Account Information" section of the "Customer Information" page, in the admin backend. It shouldn't be visible on the frontend or editable by the customer. I just want it to be a boolean value. I have the attribute appearing on the backend, in the correct place, and it defaults to being

Accessing value of JsonPropertyAttribute in C# [duplicate]

大兔子大兔子 提交于 2019-12-11 15:01:40
问题 This question already has answers here : Reflection - get attribute name and value on property (14 answers) Get a list of JSON property names from a class to use in a query string (3 answers) Getting the JsonPropertyAttribute of a Property (1 answer) Closed 12 months ago . Am having a class of this nature, using Newtonsoft.Json; namespace Models { public class ItemsDbTable { [JsonProperty("City")] public string City { get; set; } [JsonProperty("Delivery.no")] public string DeliveryNo { get;

Custom authorize attribute - can I store a value for later?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 14:10:53
问题 I have a custom authorize attribute, which basically simply verifies that a cookie was sent with the request and that it has a value assigned. public override void OnAuthorization(AuthorizationContext filterContext) { if (filterContext == null) throw new ArgumentNullException("filterContext"); bool skipAuthorization = filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), inherit: true) || filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof

Read Attribute on property without calling getter?

时间秒杀一切 提交于 2019-12-11 08:55:18
问题 C# 4.0. I have a slow property with an attribute. I want to read this attribute without calling the getter: [Range(0.0f, 1000.0f)] public float X { get { return SlowFunctionX(); } } This is what I have now: public static T GetRangeMin<T>(T value) { var attribute = value.GetType() .GetField(value.ToString()) .GetCustomAttributes(typeof(RangeAttribute), false) .SingleOrDefault() as RangeAttribute; return (T)attribute.Minimum; } var min = GetRangeMin<double>(X); // Will call the getter of X :( Q

TypedArray and styleable attributes: getIndexCount() vs. length()

匆匆过客 提交于 2019-12-11 08:42:57
问题 I'm working with parsing custom attributes, and I've come across something weird. Let's say my parser looks something like this: final TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.Item); final int size = attributes.getIndexCount(); for(int i = 0; i < size; i++) { final int attr = attributes.getIndex(i); if(attr == R.styleable.Item_custom_attrib) { final int resourceId = attributes.getResourceId(attr, -1); if(resourceId == -1) throw new Resources.NotFoundException(

Serialize Custom Attribute Values

不想你离开。 提交于 2019-12-11 06:55:23
问题 Given the following class: public class PayrollReport { [UiGridColumn(Name = "fullName",Visible = false,Width = "90")] public string FullName { get; set; } [UiGridColumn(Name = "weekStart", CellFilter = "date")] public DateTime WeekStart { get; set; } } And this custom attribute [AttributeUsage(AttributeTargets.All)] public class UiGridColumn : Attribute { public string CellFilter { get; set; } public string DisplayName { get; set; } public string Name { get; set; } public bool Visible { get;

React Typescript - Adding custom attribute

馋奶兔 提交于 2019-12-11 06:45:00
问题 React Typescript allow to add custom data-* attributes. But is it possible to add custom attributes like 'name' || 'test' act. ? <span name="I'm causing a type error" data-test="I'm Working"/> Bold added by me. type error: Type '{ children: Element; name: string; data-test: string; }' is not assignable to type 'DetailedHTMLProps, HTMLSpanElement>'. Property 'name' does not exist on type 'DetailedHTMLProps, HTMLSpanElement>'. TS232 "react": "^16.7.0", "typescript": "^3.2.4", 回答1: in react 16+

Keeping IClientValidatable outside the model layer

安稳与你 提交于 2019-12-11 05:41:14
问题 I'm using Data Annotations to validate my model classes. I wrote a couple of custom attributes as well. Ultimately, the model is pushed to a web interface built in ASP.NET MVC, but I want to keep a clean separation of concerns, so the model classes has its own assembly (which will also be used by console apps). Having to use the IClientValidatable interface (which is a web concern) in the model layer breaks the loose coupling I'm aiming for. Any ideas on how to fix this? Thanks. 回答1: You can

Adding a parameter to a method using attributes

给你一囗甜甜゛ 提交于 2019-12-11 03:43:33
问题 Admittedly, this one's a long shot. I'm working on an auditing piece where you open and close an audit record at the start and end of your action. I have it nicely rigged up so that in order to audit a method, you just have to add an [Audit(AuditType.Something)] attribute onto it, plus some other information if needed, like messages. Then, using SNAP, I have an interceptor that handles creating the Audit object, then opening and closing it. A case came up from a coworker where we would need