Esempio n. 1
0
        ///<summary>
        ///     MediaPermission ctor.
        ///</summary>
        public MediaPermission(MediaPermissionVideo permissionVideo)
        {
            VerifyMediaPermissionVideo(permissionVideo);
            InitDefaults();

            _mediaPermissionVideo = permissionVideo;
        }
Esempio n. 2
0
 internal static void VerifyMediaPermissionVideo(MediaPermissionVideo level)
 {
     if (level < MediaPermissionVideo.NoVideo || level > MediaPermissionVideo.AllVideo)
     {
         throw new ArgumentException(SR.Get(SRID.InvalidPermissionLevel));
     }
 }
Esempio n. 3
0
 ///<summary>
 ///     Private helper to compare the level of the 3 enum fields.
 ///</summary>
 private bool EqualsLevel(MediaPermissionAudio audioLevel,
                          MediaPermissionVideo videoLevel,
                          MediaPermissionImage imageLevel)
 {
     return((_mediaPermissionAudio == audioLevel) &&
            (_mediaPermissionVideo == videoLevel) &&
            (_mediaPermissionImage == imageLevel));
 }
Esempio n. 4
0
 internal static void DemandMediaPermission(MediaPermissionAudio audioPermissionToDemand,
                                            MediaPermissionVideo videoPermissionToDemand,
                                            MediaPermissionImage imagePermissionToDemand)
 {
     // Demand the appropriate permission
     (new MediaPermission(audioPermissionToDemand,
                          videoPermissionToDemand,
                          imagePermissionToDemand)).Demand();
 }
Esempio n. 5
0
        // </SnippetMediaPermissionAttribute9>
        public void Stub09()
        {
            // <SnippetMediaPermission3>
            MediaPermission mediaPermission = new MediaPermission(MediaPermissionVideo.AllVideo);
            // </SnippetMediaPermission3>

            // <SnippetMediaPermission8>
            MediaPermissionVideo mediaPermissionVideo = mediaPermission.Video;
            // </SnippetMediaPermission8>
        }
Esempio n. 6
0
        ///<summary>
        ///     MediaPermission ctor.
        ///</summary>
        public MediaPermission(MediaPermissionAudio permissionAudio,
                               MediaPermissionVideo permissionVideo,
                               MediaPermissionImage permissionImage)
        {
            VerifyMediaPermissionAudio(permissionAudio);
            VerifyMediaPermissionVideo(permissionVideo);
            VerifyMediaPermissionImage(permissionImage);

            _mediaPermissionAudio = permissionAudio;
            _mediaPermissionVideo = permissionVideo;
            _mediaPermissionImage = permissionImage;
        }
Esempio n. 7
0
 internal static bool CallerHasMediaPermission(MediaPermissionAudio audioPermissionToDemand,
                                               MediaPermissionVideo videoPermissionToDemand,
                                               MediaPermissionImage imagePermissionToDemand)
 {
     try
     {
         (new MediaPermission(audioPermissionToDemand, videoPermissionToDemand, imagePermissionToDemand)).Demand();
         return(true);
     }
     catch (SecurityException)
     {
         return(false);
     }
 }
Esempio n. 8
0
        ///<summary>
        ///     Return the intersection with the target
        ///</summary>
        public override IPermission Intersect(IPermission target)
        {
            if (target == null)
            {
                return(null);
            }

            MediaPermission operand = target as MediaPermission;

            if (operand != null)
            {
                //
                // Construct a permission that is the aggregate of the
                // least priveleged level of the 3 enums.
                //
                MediaPermissionAudio audioIntersectLevel = _mediaPermissionAudio < operand._mediaPermissionAudio
                                                                ? _mediaPermissionAudio : operand._mediaPermissionAudio;

                MediaPermissionVideo videoIntersectLevel = _mediaPermissionVideo < operand._mediaPermissionVideo
                                                                ? _mediaPermissionVideo : operand._mediaPermissionVideo;

                MediaPermissionImage imageIntersectLevel = _mediaPermissionImage < operand._mediaPermissionImage
                                                                ? _mediaPermissionImage : operand._mediaPermissionImage;

                if ((audioIntersectLevel == MediaPermissionAudio.NoAudio) &&
                    (videoIntersectLevel == MediaPermissionVideo.NoVideo) &&
                    (imageIntersectLevel == MediaPermissionImage.NoImage))

                {
                    return(null);
                }
                else
                {
                    return(new MediaPermission(audioIntersectLevel, videoIntersectLevel, imageIntersectLevel));
                }
            }
            else
            {
                throw new ArgumentException(SR.Get(SRID.TargetNotMediaPermissionLevel));
            }
        }
