Click here to Skip to main content
11,580,572 members (68,174 online)
   

C#

 
AnswerRe: .exe Reference Problem - maybe Pin
Eddy Vluggen4-Oct-12 9:01
memberEddy Vluggen4-Oct-12 9:01 
GeneralRe: .exe Reference Problem - maybe Pin
dirsow4-Oct-12 9:27
memberdirsow4-Oct-12 9:27 
GeneralRe: .exe Reference Problem - maybe Pin
Eddy Vluggen4-Oct-12 9:34
memberEddy Vluggen4-Oct-12 9:34 
GeneralRe: .exe Reference Problem - maybe Pin
dirsow4-Oct-12 9:41
memberdirsow4-Oct-12 9:41 
AnswerRe: .exe Reference Problem - maybe Pin
Bernhard Hiller4-Oct-12 21:00
memberBernhard Hiller4-Oct-12 21:00 
Questionhow to setting Four tier application in my application? Pin
somasundarapandian4-Oct-12 4:28
membersomasundarapandian4-Oct-12 4:28 
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 
AnswerRe: TagLibSharp help needed Pin
Smart Arab3-Oct-12 21:18
memberSmart Arab3-Oct-12 21:18 
AnswerRe: TagLibSharp help needed Pin
joost.versteegen3-Oct-12 21:41
memberjoost.versteegen3-Oct-12 21:41 
QuestionEquation on c# Pin
sabuhi_asad3-Oct-12 20:41
membersabuhi_asad3-Oct-12 20:41 
AnswerRe: Equation on c# Pin
Richard MacCutchan3-Oct-12 21:41
mvpRichard MacCutchan3-Oct-12 21:41 
QuestionImplementing Private Inheritence Pin
AmbiguousName3-Oct-12 19:07
memberAmbiguousName3-Oct-12 19:07 
AnswerRe: Implementing Private Inheritence Pin
Peter_in_27803-Oct-12 19:21
memberPeter_in_27803-Oct-12 19:21 
GeneralRe: Implementing Private Inheritence Pin
AmbiguousName3-Oct-12 19:33
memberAmbiguousName3-Oct-12 19:33 
GeneralRe: Implementing Private Inheritence Pin
Peter_in_27803-Oct-12 19:50
memberPeter_in_27803-Oct-12 19:50 
AnswerRe: Implementing Private Inheritence Pin
Pete O'Hanlon3-Oct-12 22:19
protectorPete O'Hanlon3-Oct-12 22:19 
AnswerRe: Implementing Private Inheritence Pin
jschell4-Oct-12 11:39
memberjschell4-Oct-12 11:39 
Questionprocess being called by C# app Pin
rachel_m3-Oct-12 18:28
memberrachel_m3-Oct-12 18:28 
AnswerRe: process being called by C# app Pin
Smart Arab3-Oct-12 20:54
memberSmart Arab3-Oct-12 20:54 
QuestionFail Read Int64 value from binary file created by C++ Pin
kisetsu3-Oct-12 14:49
memberkisetsu3-Oct-12 14:49 
QuestionThere is an error in XML document calling a PHP Webservice Pin
RalphGielkens3-Oct-12 10:54
memberRalphGielkens3-Oct-12 10:54 
QuestionPassing object[] Elements as Parameters to Invoke() Pin
ezazazel3-Oct-12 7:04
memberezazazel3-Oct-12 7:04 
AnswerRe: Passing object[] Elements as Parameters to Invoke() Pin
Matt T Heffron3-Oct-12 9:08
memberMatt T Heffron3-Oct-12 9:08 
GeneralRe: Passing object[] Elements as Parameters to Invoke() Pin
ezazazel3-Oct-12 19:26
memberezazazel3-Oct-12 19:26 
QuestionC# calling executable Pin
dcof3-Oct-12 3:57
memberdcof3-Oct-12 3:57 
AnswerRe: C# calling executable Pin
Pete O'Hanlon3-Oct-12 4:16
protectorPete O'Hanlon3-Oct-12 4:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web03 | 2.8.150603.1 | Last Updated 6 Jul 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid