Hello!
I'm new to C# and wondering if it's possible to wrap a method only by adding an attribute.
Example: I want to log the execution time a method takes.
[LogTimings]
public void work()
{
..
}
This is kind of wrapping a method into another one(see this python implementation)
...
I'm trying to convert all my old javascripts to jquery but I'm a bit confused how can I convert my click event with attr. The old javascript looks something like:
function MyFunction(string1, string2){
doSomething(string1);
doSomethingElse(string2);
}
And then I call it with
<a href="javascript:MyFunction('string 1','string 2...
Say I have the following set of classes, is it possible for the attributes of DerivedClass to be merged? Currently if I use the GetType().GetCustomAttributes()method passing in true for inheritance it takes the highest attributes in the inheritance structure.
i.e. [Another("Bob")] and [My(16)]
Is it possible for the attributes to be me...
I am using a dropdown list as follows.
<%=Html.DropDownList("ddl", ViewData["Available"] as SelectList,
new { CssClass = "input-config", onchange = "this.form.submit();" })%>
On its selection change I am invoking post action. After the post the same page is shown on which this drop down is present. I want to know about the HTML a...
I have a custom module that exports data to our fulfillment system when the user checks out. Before export I need to run the address through a verification service. Since we are charged for this service, I need to configure the user name and password for the service per store. I have added the attributes I need, however I cannot figur...
I know individual attributes can be retrieved with the attr() method, but I'm trying to iterate over all of the attributes for an element. For context, I'm using jQuery on some XML...
<items>
<item id="id123" name="Fizz" value="Buzz" type="xyz">
<subitem name="foo">
<subitem name="bar">
</item>
<item id="id456" name="Bizz...
From some xml I want to find items that have a specific attribute and value.
Here is example xml:
<node>
<node>
<node>
<special NAME="thisone"></special>
</node>
<node>
<special>dont want this one</special>
</node>
</node>
</node>
(nodes can contain nodes...)
I need to find the first based on it has an attribute nam...
Hi,
I've been trying to formulate a regular expression to remove any attributes that may be present in html tags but I'm having trouble doing this and Google doesn't seem to provide any answers either.
Basically my input string looks something like
<p style="font-family:Arial;" class="x" onclick="doWhatever();">this text</p>
<img st...
I am working in c#.NEt 2.0. I have a class, let's say X with many properties. Each properties has a custom attribute, an interger, which I planned to use to specify its order int he final array.
Using reflection I read through all of the properties and group the values and place them into a generic list of properties. This works and I c...
Hi,
I would like to define a constrait on my custom (PostSharp) attribute. My goal is to get error or warning while compile time, if class X dont implements Y interface but it has my attribute.
So this should work:
[MyAttributeOnlyForY]
public class X : Y { ... }
but this should break the compile process:
[MyAttributeOnlyForY]
publ...
Hey guys
Just wondering how do I mimic the following using attributes...
<%= Html.EditorFor(x => x.SportProgramIdList, "FormMultiSelectDropDownList", "SportProgramIds")%>
I know I can specify the template by using [UIHint("FormMultiSelectDropDownList")] but I am left with the problem with how to set the name...
Cheers
Anthony
...
Hi,
I have a question:
Is there an elegant way of getting Attributes on a referenced field.
Ie.:
public class C1: Base
{
[MyAttribute]
public string Field1;
}
public class Base
{
private void Do(ref string field)
{
if (field has attributes)
DoSomething();
}
}
How can I get attributes of a f...
I'm trying to determine if a interface is decorated with a specific attribute. For example, I have the following interface:
<MyCustomAttribute()> _
Public Interface IMyInterface
Function Function1
Sub DeleteWorkflowInstanceMap(ByVal instanceId As Guid)
Sub InsertWorkflowInstanceMap(ByVal instanceId As Guid, ByVal aliasName ...
For example:
[TestFixtureSetUp]
public void Init()
{
GetTestRepo(false);
}
[TestFixtureSetUp] in this example, what does it do? From my experience, [] usually refers to lists.
...
Hi,
I can check if an element have a specific attribute with:
if ($('#A').attr('myattr') !== undefined) {
// attribute exists
} else {
// attribute does not exist
}
How can I check if an element have any attribute?
Thank you
...
I have an object that I set as the datasource for a gridview - this works fine, I get a nice table on the page with a column for each public property.
But - I always want to hide one of the columns (but still need it available as a public property.
I'm using a clunky hide-column-on-row-created fix for now, but am looking for a better s...
I am trying to set a Core Data attribute but am getting incompatible type errors. I have a float attribute in a Core Data entity on iPhone 3.0. Core Data auto-generates an interface for a managed data object that provides property access to it:
@property (nonatomic, retain) NSNumber * volume;
and an implementation for it:
@dynamic vo...
If multiple attributes are applied to a member, e.g.
[Foo]
[Bar]
void Baz() { ... }
Then are any guarantees made by the CLR/.NET specifications as to what order they will be retrieved in when retrieved by reflection (e.g. Attribute.GetCustomAttributes)? The documentation for these methods does not make it explicit, and while it does s...
I have a User model with a number of very similar properties that I want to list without typing each on in individually.
So, rather than:
"eye color: #{@user.his_eye_color}"
"hair color: #{@user.his_hair_color}"
"height: #{@user.his_height}"
"weight: #{@user.his_weight}"
...
"eye color: #{@user.her_eye_color}"
"hair color: #{@user.her...
What is the difference between the code bellow
' no Flags'
Public Enum MyEnum
Monday = 1
Tuesday = 2
Wednesday = 4
Thursday = 8
End Enum
and
<Flags()> _
Public Enum MyEnum
Monday = 1
Tuesday = 2
Wednesday = 4
Thursday = 8
End Enum
I do the
Dim days As MyEnum = MyEnum.Monday Or MyEnum.Tuesday Or MyEnum.Wednesday ...