Message 1 of 3
Assembly attributes
Not applicable
08-31-2005
08:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is there a reason why the interop assembly-level attributes
(e.g., ExtensionApplicationAttribute, CommandClassAttribute)
have multiple overloaded constructors? Is there a limitation
on the ability of some languages to use named parameters?
I have a tool that is similar to the AcadAppInfo ARX class
which registers a managed app in the registry for automatic
or demand-loading. The main difference is that my managed
counterpart uses reflection to find the commands defined in
the assembly, and adds their names to the Commands subkey,
and only requires the developer to declare a single, assembly-
level attribute, like this:
[assembly: ExtensionApplicationInfo(
Description = "My Extension Application",
Hive = RegistryHive.LocalMachine,
Guid = "{5B1456C3-811B-40a1-B6EC-E74145A17676}",
LoadReasons = ApplicationLoadReasons.OnCommandInvocation,
IgnoreVersion = false,
Silent = false,
SkipHKLM = falkse)]
I really don't want to create 8 overloaded constructors for this
attribute, if I can avoid it. Is there some reason why I should?
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple=false)]
public class ExtensionApplicationInfoAttribute : System.Attribute
{
public ExtensionApplicationInfoAttribute()
{
}
public string Description = "";
public RegistryHive Hive = RegistryHive.LocalMachine;
public string Guid = "";
public ApplicationLoadReasons LoadReasons =
(ApplicationLoadReasons) 0;
public bool IgnoreVersion = false;
public bool SkipHKLM = false;
public bool Silent = false;
internal bool Register(ExtensionAppInfo info)
{
if( Guid != string.Empty )
{
try
{
info.Guid = new Guid(Guid);
}
catch
{
throw new InvalidOperationException("Invalid GUID string");
}
}
if( Description != string.Empty )
info.Description = Description;
info.Hive = Hive;
if( LoadReasons != 0 )
info.LoadReasons = LoadReasons;
info.SkipHKLM = SkipHKLM;
info.IgnoreVersion = IgnoreVersion;
info.ShowStatusMessages = ! Silent;
return info.Register();
}
}
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
(e.g., ExtensionApplicationAttribute, CommandClassAttribute)
have multiple overloaded constructors? Is there a limitation
on the ability of some languages to use named parameters?
I have a tool that is similar to the AcadAppInfo ARX class
which registers a managed app in the registry for automatic
or demand-loading. The main difference is that my managed
counterpart uses reflection to find the commands defined in
the assembly, and adds their names to the Commands subkey,
and only requires the developer to declare a single, assembly-
level attribute, like this:
[assembly: ExtensionApplicationInfo(
Description = "My Extension Application",
Hive = RegistryHive.LocalMachine,
Guid = "{5B1456C3-811B-40a1-B6EC-E74145A17676}",
LoadReasons = ApplicationLoadReasons.OnCommandInvocation,
IgnoreVersion = false,
Silent = false,
SkipHKLM = falkse)]
I really don't want to create 8 overloaded constructors for this
attribute, if I can avoid it. Is there some reason why I should?
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple=false)]
public class ExtensionApplicationInfoAttribute : System.Attribute
{
public ExtensionApplicationInfoAttribute()
{
}
public string Description = "";
public RegistryHive Hive = RegistryHive.LocalMachine;
public string Guid = "";
public ApplicationLoadReasons LoadReasons =
(ApplicationLoadReasons) 0;
public bool IgnoreVersion = false;
public bool SkipHKLM = false;
public bool Silent = false;
internal bool Register(ExtensionAppInfo info)
{
if( Guid != string.Empty )
{
try
{
info.Guid = new Guid(Guid);
}
catch
{
throw new InvalidOperationException("Invalid GUID string");
}
}
if( Description != string.Empty )
info.Description = Description;
info.Hive = Hive;
if( LoadReasons != 0 )
info.LoadReasons = LoadReasons;
info.SkipHKLM = SkipHKLM;
info.IgnoreVersion = IgnoreVersion;
info.ShowStatusMessages = ! Silent;
return info.Register();
}
}
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com