Ejemplo n.º 1
0
        ///<summary>
        ///     MediaPermission ctor.
        ///</summary>
        public MediaPermission(MediaPermissionImage permissionImage)
        {
            VerifyMediaPermissionImage(permissionImage);
            InitDefaults();

            _mediaPermissionImage = permissionImage;
        }
Ejemplo n.º 2
0
 internal static void VerifyMediaPermissionImage(MediaPermissionImage level)
 {
     if (level < MediaPermissionImage.NoImage || level > MediaPermissionImage.AllImage)
     {
         throw new ArgumentException(SR.Get(SRID.InvalidPermissionLevel));
     }
 }
Ejemplo 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));
 }
Ejemplo n.º 4
0
 internal static void DemandMediaPermission(MediaPermissionAudio audioPermissionToDemand,
                                            MediaPermissionVideo videoPermissionToDemand,
                                            MediaPermissionImage imagePermissionToDemand)
 {
     // Demand the appropriate permission
     (new MediaPermission(audioPermissionToDemand,
                          videoPermissionToDemand,
                          imagePermissionToDemand)).Demand();
 }
Ejemplo n.º 5
0
        // </SnippetMediaPermissionAttribute6>
        public void Stub06()
        {
            // <SnippetMediaPermission2>
            MediaPermission mediaPermission = new MediaPermission(MediaPermissionImage.NoImage);
            // </SnippetMediaPermission2>

            // <SnippetMediaPermission7>
            MediaPermissionImage mediaPermissionImage = mediaPermission.Image;
            // </SnippetMediaPermission7>
        }
Ejemplo 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;
        }
Ejemplo 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);
     }
 }
Ejemplo 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));
            }
        }
Ejemplo n.º 9
0
		public MediaPermission (MediaPermissionImage permissionImage)
		{
			throw new NotImplementedException ();
		}
Ejemplo n.º 10
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 ) ) ;
 }
Ejemplo n.º 11
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 ;             
 }
Ejemplo n.º 12
0
 internal static void VerifyMediaPermissionImage(MediaPermissionImage level) 
 {
     if (level < MediaPermissionImage.NoImage || level > MediaPermissionImage.AllImage )
     {
         throw new ArgumentException(SR.Get(SRID.InvalidPermissionLevel));
     }
 }
Ejemplo n.º 13
0
 internal static bool CallerHasMediaPermission(MediaPermissionAudio audioPermissionToDemand,
                                               MediaPermissionVideo videoPermissionToDemand,
                                               MediaPermissionImage imagePermissionToDemand)
 {
     try
     {
         (new MediaPermission(audioPermissionToDemand,videoPermissionToDemand,imagePermissionToDemand)).Demand();
         return true;
     }
     catch(SecurityException)
     {
             return false;
     }
 }
Ejemplo n.º 14
0
 ///<summary> 
 ///     MediaPermission ctor. 
 ///</summary>         
 public MediaPermission(MediaPermissionImage permissionImage )
 {
     VerifyMediaPermissionImage( permissionImage );         
     InitDefaults(); 
     
     _mediaPermissionImage = permissionImage ; 
 }
 public MediaPermission(MediaPermissionImage permissionImage)
 {
 }
Ejemplo n.º 16
0
 internal static void DemandMediaPermission(MediaPermissionAudio audioPermissionToDemand, MediaPermissionVideo videoPermissionToDemand, MediaPermissionImage imagePermissionToDemand)
 {
     new MediaPermission(audioPermissionToDemand, videoPermissionToDemand, imagePermissionToDemand).Demand();
 }
Ejemplo n.º 17
0
 public MediaPermission(MediaPermissionAudio permissionAudio, MediaPermissionVideo permissionVideo, MediaPermissionImage permissionImage)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 18
0
 public MediaPermission(MediaPermissionImage permissionImage)
 {
     throw new NotImplementedException();
 }
 public MediaPermission(MediaPermissionAudio permissionAudio,
                        MediaPermissionVideo permissionVideo,
                        MediaPermissionImage permissionImage)
 {
 }
Ejemplo n.º 20
0
		public MediaPermission (MediaPermissionAudio permissionAudio, MediaPermissionVideo permissionVideo, MediaPermissionImage permissionImage)
		{
			throw new NotImplementedException ();
		}
Ejemplo n.º 21
0
 internal static void DemandMediaPermission(MediaPermissionAudio audioPermissionToDemand,
                                            MediaPermissionVideo videoPermissionToDemand,
                                            MediaPermissionImage imagePermissionToDemand)
 {
     // Demand the appropriate permission
    (new MediaPermission(audioPermissionToDemand,
                         videoPermissionToDemand,
                         imagePermissionToDemand )).Demand();
 }