File "Microsoft.PowerShell.ODataAdapter.ps1"
Full Path: C:/Windows/System32/WindowsPowerShell/v1.0/Modules/Microsoft.PowerShell.ODataUtils/Microsoft.PowerShell.ODataAdapter.ps1
File size: 167.09 KB
MIME-type: text/plain
Charset: 8 bit
I m p o r t - L o c a l i z e d D a t a L o c a l i z e d D a t a - F i l e N a m e M i c r o s o f t . P o w e r S h e l l . O D a t a U t i l s S t r i n g s . p s d 1
# A d d . N E T c l a s s e s u s e d b y t h e m o d u l e
A d d - T y p e - T y p e D e f i n i t i o n $ g l o b a l : B a s e C l a s s D e f i n i t i o n s
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# G e n e r a t e s P o w e r S h e l l m o d u l e c o n t a i n i n g c l i e n t s i d e
# p r o x y c m d l e t s t h a t c a n b e u s e d t o i n t e r a c t w i t h a n
# O D a t a b a s e d s e r v e r s i d e e n d p o i n t .
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
f u n c t i o n E x p o r t O D a t a E n d p o i n t P r o x y
{
p a r a m
(
[ s t r i n g ] $ U r i ,
[ s t r i n g ] $ O u t p u t M o d u l e ,
[ s t r i n g ] $ M e t a d a t a U r i ,
[ P S C r e d e n t i a l ] $ C r e d e n t i a l ,
[ s t r i n g ] $ C r e a t e R e q u e s t M e t h o d ,
[ s t r i n g ] $ U p d a t e R e q u e s t M e t h o d ,
[ s t r i n g ] $ C m d l e t A d a p t e r ,
[ H a s h t a b l e ] $ R e s o u r c e N a m e M a p p i n g ,
[ s w i t c h ] $ F o r c e ,
[ H a s h t a b l e ] $ C u s t o m D a t a ,
[ s w i t c h ] $ A l l o w C l o b b e r ,
[ s w i t c h ] $ A l l o w U n s e c u r e C o n n e c t i o n ,
[ H a s h t a b l e ] $ H e a d e r s ,
[ s t r i n g ] $ P r o g r e s s B a r S t a t u s ,
[ S y s t e m . M a n a g e m e n t . A u t o m a t i o n . P S C m d l e t ] $ P S C m d l e t
)
[ x m l ] $ m e t a d a t a X M L = G e t M e t a D a t a $ M e t a d a t a U r i $ P S C m d l e t $ C r e d e n t i a l $ H e a d e r s
[ O D a t a U t i l s . M e t a d a t a ] $ m e t a D a t a = P a r s e M e t a d a t a $ m e t a d a t a X M L $ M e t a d a t a U r i $ C m d l e t A d a p t e r $ P S C m d l e t
V e r i f y M e t a D a t a $ M e t a d a t a U r i $ m e t a D a t a $ A l l o w C l o b b e r . I s P r e s e n t $ P S C m d l e t $ p r o g r e s s B a r S t a t u s $ C m d l e t A d a p t e r $ C u s t o m D a t a $ R e s o u r c e N a m e M a p p i n g
G e n e r a t e C l i e n t S i d e P r o x y M o d u l e $ m e t a D a t a $ M e t a d a t a U r i $ U r i $ O u t p u t M o d u l e $ C r e a t e R e q u e s t M e t h o d $ U p d a t e R e q u e s t M e t h o d $ C m d l e t A d a p t e r $ R e s o u r c e N a m e M a p p i n g $ C u s t o m D a t a $ P r o g r e s s B a r S t a t u s $ P S C m d l e t
}
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# P a r s e M e t a D a t a i s a h e l p e r f u n c t i o n u s e d t o p a r s e t h e
# m e t a d a t a t o c o n v e r t i t i n t o a n o b j e c t s t r u c t u r e f o r
# f u r t h e r c o n s u m p t i o n d u r i n g p r o x y g e n e r a t i o n .
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
f u n c t i o n P a r s e M e t a D a t a
{
p a r a m
(
[ x m l ] $ m e t a d a t a X m l ,
[ s t r i n g ] $ m e t a D a t a U r i ,
[ s t r i n g ] $ c m d l e t A d a p t e r ,
[ S y s t e m . M a n a g e m e n t . A u t o m a t i o n . P S C m d l e t ] $ c a l l e r P S C m d l e t
)
# $ m e t a D a t a U r i i s a l r e a d y v a l i d a t e d a t t h e c m d l e t l a y e r .
i f ( $ c a l l e r P S C m d l e t - e q $ n u l l ) { t h r o w ( $ L o c a l i z e d D a t a . A r g u e m e n t N u l l E r r o r - f "