Access A Method's Parameter From An Associated Attribute?
Mar 19, 2009Given the following classes, how can i intercept Class1.SampleMethod's Value from SampleAttribute?[code]...
View 2 RepliesGiven the following classes, how can i intercept Class1.SampleMethod's Value from SampleAttribute?[code]...
View 2 RepliesI have a method which requires a parameter to be passed in. I would like to use the Addhandler to call the method through a dynamically created button control's click event.
When I include () in the AddressOf, VS complains: 'AddressOf' operand must be the name of a method (without parentheses).
When I exclude the brackets, VS complains: Method '...' does not have a signature compatible with delegate...
My code:
CODE:
I'm trying to use the type Boolean for some parameter.
<AttributeUsage(AttributeTargets.Method, Inherited:=True, AllowMultiple:=False)>
Public Class MyAttribute
Inherits Attribute
[code].....
I'd like to auto-register the common/simple services in my unity container. I think the cleanest way to do this would be via a custom atribute.I can then examine all the (abstract) classes in an assembly and register those types with unity.The piece of information I'm missing is the interface(s) that the class wants to be registered against
eg:
Public Class AutoRegisterAttribute
Public Property ForInterface As System.Type
Public Sub New(ForInterface As System.Type)
[code]....
Note, I don't just want to find any class it implements as shown with IDisposableI've tried doing this using generics (generics can't inherit from Attribute), with a Type Parameter (Passing in IEngine.GetType results in a "Constant expression is required")
I have a Winforms project that is loosely based on MVVM. Security is implemented by the domain layer by using the PrincipalPermissionAttribute, [cod]e...
View 1 RepliesI have a couple of shared methods in my app which are intended to be used with ObjectDataSource's (and other reflection based objects). They handle a lot of automatic parameter checking, filtering, etc. They are, however, all one time use methods (they rebuild everything on every call). It would be much better for someone writing code directly to call the instance methods so that all the filtering, etc, is stored between calls.Is there an attribute I can add to my methods to indicate this? The best would be if it would prevent the method from being called without reflection. Second best would be to issue a warning that the method is being used wrong.[code]
View 1 RepliesI'm trying to figure out what the best method is for attaching a single key/value pair attribute to an enumeration where the key is my MerchantId and the value is the corresponding TransactionKey. What I currently do is put a comma delimited string into a StringValueAttribute class:
Public Enum Merchants
<StringValue("coke,faj80785hq+faf=-1=-jfa+">
Coke = 0
<StringValue("pepsi,adfji=-901jnas++fdj98ua")>
Pepsi = 1
<StringValue("drpepper,jk878-=+9kdkdja0=a=f--daj")>
DrPepper = 2
[Code]...
Is this the most efficient way to do this? Instead of StringValueAttribute, what about creating an attribute using a Dictionary(Of String, String) since it is a key/value pair list? Or String Array or List? Maybe something in LINQ?
Is there a way to choose between different methods and pass one into another method ?
Sub conditionnal_binding(ByVal list_box_reference As ListBox, ByVal list_box_final As ListBox, _
ByVal dico_source As Dictionary(Of String, List(Of String)), _
ByVal my_methode As ??? )
' DO SOMETHING
End Sub
I wrote ??? because I don't know how to call another method inside a method.
I would like to choose between different "sub-methods". Here is how I would like to use my method :
conditionnal_binding(ListBox1, ListBox3, HTML.dico_basic_attribut, best_method)
conditionnal_binding(ListBox1, ListBox3, HTML.dico_basic_attribut, some_method)
conditionnal_binding(ListBox1, ListBox3, HTML.dico_basic_attribut, another_method)
I'm trying to code a class of RandomNumber. One of the class methods needs to populate a "List (Of RandomNumber)" ... which was passed as a parameter to the method ... with 10 random numbers between 1 and 50. DEAD SIMPLE :)
View 6 RepliesI have a a method drawPaper(g, rect,.....).This drawPaper method is called on from another method (PrintPaper method) with the parameters passed on as (e.graphics, rect, .....) i.e drawpaper (e.graphics, rect, .....) why is the method called with the e.graphics argument not with g as per the method.
View 6 Replies<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-
[Code]....
This is my Effect.xml file .I am using vb.net to access this xml file.
Actually i want to access effect name when i enter particular effect id.So that i will get attribute value of effect name when i give effect id as input value
How can i do using vb.net
I'm trying to make this code with reflection since I want it to manage Technician and other types too.
[Code]....
Is it accepted to have a method parameter named the same as a property? At least it gives no error, even if in the same letter-case.. How does the compiler distinguish? does it always prioritize the local parameter?
[Code]...
I have a method/sub that takes an object as a parameter, then it scans through a panels controls and trys to find if it is in the window.
Public Sub removetype (ByVal findobject As Object)
Dim types As System.Type = findobject.GetType
For Each ThisCtrl In Flow.Controls 'flow is a panel
[Code]......
So for instance I have this method: LoadFunkyInfo(byval funkyData as string) And I pass it something like this:
LoadFunkyInfo(giantTable.Rows.Item(0).Item("blahName")). Should I do this instead?
dim foo as string = giantTable.Rows.Item(0).Item("blahName")
LoadFunkyInfo(foo)
I read somewhere long ago, that it's better to assign the method to a variable and pass that variable to a method, as opposed to passing the method as a parameter. Is that still true? Or true at all?
This link explains the Encoder.GetBytes Method and there is a bool parameter called flush explained too . The explanation of flush is : true if this encoder can flush its state at the end of the conversion; otherwise, false. To ensure correct termination of a sequence of blocks of encoded bytes, the last call to GetBytes can specify a value of true for flush.but I didn't understand what flush does?
View 3 RepliesI have traditionally coded empty strings like this "", but for a couple of years now, I have been using String.Empty.I also normally never use optional parameters, but I'm refactoring a solution that's tied into my ERP, and I don't want to break anything. One of the changes was to add a parameter to proc, which pushes a new parameter into the method from which it is called. I coded it like this:
Optional BackReferenceID As String = String.Empty
But I got a syntax error "Constant expression is required." I guess String.Empty is non-deterministic??? Anyway, it seems like a bug. The workaround is of course to use double quotes.
I'm currently working on being able to import a DLL written in Fortran into Visual Basic. I've got all the basics down, so now I'm trying to take it a step further. The title basically says it all, but I'll explain what it is I'm trying to do anyways.
For kicks and giggles, let's just assume I want to pass an object that has three double values in it, possibly representing a point in space in three dimensions. In my Fortran method, I want to take that object, print out the x value, then change the x value to 7.5. Here's my Fortran code that does just that.[code]...
What happened when parameter passing. Here is a test project I write.
Public Class Form1
'1.test string
Private Sub btnString_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnString.Click
Dim str1 As String = "x"
[Code] .....
From the project you can see, when pass integer type parameter (value type) into a method , if use ByVal keyword, the value won't change. If use ByRef keyword, the value will change (I can understand it, to my understanding, when using ByVal, It pass the value of the argument to the method; when using BvRef, it pass the address of the argument to the method, so the value can be rewrite)
Well, for the following two scenarios , I can't understand why.
String type is reference type, but it acts like integer type.
Val type is also reference type, but no matter what you use(ByVal or ByRef), the result will be the same.
So my question is what actually passed into method? What's the underlying mechanism about pass parameter? What's the effect of ByRef and ByVal to value type and reference type?
I'm using the Authorize() attribute to secure my controllers/actions and want to only display the Login action to unauthenticated users - or to put it another way, deny access to authenticated users. I haven't been able to find anything on the web dealing with either denying permission or allowing negative permissions (i.e., ! LoggedIn)
MVC2, .Net 4
To clarify, I want something like this:
Public Class PublicController
Inherits ControllerBase
<Authorize()> 'Only logged-in users can logout
Public Function Logout() as ActionResult
[Code] .....
I have already defined in my SELECT statement in TableAdapter to tell it what to do if the parameters are Null:
SELECT a.ID, a.NameID, b.BNameID
FROM a INNER JOIN b
ON a.ID = b.ID
WHERE ((@NameID IS NULL) OR (a.NameID = @NameID))
AND ((@BNameID IS NULL) OR (b.BNameID = @BNameID))
Jst recently i came across the select() method of data table and felli n love with it instantaneously.
Basically I want query the data table on a date field, unfortunately the format of the date string returned from y database in to data-table and the date string i'm passing as inputs are different.
How can i make sure that the data is compared irrespective of the formats ? Can I use something like SqlParameters whoes data type is date for comparison ??
this is what i'm tying :
dim dat as date = "#1/3/2009#"
dt.select("StzDate ='" & dat "'")
entry in datateable dt : StzDate : 3/1/2009 12:00:000
Am I do'in something wrong ??
Also, can anyone redirect me to some site where I can learn a bit more about passing parameters to the select statement,etc...
In VB.NET, it is entirely possible to pass an integer as a string parameter to a method without calling .ToString() - it's even possible to call .ToString without the ()'s. The code will run without a problem, VB will interpret the integer as a string without having been told to. In C#, these would cause compilation errors - you are required to call .ToString() and to call it correctly in that situation before it will compile. Is there a way to make the VB compilation process check for the same things as the C# compilation process? Would it be best practice in a mixed team to force this check?
View 3 Replieshere any algorithms/pseudocode for reading/parsing 3-column csv data and determining unique objects/attributes/values?
example data:
john,height,1.75
george,age,21
[Code]....
i have already implemented a solution of my own but it's too slow and i can't find any relevant literature on the internet.
Possible Duplicate: Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive
I am using window xp and iis 5.1 to run the application.
error is occurred Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
[Code]...
I recently changed application settings to be in an encrypted config file.The first time I run any application and try to retrieve a setting (My.settings. ...) from the config file I get an Unrecognized attribute 'configProtectionProvider'If I restart the application I don't get an error due to the fact that it doesn't re-encrypt during that run. Why when I run the application for the first time am I getting this error?
I am encrypting the config file on application startup using the following code:
[Code]...
I get an error when I try to build my project.'SSLAccessFiltercannot' be used as an attribute because it does not inherit from 'System.Attribute'. [code]
View 1 RepliesI am trying to utilize the access database, but I'm getting an error message: Value cannot be null. Parameter name: dataSet
[Code]...
That's the code I'm using, why I'm getting this error?
I want to know can i access parameter exe using vb.net or c#.net.
View 1 RepliesI'm doing a search option in my system where if your searching for a entry even if you didnt typed the whole word, all of the entry that contains the letters that you have typed will appear, well i really cant explain it but it goes like this if i have entries:
reserve,reservoir,restaurant,jaded,mend,feed in my database and the searcher typed "res" all the word containing res will appear. i know it has something to do with the like parameter but i just cant do the code right.