Click here to Skip to main content
       

C#

 
AnswerRe: .exe Reference Problem - maybe PinmemberEddy Vluggen4-Oct-12 9:01 
GeneralRe: .exe Reference Problem - maybe Pinmemberdirsow4-Oct-12 9:27 
GeneralRe: .exe Reference Problem - maybe PinmemberEddy Vluggen4-Oct-12 9:34 
GeneralRe: .exe Reference Problem - maybe Pinmemberdirsow4-Oct-12 9:41 
AnswerRe: .exe Reference Problem - maybe PinmemberBernhard Hiller4-Oct-12 21:00 
Questionhow to setting Four tier application in my application? Pinmembersomasundarapandian4-Oct-12 4:28 
AnswerRe: how to setting Four tier application in my application? PinmvpDave Kreskowiak4-Oct-12 6:45 
QuestionRe: how to setting Four tier application in my application? PinmemberEddy Vluggen4-Oct-12 9:02 
AnswerRe: how to setting Four tier application in my application? PinmvpOriginalGriff4-Oct-12 9:34 
Questionsqldatabaseconnectivity PinmemberMember 94545634-Oct-12 4:05 
AnswerRe: sqldatabaseconnectivity PinmemberRavi Bhavnani4-Oct-12 4:31 
AnswerRe: sqldatabaseconnectivity PinmvpRichard MacCutchan4-Oct-12 4:32 
AnswerRe: sqldatabaseconnectivity Pinmemberpalakshamb4-Oct-12 23:28 
QuestionCan an Attribute class find out, to which class it is actually attached? PinmemberAndy4114-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? PinmvpDave Kreskowiak4-Oct-12 6:56 
GeneralRe: Can an Attribute class find out, to which class it is actually attached? PinmemberAndy4114-Oct-12 20:05 
AnswerRe: Can an Attribute class find out, to which class it is actually attached? PinmemberBobJanova5-Oct-12 1:15 
GeneralRe: Can an Attribute class find out, to which class it is actually attached? PinmemberAndy4116-Oct-12 2:25 
QuestionReturning Object From HashTable PinmemberAmbiguousName4-Oct-12 1:10 
AnswerRe: Returning Object From HashTable PinmemberSmart Arab4-Oct-12 1:54 
AnswerRe: Returning Object From HashTable PinmemberMember 94836444-Oct-12 1:59 
AnswerRe: Returning Object From HashTable PinmvpManfred R. Bihy4-Oct-12 2:22 
AnswerRe: Returning Object From HashTable PinmemberBernhard Hiller4-Oct-12 21:05 
Questionbusiness process management [modified] Pinmembersag4prog4-Oct-12 1:04 
AnswerRe: BUSINESS PROCESS MANAGEMENT PinmvpOriginalGriff4-Oct-12 9:34 
QuestionC# PinmemberS Akshay4-Oct-12 0:19 
AnswerRe: C# PinmemberEddy Vluggen4-Oct-12 0:42 
QuestionJQUERY in C# PinmemberJabbarJahambana3-Oct-12 22:00 
AnswerRe: JQUERY in C# PinprotectorPete O'Hanlon3-Oct-12 22:30 
AnswerRe: JQUERY in C# Pinmemberpalakshamb4-Oct-12 23:42 
QuestionTagLibSharp help needed Pinmemberjoost.versteegen3-Oct-12 20:42 
AnswerRe: TagLibSharp help needed PinmemberSmart Arab3-Oct-12 21:18 
AnswerRe: TagLibSharp help needed Pinmemberjoost.versteegen3-Oct-12 21:41 
QuestionEquation on c# Pinmembersabuhi_asad3-Oct-12 20:41 
AnswerRe: Equation on c# PinmvpRichard MacCutchan3-Oct-12 21:41 
QuestionImplementing Private Inheritence PinmemberAmbiguousName3-Oct-12 19:07 
AnswerRe: Implementing Private Inheritence PinmemberPeter_in_27803-Oct-12 19:21 
GeneralRe: Implementing Private Inheritence PinmemberAmbiguousName3-Oct-12 19:33 
GeneralRe: Implementing Private Inheritence PinmemberPeter_in_27803-Oct-12 19:50 
AnswerRe: Implementing Private Inheritence PinprotectorPete O'Hanlon3-Oct-12 22:19 
AnswerRe: Implementing Private Inheritence Pinmemberjschell4-Oct-12 11:39 
Questionprocess being called by C# app Pinmemberrachel_m3-Oct-12 18:28 
AnswerRe: process being called by C# app PinmemberSmart Arab3-Oct-12 20:54 
QuestionFail Read Int64 value from binary file created by C++ Pinmemberkisetsu3-Oct-12 14:49 
QuestionThere is an error in XML document calling a PHP Webservice PinmemberRalphGielkens3-Oct-12 10:54 
QuestionPassing object[] Elements as Parameters to Invoke() [modified] Pinmemberezazazel3-Oct-12 7:04 
AnswerRe: Passing object[] Elements as Parameters to Invoke() PinmemberMatt T Heffron3-Oct-12 9:08 
GeneralRe: Passing object[] Elements as Parameters to Invoke() Pinmemberezazazel3-Oct-12 19:26 
QuestionC# calling executable Pinmemberdcof3-Oct-12 3:57 
AnswerRe: C# calling executable PinprotectorPete 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
Web01 | 2.8.140721.1 | Last Updated 31 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid