Click here to Skip to main content
15,891,951 members
Home / Discussions / C#
   

C#

 
QuestionC# linq group by Pin
rachel_m4-Oct-12 17:43
rachel_m4-Oct-12 17:43 
AnswerRe: C# linq group by Pin
OriginalGriff4-Oct-12 23:19
mveOriginalGriff4-Oct-12 23:19 
GeneralRe: C# linq group by Pin
rachel_m5-Oct-12 2:48
rachel_m5-Oct-12 2:48 
GeneralRe: C# linq group by Pin
OriginalGriff5-Oct-12 3:29
mveOriginalGriff5-Oct-12 3:29 
QuestionCrystal Reports : Database Login Prompt Issue Pin
Quam Chang4-Oct-12 16:36
Quam Chang4-Oct-12 16:36 
AnswerRe: Crystal Reports : Database Login Prompt Issue Pin
AmbiguousName4-Oct-12 20:00
AmbiguousName4-Oct-12 20:00 
QuestionAggregate data into 5 min interval Pin
bad_kid4-Oct-12 11:59
bad_kid4-Oct-12 11:59 
QuestionC# linq Pin
rachel_m4-Oct-12 9:36
rachel_m4-Oct-12 9:36 
Question.exe Reference Problem - maybe Pin
dirsow4-Oct-12 7:52
dirsow4-Oct-12 7:52 
AnswerRe: .exe Reference Problem - maybe Pin
Eddy Vluggen4-Oct-12 9:01
professionalEddy Vluggen4-Oct-12 9:01 
GeneralRe: .exe Reference Problem - maybe Pin
dirsow4-Oct-12 9:27
dirsow4-Oct-12 9:27 
GeneralRe: .exe Reference Problem - maybe Pin
Eddy Vluggen4-Oct-12 9:34
professionalEddy Vluggen4-Oct-12 9:34 
GeneralRe: .exe Reference Problem - maybe Pin
dirsow4-Oct-12 9:41
dirsow4-Oct-12 9:41 
AnswerRe: .exe Reference Problem - maybe Pin
Bernhard Hiller4-Oct-12 21:00
Bernhard Hiller4-Oct-12 21:00 
Questionhow to setting Four tier application in my application? Pin
somasundarapandian4-Oct-12 4:28
somasundarapandian4-Oct-12 4:28 
AnswerRe: how to setting Four tier application in my application? Pin
Dave Kreskowiak4-Oct-12 6:45
mveDave Kreskowiak4-Oct-12 6:45 
QuestionRe: how to setting Four tier application in my application? Pin
Eddy Vluggen4-Oct-12 9:02
professionalEddy Vluggen4-Oct-12 9:02 
AnswerRe: how to setting Four tier application in my application? Pin
OriginalGriff4-Oct-12 9:34
mveOriginalGriff4-Oct-12 9:34 
Questionsqldatabaseconnectivity Pin
Member 94545634-Oct-12 4:05
Member 94545634-Oct-12 4:05 
AnswerRe: sqldatabaseconnectivity Pin
Ravi Bhavnani4-Oct-12 4:31
professionalRavi Bhavnani4-Oct-12 4:31 
AnswerRe: sqldatabaseconnectivity Pin
Richard MacCutchan4-Oct-12 4:32
mveRichard MacCutchan4-Oct-12 4:32 
AnswerRe: sqldatabaseconnectivity Pin
palakshamb4-Oct-12 23:28
palakshamb4-Oct-12 23:28 
QuestionCan an Attribute class find out, to which class it is actually attached? Pin
Andy4114-Oct-12 2:42
Andy4114-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
C#
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

C#
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.

C#
[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
mveDave 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
Andy4114-Oct-12 20:05 

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.