Hi everyone,
I'm developing a multi-language web site. My solution for displaying
multilanguage texts, based on following *LocalizedDisplayAttribute* class.
I would like to inject some dependency to this class.But the class
is instantiated by .Net Framework. How container inject dependency without
using service locator?
Here is my code block
[AttributeUsage(AttributeTargets.All)]
public class LocalizedDisplayAttribute : DisplayNameAttribute
{
public MultilanguageKeys Key { get; set; }
public IMultilanguageManager MultilanguageManager { get; set; }
public LocalizedDisplayAttribute(IMultilanguageManager
multilanguageManager)
{
this.MultilanguageManager = multilanguageManager;
}
public override string DisplayName
{
get
{
return GetCustomAttribute(Key);
}
}
public string GetCustomAttribute(MultilanguageKeys key)
{
int multiLanguageId = 3;
MultiLanguageDictionaryInfo multiLanguageDictionary =
MultilanguageManager.DictionaryList()
.Where(t =>
t.Key == key.ToString())
.Where(t =>
t.MultilanguageId == multiLanguageId)
.FirstOrDefault();
return multiLanguageDictionary.Value;
}
}
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/castle-project-users/-/tsqCfdyDyqwJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.