Click here to Skip to main content
12,503,681 members (31,496 online)
   

C#

 
AnswerRe: how to setting Four tier application in my application? Pin
Dave Kreskowiak4-Oct-12 6:45
mvpDave Kreskowiak4-Oct-12 6:45 
QuestionRe: how to setting Four tier application in my application? Pin
Eddy Vluggen4-Oct-12 9:02
memberEddy Vluggen4-Oct-12 9:02 
AnswerRe: how to setting Four tier application in my application? Pin
OriginalGriff4-Oct-12 9:34
mvpOriginalGriff4-Oct-12 9:34 
Questionsqldatabaseconnectivity Pin
Member 94545634-Oct-12 4:05
memberMember 94545634-Oct-12 4:05 
AnswerRe: sqldatabaseconnectivity Pin
Ravi Bhavnani4-Oct-12 4:31
memberRavi Bhavnani4-Oct-12 4:31 
AnswerRe: sqldatabaseconnectivity Pin
Richard MacCutchan4-Oct-12 4:32
mvpRichard MacCutchan4-Oct-12 4:32 
AnswerRe: sqldatabaseconnectivity Pin
palakshamb4-Oct-12 23:28
memberpalakshamb4-Oct-12 23:28 
QuestionCan an Attribute class find out, to which class it is actually attached? Pin
Andy4114-Oct-12 2:42
memberAndy4114-Oct-12 2:42 
Background:
To implement localization I have derived from DisplayNameAttribute: LocalDisplayNameAttribute. When using this attribute, I only want to declare the ResourceString an a default string. The class LocalDisplayNameAttribute should find out on it's own, which class and which assembly is using it.

My idea is, to find the strings in related resources by reflection. The strings should allways be in AssemblyName.Properties.Resources.

Is it possible for a attribute class, to find out, who it is used by?

Example:

Assembly LocalizationTools.dll
namespace LocalizationTools
{
    public class LocalDisplayNameAttribute : DisplayNameAttribute
    {
        public LocalDisplayNameAttribute(string resourceName, string defaultText)
            : base(defaultText)
        {
            m_resourceName = resourceName;
        }
        
        public override string DisplayName
        {
            get
            {
                string name = string.Empty;
                try
                {
                    name = SomeVodoo(base.DisplayNameValue);
                }
                catch (Exception)
                {
                    name = base.DisplayNameValue;
                }
                return name;
            }
        }
        
        private string SomeVodoo(string defaultText)
        {
            // Find out to which class an assembly we belong. Then Find the Properties.Resources of the assembly
            // and find the m_resourceName
        }    
    }
}

Assembly SomeClasses.dll

public class Foo
{
    [LocalizationTools.LocalDisplayName("DisplayName_ImportantProperty", "Important property XYZ")]
    public int ImportantProperty { get; set; }
}

And in SomeClasses.Properties.Resources you can find DisplayName_ImportantProperty


PS: I have a IMO less elegant solution by declaring the type.

[LocalizationTools.LocalDisplayName(typeof(SomeClasses.Properties.Resources), "DisplayName_ImportantProperty", "Important property XYZ")]
    public int ImportantProperty { get; set; }
}

Thanks in advance

Andy
AnswerRe: Can an Attribute class find out, to which class it is actually attached? Pin
Dave Kreskowiak4-Oct-12 6:56
mvpDave Kreskowiak4-Oct-12 6:56 
GeneralRe: Can an Attribute class find out, to which class it is actually attached? Pin
Andy4114-Oct-12 20:05
memberAndy4114-Oct-12 20:05 
AnswerRe: Can an Attribute class find out, to which class it is actually attached? Pin
BobJanova5-Oct-12 1:15
memberBobJanova5-Oct-12 1:15 
GeneralRe: Can an Attribute class find out, to which class it is actually attached? Pin
Andy4116-Oct-12 2:25
memberAndy4116-Oct-12 2:25 
QuestionReturning Object From HashTable Pin
AmbiguousName4-Oct-12 1:10
memberAmbiguousName4-Oct-12 1:10 
AnswerRe: Returning Object From HashTable Pin
Smart Arab4-Oct-12 1:54
memberSmart Arab4-Oct-12 1:54 
AnswerRe: Returning Object From HashTable Pin
Member 94836444-Oct-12 1:59
memberMember 94836444-Oct-12 1:59 
AnswerRe: Returning Object From HashTable Pin
Manfred R. Bihy4-Oct-12 2:22
mvpManfred R. Bihy4-Oct-12 2:22 
AnswerRe: Returning Object From HashTable Pin
Bernhard Hiller4-Oct-12 21:05
memberBernhard Hiller4-Oct-12 21:05 
Questionbusiness process management Pin
sag4prog4-Oct-12 1:04
membersag4prog4-Oct-12 1:04 
AnswerRe: BUSINESS PROCESS MANAGEMENT Pin
OriginalGriff4-Oct-12 9:34
mvpOriginalGriff4-Oct-12 9:34 
QuestionC# Pin
S Akshay4-Oct-12 0:19
memberS Akshay4-Oct-12 0:19 
AnswerRe: C# Pin
Eddy Vluggen4-Oct-12 0:42
memberEddy Vluggen4-Oct-12 0:42 
QuestionJQUERY in C# Pin
JabbarJahambana3-Oct-12 22:00
memberJabbarJahambana3-Oct-12 22:00 
AnswerRe: JQUERY in C# Pin
Pete O'Hanlon3-Oct-12 22:30
protectorPete O'Hanlon3-Oct-12 22:30 
AnswerRe: JQUERY in C# Pin
palakshamb4-Oct-12 23:42
memberpalakshamb4-Oct-12 23:42 
QuestionTagLibSharp help needed Pin
joost.versteegen3-Oct-12 20:42
memberjoost.versteegen3-Oct-12 20:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 26 Sep 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid