Re: Monad: Synthetic typing
- From: "Jeff Jones [MSFT]" <jeffjon@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 7 Apr 2006 13:23:50 -0700
The attached script was something I wrote a while back that sort of gave MSH
a type system. Note it isn't very feature rich. Just dot-source the script
into your shell and you will have the ability to create new types using
new-type, create new instances of a type using new-instance, get a type
definition using get-type, and see if an instance is of a certain type by
using is-type. The script uses the TypeNames property of the MshObject to
specify the type hierarchy. This allows you to specify formatting directives
using that type name.
This script uses hashtables to hold the property and method definitions of
the type because at the time I wrote the script MshObject didn't support
enough features. It would probably be possible to convert it to use
MshObject now. I haven't run the script in a while so you might have to fix
it up a bit. Unfortunately I only have current builds installs that have a
bunch of changes that would break you if I updated the script so I will have
to leave that to you.
I have also attached a script that uses the type system to define types and
another that tests the types that were defined. Just copy the scripts
removing the 1 from the extension.
--
Jeff Jones [MSFT]
Monad Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
"Alex K. Angelopoulos [MVP]" <a k a @ m v p s . o r g> wrote in message
news:egRouEZWGHA.4620@xxxxxxxxxxxxxxxxxxxxxxx
Jeff,
Could you elaborate on the type definition concept? Is it possible to do
from interactive MSH?
"Jeff Jones [MSFT]" <jeffjon@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:u1VTN8YWGHA.1192@xxxxxxxxxxxxxxxxxxxxxxx
I'm not exactly sure what you are asking... We have an MshObject which
wraps objects in the shell. It can also be used as a generic object
container (meaning that it is not wrapping a .NET, COM, or WMI object).
If you set the TypeNames property of the MshObject to a unique type name
and then use the types.mshxml file to declare members of the type you are
essentially creating a type without having to compile any code. You can
also dynamically define an instance adding properties and methods and
setting the TypeNames property. The TypeNames property is also used in
determining which formatting rules apply using the format.mshxml files.
This means that you can define your own type and specify how it gets
displayed without writing any compiled code.
You can find more information about MshObject in our team blog
(http://blogs.msdn.com/monad/archive/2005/08/25/456591.aspx) and in the
product documentation.
--
Jeff Jones [MSFT]
Monad Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no
rights.
<guzzeva@xxxxxxxxx> wrote in message
news:1144333339.513256.89580@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
Can anyone explain what synthetic typing is, in Monad? Can it be used
when passing objects by the pipeline?
Thanks,
Mira
begin 666 add-typesystem.msh1
M(PT*(R!'971S('1H92!T>7!E('=I=&@@=&AE(&UA=&-H:6YG(&YA;64-"B,@
M268@=&AE(&YA;64@:7,@;F]T('-P96-I9FEE9"P@86QL('1Y<&5S(&%R92!R
M971U<FYE9 T*(PT*9G5N8W1I;VX@9V5T+71Y<&4@*%MS=')I;F==)&YA;64I
M#0I[#0H@(" @:68@*%MS=')I;F==.CI)<TYU;&Q/<D5M<'1Y*"1N86UE*2D-
M"B @("![#0H@(" @(" @("1T>7!E<RY686QU97,-"B @("!]#0H@(" @96QS
M90T*(" @('L-"B @(" @(" @)'1Y<&5S6R1N86UE70T*(" @('T-"GT-"@T*
M(PT*(R!#<F5A=&5S(&$@;F5W('1Y<&4@9&5F:6YI=&EO;B!G:79E;B!T:&4@
M;F%M92P@=&AE(&)A<V4@8VQA<W,L(&%N9"!T:&4@;65M8F5R<PT*(PT*9G5N
M8W1I;VX@;F5W+71Y<&4@*%MS=')I;F==)&YA;64L(%M3>7-T96TN0V]L;&5C
M=&EO;G,N2&%S:'1A8FQE721M96UB97)S+"!;<W1R:6YG721D97)I=F5S1G)O
M;2D-"GL-"B @(" C(%9E<FEF>2!P87)A;65T97)S#0H-"B @("!I9B H6W-T
M<FEN9UTZ.DES3G5L;$]R16UP='DH)&YA;64I*0T*(" @('L-"B @(" @(" @
M=&AR;W<@(D$@;F%M92!M=7-T(&)E('-P96-I9FEE9"!F;W(@=&AE(&YE=R!T
M>7!E(@T*(" @('T-"@T*(" @(&EF("@A)&UE;6)E<G,I#0H@(" @>PT*(" @
M(" @("!T:')O=R B070@;&5A<W0@;VYE(&UE;6)E<B!M=7-T(&)E('-P96-I
M9FEE9"(-"B @("!]#0H-"B @(" C($5N<W5R92!T:&4@='EP92!D;V5S(&YO
M="!A;')E861Y(&5X:7-T#0H-"B @("!I9B H9V5T+71Y<&4@)&YA;64I#0H@
M(" @>PT*(" @(" @("!T:')O=R B02!T>7!E(&YA;65D("=[,'TG(&%L<F5A
M9'D@97AI<W1S+B(@+68@)&YA;64-"B @("!]#0H-"@T*(" @(&EF("@A6W-T
M<FEN9UTZ.DES3G5L;$]R16UP='DH)&1E<FEV97-&<F]M*2D-"B @("![#0H@
M(" @(" @(",@0VAE8VL@=&\@;6%K92!S=7)E('1H92!B87-E('1Y<&4@97AI
M<W1S#0H-"B @(" @(" @)&)A<V54>7!E1&5F(#T@9V5T+71Y<&4@)&1E<FEV
M97-&<F]M#0H@(" @(" @(&EF("@A)&)A<V54>7!E1&5F*0T*(" @(" @("![
M#0H@(" @(" @(" @("!T:')O=R B5&AE(&)A<V4@='EP92 G>S!])R!D;V5S
M(&YO="!E>&ES="XB("UF("1D97)I=F5S1G)O;0T*(" @(" @("!]#0H@(" @
M?0T*#0H@(" @(R!G96YE<F%T92!T:&4@;F5W('1Y<&4-"@T*(" @("1N97=4
M>7!E(#T@0'L@;F%M92 ]("1N86UE.R!B87-E(#T@)&)A<V54>7!E1&5F.R!M
M96UB97)S(#T@0'M]?0T*#0H@(" @(R!!9&0@=&AE(&UE;6)E<G,-"@T*(" @
M(&9O<F5A8V@@*"1M96UB97(@:6X@)&UE;6)E<G,N1V5T16YU;65R871O<B@I
M*0T*(" @('L-"B @(" @(" @)&YE=U1Y<&4N;65M8F5R<ULD;65M8F5R+DME
M>5T@/2 D;65M8F5R+E9A;'5E#0H@(" @?0T*#0H@(" @(R!S970@=&AE('1Y
M<&4@:6X@=&AE(&-A;&QE<G,@<V-O<&4-"B @(" D*&=E="UV87)I86)L92!T
M>7!E<R M<V-O<&4@,2 M=F%L=64I6R1N86UE72 ]("1N97=4>7!E#0I]#0H-
M"B,-"B,@0W)E871E<R!A(&YE=R!I;G-T86YC92!O9B!T:&4@<W!E8VEF:65D
M('1Y<&5S#0HC#0IF=6YC=&EO;B!N97<M:6YS=&%N8V4@*%MS=')I;F==)'1Y
M<&5.86UE*0T*>PT*(" @(",@5F5R:69Y('!A<F%M971E<G,-"@T*(" @(&EF
M("A;<W1R:6YG73HZ27-.=6QL3W)%;7!T>2@D='EP94YA;64I*0T*(" @('L-
M"B @(" @(" @=&AR;W<@(D$@='EP92!N86UE(&UU<W0@8F4@<W!E8VEF:65D
M('1O(&-R96%T92!A;B!I;G-T86YC92XB#0H@(" @?0T*#0H@(" @)'1Y<&4@
M/2!G970M='EP92 D='EP94YA;64-"B @("!I9B H(21T>7!E*0T*(" @('L-
M"B @(" @(" @=&AR;W<@(D$@='EP92!N86UE9" G>S!])R!C;W5L9"!N;W0@
M8F4@9F]U;F0N(B M9B D='EP94YA;64-"B @("!]#0H-"B @(" D='EP94YA
M;65(:65R87)C:'D@/2! *"D-"@T*(" @(",-"B @(" C($AE;'!E<B!F=6YC
M=&EO;B!T;R!R96-U<G-I=F5L>2!A9&0@;65M8F5R<R!F<F]M('1H92!B87-E
M(&-L87-S*&5S*2!T;R!T:&4@:6YS=&%N8V4@#0H@(" @(PT*(" @(&9U;F-T
M:6]N(&YE=RUI;G-T86YC94]F5'EP92 H6U-Y<W1E;2Y#;VQL96-T:6]N<RY(
M87-H=&%B;&5=)'1Y<&4I#0H@(" @>PT*(" @(" @(" C($%D9"!T:&4@='EP
M92!N86UE('1O('1H92!H:65R87)C:'D@8F5F;W)E(&1O:6YG('1H92!R96-U
M<G-I;VX@<V\@=&AA="!T:&4-"B @(" @(" @(R!S;R!T:&%T('1H92!M;W-T
M('-I9VYI9FEC86YT('1Y<&4@:7,@9FER<W0-"@T*(" @(" @(" D*&=E="UV
M87)I86)L92!T>7!E3F%M94AI97)A<F-H>2DN5F%L=64@*ST@)'1Y<&4N;F%M
M90T*#0H@(" @(" @(",@4F5C=7)S:79E;'D@8W)E871E(&%N(&EN<W1A;F-E
M(&]F('1H92!B87-E(&)E9F]R92!E>'1E;F1I;F<@:70@=VET:"!D97)I=F5D
M(&UE;6)E<G,-"@T*(" @(" @("!I9B H)'1Y<&4N8F%S92D-"B @(" @(" @
M>PT*(" @(" @(" @(" @)&EN<W1A;F-E(#T@;F5W+6EN<W1A;F-E3V94>7!E
M("1T>7!E+F)A<V4-"B @(" @(" @?0T*( T*(" @(" @("!I9B H(21I;G-T
M86YC92D-"B @(" @(" @>PT*(" @(" @(" @(" @)&EN<W1A;F-E(#T@0'M]
M#0H@(" @(" @('T-"@T*(" @(" @(" C($YO=R!A9&0@=&AE('1Y<&4@;65M
M8F5R<R!T;R!T:&4@:6YS=&%N8V4@#0H@(" @(" @(",@0GD@861D:6YG('1H
M92!B87-E(&UE;6)E<G,@9FER<W0L('=E(&5N<W5R92!D97)I=F5D(&UE;6)E
M<G,@8V%N#0H@(" @(" @(",@;W9E<G)I9&4@=&AE;0T*#0H@(" @(" @(&9O
M<F5A8V@@*"1M96UB97(@:6X@)'1Y<&4N;65M8F5R<RY'971%;G5M97)A=&]R
M*"DI#0H@(" @(" @('L-"B @(" @(" @(" @("1I;G-T86YC95LD;65M8F5R
M+DME>5T@/2 D;65M8F5R+E9A;'5E#0H@(" @(" @('T-"@T*(" @(" @("!R
M971U<FX@)&EN<W1A;F-E#0H@(" @?0T*#0H@(" @)&EN<W1A;F-E(#T@;F5W
M+6EN<W1A;F-E3V94>7!E("1T>7!E("1T>7!E3F%M94AI97)A<F-H>0T*(" @
M("1I;G-T86YC92Y4>7!E(#T@)'1Y<&4-"@T*(" @(",@3F]W('=R87 @=&AE
M(&EN<W1A;F-E(&EN(&%N($US:$]B:F5C="!A;F0@<V5T('1H92!T>7!E(&YA
M;64@:&EE<F%R8VAY#0H@(" @)'=R87!P961);G-T86YC92 ](%M!8W1I=F%T
M;W)=.CI#<F5A=&5);G-T86YC92A;4WES=&5M+DUA;F%G96UE;G0N075T;VUA
M=&EO;BY-<VA/8FIE8W1=+" D:6YS=&%N8V4I#0H-"B @(" C(%-E="!T:&4@
M5'EP94YA;65S(&%P<')O<')I871E;'D@9F]R('1H:7,@='EP90T*(" @("1W
M<F%P<&5D26YS=&%N8V4N;7-H;V)J96-T+E1Y<&5.86UE<RY#;&5A<B@I#0H@
M(" @9F]R96%C:" H)&YA;65);DAI97)A<F-H>2!I;B D='EP94YA;65(:65R
M87)C:'DI#0H@(" @>PT*(" @( DD=W)A<'!E9$EN<W1A;F-E+FUS:&]B:F5C
M="Y4>7!E3F%M97,N061D*"1N86UE26Y(:65R87)C:'DI#0H@(" @?0T*#0H@
M(" @<F5T=7)N("1W<F%P<&5D26YS=&%N8V4@(" @( T*?0T*#0IF=6YC=&EO
M;B!I<RUT>7!E("@D;V)J(#T@)"AT:')O=R B06X@;V)J96-T(&UU<W0@8F4@
M<W!E8VEF:65D(BDL("1I<W1Y<&4@/2 D*'1H<F]W(")!('1Y<&4@;75S="!B
M92!S<&5C:69I960B*2D-"GL-"B @("!F;W)E86-H("@D;F%M92!I;B D;V)J
M+FUS:&]B:F5C="Y4>7!E3F%M97,I#0H@(" @>PT*(" @(" @("!I9B H)&YA
M;64@+6EL:6ME("1I<W1Y<&4I#0H@(" @(" @('L-"B @(" @(" @(" @(')E
M='5R;B D=')U93L-"B @(" @(" @?0T*(" @('T-"B @("!R971U<FX@)&9A
M;'-E.PT*?0T*#0HC(%-E='5P('1H92!T>7!E<R!T86)L92!A;F0@8F%S92!O
M8FIE8W0@8VQA<W,-"@T*:68@*"$D='EP97,I#0I[#0H@(" @;F5W+79A<FEA
M8FQE("UN86UE('1Y<&5S("UV86QU92! >WT@+6]P=&EO;B B06QL4V-O<&4L
M0V]N<W1A;G0B#0H@(" @#0H@(" @(R!!9&0@82!B87-E(&]B:F5C="!T>7!E
M#0H@(" @;F5W+71Y<&4@4F]O=%1Y<&4@0'L@5'EP92 ]("1T:&ES('T-"B @
M(" D<V-R:7!T.E)O;W14>7!E(#T@9V5T+71Y<&4@4F]O=%1Y<&4-"GT-"@T*
"#0H`
`
end
begin 666 shapest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1T:&ES+FAE:6=H="!].R!#:7)C=6UF97)E;F-E(#T@
M>R R("H@*"1T:&ES+G=I9'1H("L@)'1H:7,N:&5I9VAT*2!]('T-"FYE=RUT
M>7!E('-Q=6%R92 M9&5R:79E<T9R;VT@<F5C=&%N9VQE($C:7)C;&4B#0H@(" @>PT*(" @(" @(" D8VER8VQE(#T@;F5W+6EN
M<W1A;F-E(&-I<F-L90T*#0H@(" @(" @(&EF("@A)&%R9W,@+6]R("1A<F=S
M+D-O=6YT("UL=" Q*0T*(" @(" @("![#0H@(" @(" @(" @("!T:')O=R B
M02!C:7)C;&4@<F5Q=6ER97,@=&AE(')A9&EU<R!B92!S<&5C:69I960@87,@
M86X@87)G=6UE;G0B#0H@(" @(" @('T-"B @(" @(" @)&-I<F-L92YR861I
M=7,@/2!;:6YT721A<F=S6S!=#0H))&-I<F-L90T*(" @(" @("!B<F5A:PT*
M(" @('T-"@T*(" @(")R96-T86YG;&4B#0H@(" @>PT*(" @(" @(" D<F5C
M=&%N9VQE(#T@;F5W+6EN<W1A;F-E(')E8W1A;F=L90T*(" @(" @(" -"B @
M(" @(" @:68@*"$D87)G<R M;W(@)&%R9W,N0V]U;G0@+6QT(#(I#0H@(" @
M(" @('L-"B @(" @(" @(" @('1H<F]W(")!(')E8W1A;F=L92!R97%U:7)E
M<R!T:&4@=VED=&@@86YD(&AE:6=H="!B92!S<&5C:69I960@87,@87)G=6UE
M;G1S(@T*(" @(" @("!]#0H-"B @(" @(" @)')E8W1A;F=L92YW:61T:" ]
M(%MI;G1=)&%R9W-;,%T-"B @(" @(" @)')E8W1A;F=L92YH96EG:'0@/2!;
M:6YT721A<F=S6S%=#0H@(" @(" @("1R96-T86YG;&4-"B @(" @(" @8G)E
M86L-"B @("!]#0H-"B @(" B<W%U87)E(@T*(" @('L-"B @(" @(" @)'-Q
M=6%R92 ](&YE=RUI;G-T86YC92!S<75A<F4-"B @(" @(" @:68@*"$D87)G
M<R M;W(@)&%R9W,N0V]U;G0@+6QT(#$I#0H@(" @(" @('L-"B @(" @(" @
M(" @('1H<F]W(")!('-Q=6%R92!R97%U:7)E<R!T:&4@961G92!S:7IE(&)E
M('-P96-I9FEE9"!A<R!A;B!A<F=U;65N="(-"B @(" @(" @?0T*(" @(" @
M(" D<W%U87)E+F5D9V4H6VEN=%TD87)G<ULP72D-"@DD<W%U87)E#0H@(" @
9(" @(&)R96%K#0H@(" @?0T*?0T*#0H-"@``
`
end
.
- References:
- Monad: Synthetic typing
- From: guzzeva
- Re: Monad: Synthetic typing
- From: Jeff Jones [MSFT]
- Monad: Synthetic typing
- Prev by Date: Re: [MSH] Script parameter without a value
- Next by Date: Re: [MSH] Script parameter without a value
- Previous by thread: Re: Monad: Synthetic typing
- Next by thread: Need help with pathname lengths please
- Index(es):
Loading