Esempio n. 9
0
		public MediaPermission (MediaPermissionVideo permissionVideo)
		{
			throw new NotImplementedException ();
		}
 ///<summary> 
 ///     Private helper to compare the level of the 3 enum fields. 
 ///</summary> 
 private bool EqualsLevel( MediaPermissionAudio audioLevel, 
                           MediaPermissionVideo videoLevel, 
                           MediaPermissionImage imageLevel ) 
 {                                  
     return ( ( _mediaPermissionAudio == audioLevel ) && 
               ( _mediaPermissionVideo == videoLevel ) && 
               ( _mediaPermissionImage == imageLevel ) ) ;
 }
 ///<summary> 
 ///     MediaPermission ctor. 
 ///</summary>         
 public MediaPermission(MediaPermissionAudio permissionAudio, 
                               MediaPermissionVideo permissionVideo, 
                               MediaPermissionImage permissionImage )
 {
     VerifyMediaPermissionAudio( permissionAudio );
     VerifyMediaPermissionVideo( permissionVideo );
     VerifyMediaPermissionImage( permissionImage );
     
     _mediaPermissionAudio = permissionAudio ; 
     _mediaPermissionVideo = permissionVideo ; 
     _mediaPermissionImage = permissionImage ;             
 }
 internal static void VerifyMediaPermissionVideo(MediaPermissionVideo level) 
 {
     if (level < MediaPermissionVideo.NoVideo || level > MediaPermissionVideo.AllVideo )
     {
         throw new ArgumentException(SR.Get(SRID.InvalidPermissionLevel));
     }
 }
 internal static bool CallerHasMediaPermission(MediaPermissionAudio audioPermissionToDemand,
                                               MediaPermissionVideo videoPermissionToDemand,
                                               MediaPermissionImage imagePermissionToDemand)
 {
     try
     {
         (new MediaPermission(audioPermissionToDemand,videoPermissionToDemand,imagePermissionToDemand)).Demand();
         return true;
     }
     catch(SecurityException)
     {
             return false;
     }
 }
 ///<summary> 
 ///     MediaPermission ctor. 
 ///</summary>         
 public MediaPermission(MediaPermissionVideo permissionVideo )
 {
     VerifyMediaPermissionVideo( permissionVideo ) ; 
     InitDefaults(); 
     
     _mediaPermissionVideo = permissionVideo ; 
 }
 public MediaPermission(MediaPermissionVideo permissionVideo)
 {
 }
Esempio n. 16
0
 internal static void DemandMediaPermission(MediaPermissionAudio audioPermissionToDemand, MediaPermissionVideo videoPermissionToDemand, MediaPermissionImage imagePermissionToDemand)
 {
     new MediaPermission(audioPermissionToDemand, videoPermissionToDemand, imagePermissionToDemand).Demand();
 }
Esempio n. 17
0
 public MediaPermission(MediaPermissionAudio permissionAudio, MediaPermissionVideo permissionVideo, MediaPermissionImage permissionImage)
 {
     throw new NotImplementedException();
 }
Esempio n. 18
0
 public MediaPermission(MediaPermissionVideo permissionVideo)
 {
     throw new NotImplementedException();
 }
 public MediaPermission(MediaPermissionAudio permissionAudio,
                        MediaPermissionVideo permissionVideo,
                        MediaPermissionImage permissionImage)
 {
 }
Esempio n. 20
0
		public MediaPermission (MediaPermissionAudio permissionAudio, MediaPermissionVideo permissionVideo, MediaPermissionImage permissionImage)
		{
			throw new NotImplementedException ();
		}
 internal static void DemandMediaPermission(MediaPermissionAudio audioPermissionToDemand,
                                            MediaPermissionVideo videoPermissionToDemand,
                                            MediaPermissionImage imagePermissionToDemand)
 {
     // Demand the appropriate permission
    (new MediaPermission(audioPermissionToDemand,
                         videoPermissionToDemand,
                         imagePermissionToDemand )).Demand();
 }