Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

How to refer to enums with a dot in the name?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 02-29-2008   #1 (permalink)
l0b0
Guest


 

How to refer to enums with a dot in the name?

Hi all,

I've been banging my head against the wall since I found that I can't
refer to an enum with a dot in the name just like I do with a normal
enum:

PS > [Microsoft.SharePoint.SPListTemplateType]::GenericList
GenericList
PS > [Microsoft.SharePoint.SPWeb.WebAnonymousState]::Enabled
Unable to find type [Microsoft.SharePoint.SPWeb.WebAnonymousState]:
make sure that the assembly containing this type is
loaded.
At line:1 char:47
+ [Microsoft.SharePoint.SPWeb.WebAnonymousState]: <<<< :Enabled

Anyone know how to do this?

My System SpecsSystem Spec
Old 02-29-2008   #2 (permalink)
Oisin (x0n) Grehan [MVP]
Guest


 

Re: How to refer to enums with a dot in the name?

On Feb 29, 10:27*am, l0b0 <victor.engm...@xxxxxx> wrote:
Quote:

> Hi all,
>
> I've been banging my head against the wall since I found that I can't
> refer to an enum with a dot in the name just like I do with a normal
> enum:
>
> PS > [Microsoft.SharePoint.SPListTemplateType]::GenericList
> GenericList
> PS > [Microsoft.SharePoint.SPWeb.WebAnonymousState]::Enabled
> Unable to find type [Microsoft.SharePoint.SPWeb.WebAnonymousState]:
> make sure that the assembly containing this type is
> *loaded.
> At line:1 char:47
> + [Microsoft.SharePoint.SPWeb.WebAnonymousState]: <<<< :Enabled
>
> Anyone know how to do this?
Hi,

What you're referring to is a nested type: a class/struct/enum that
has been defined within a class. There is a special syntax for this
in .NET which you can discover using some tricks:

PS C:\> [microsoft.sharepoint.spweb].GetNestedTypes()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False True WebAnonymousState System.Enum

So, lets get the full name of this nested type:

PS C:\> [microsoft.sharepoint.spweb].GetNestedTypes()[0].Fullname
Microsoft.SharePoint.SPWeb+WebAnonymousState

As you can see, it's not a dot, but rather a +. So:

PS C:\projects> [Microsoft.SharePoint.SPWeb+WebAnonymousState]

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False True WebAnonymousState System.Enum

Hope this helps,

- Oisin
http://www.nivot.org/


My System SpecsSystem Spec
Old 03-03-2008   #3 (permalink)
l0b0
Guest


 

Re: How to refer to enums with a dot in the name?

On Feb 29, 5:27 pm, "Oisin (x0n) Grehan [MVP]" <ois...@xxxxxx>
wrote:
Quote:

> On Feb 29, 10:27 am, l0b0 <victor.engm...@xxxxxx> wrote:
>
>
>
Quote:

> > Hi all,
>
Quote:

> > I've been banging my head against the wall since I found that I can't
> > refer to an enum with a dot in the name just like I do with a normal
> > enum:
>
Quote:

> > PS > [Microsoft.SharePoint.SPListTemplateType]::GenericList
> > GenericList
> > PS > [Microsoft.SharePoint.SPWeb.WebAnonymousState]::Enabled
> > Unable to find type [Microsoft.SharePoint.SPWeb.WebAnonymousState]:
> > make sure that the assembly containing this type is
> > loaded.
> > At line:1 char:47
> > + [Microsoft.SharePoint.SPWeb.WebAnonymousState]: <<<< :Enabled
>
Quote:

> > Anyone know how to do this?
>
> What you're referring to is a nested type: a class/struct/enum that
> has been defined within a class. There is a special syntax for this
> in .NET which you can discover using some tricks:
>
> PS C:\> [microsoft.sharepoint.spweb].GetNestedTypes()
>
> IsPublic IsSerial Name BaseType
> -------- -------- ---- --------
> False True WebAnonymousState System.Enum
>
> So, lets get the full name of this nested type:
>
> PS C:\> [microsoft.sharepoint.spweb].GetNestedTypes()[0].Fullname
> Microsoft.SharePoint.SPWeb+WebAnonymousState
>
> As you can see, it's not a dot, but rather a +. So:
>
> PS C:\projects> [Microsoft.SharePoint.SPWeb+WebAnonymousState]
>
> IsPublic IsSerial Name BaseType
> -------- -------- ---- --------
> False True WebAnonymousState System.Enum
Thanks a bunch!

--
Victor
My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
In any project, Can't we refer classes directly, (without addingphysically in the project)? Rachana .NET General 1 03-28-2008 04:31 PM
Using Enums Andy Webster PowerShell 1 01-29-2007 09:03 AM


Update your Vista Drivers Update Your Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008