RE: TypeConverter and arrays

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



You would have to use a separate setter method to turn your string into a
Permission[].

I almost sent code to do it in an implicit cast but then I remembered you
can't create an implicit cast from an object to an array of another object -
only to an instance of the other object.

Alternatively, you may make your Permission[] property into an Object[]
property instead. That would require casting each time you access it but
then you could pass the string as the value, convert it to an array of
Permissions, and set your private Permission[] variable to hold that array.

HTH

Dale

--
Dale Preston
MCAD C#
MCSE, MCDBA


"Rog" wrote:

Using asp.net1.1, I have a property on a control that is an enum. I use an
accessor and set it in HTML view. So:

public enum Permission
{
None = 0,
Admin = 1,
Member = 2, ...
}
...
public class Lock : System.Web.UI.Control
{
private Permission perm;

[Bindable(true),
Category("Security"),
DefaultValue("1")]
public Permission RequiredPermission
{
get
{
return perm;
}
set
{
perm = value;
}
}

Then in html view:
<cc1:Lock ... RequiredPermission="Admin" ... >

Now, I want to make the Permission property an array of permissions:

private Permission[] perm;

My question is, how can I implement this to allow me to still specify the
list of permissions in html view, like:
<cc1:Lock ... RequiredPermission="Admin,Member" ... >

I need to convert this list into an array, is there any way to do this
within an accessor? If I try something like this, I get a parser error,
saying it can't create an object of type Permission[] from its string
representation.

public Camelot.Permission[] RequiredPermission
{
get
{
return perm;
}
set
{
// break up comma delimited string in value, create an array of
permissions, assign it to perm
}
}

Thanks!
.



Relevant Pages

  • Re: TypeConverter and arrays
    ... You can add another property that accepts coma delimited strings, ... R> public enum Permission ... R> private Permission perm; ... I want to make the Permission property an array of permissions: ...
    (microsoft.public.dotnet.framework)
  • Re: Determine what security permissions are needed
    ... In order to override or call the underlying CreateParams implementation, ... your assembly will need SecurityPermission.UnmanagedCode permission. ... > at System.AppDomain.CreateComInstanceFrom(String assemblyFile, String ...
    (microsoft.public.dotnet.security)
  • Re: ADO connect string ignoring UID & PWD
    ... permission through membership of a group that has such permission. ... > connection use the security setting set up in the database thats opening. ... >> Brendan Reynolds (MVP) ... >>>> i tried to build connection string using udl file, ...
    (microsoft.public.access.modulesdaovba)
  • Re: Urgent SendMail Problem
    ... I looked for the dll for the object ... the "Users" group was not given permission to ... > at System.Web.Mail.CdoSysHelper.Send(String from, String to, String ... > String messageText) ...
    (microsoft.public.dotnet.framework.aspnet)
  • securing a web service
    ... I have taken the public key and amended by webservice as ... StrongNameIdentityPermissionAttribute ... permission of type ... dVersion, String& ...
    (microsoft.public.dotnet.security)