|
using System;
using System.Linq;
using System.Windows;
using System.Windows.Markup;
using System.Collections.Generic;
using UIAuthorization.Providers;
namespace UIAuthorization.Primitives
{
[MarkupExtensionReturnType(typeof(Visibility))]
public class AuthToVisibilityExtension : MarkupExtension
{
public string Operation { get; set; }
public AuthToVisibilityExtension()
{
Operation = String.Empty;
}
public AuthToVisibilityExtension(string operation)
{
Operation = operation;
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
if (String.IsNullOrEmpty(Operation))
return Visibility.Collapsed;
if (AuthProvider.Instance.CheckAccess(Operation))
return Visibility.Visible;
return Visibility.Collapsed;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Elvin Cheng is currently living in Woodlands, Singapore. He has been developing applications with the .NET Framework, using C# and ASP.NET since October 2002. Elvin specializes in building Real-time monitoring and tracking information system for Semi-conductor manufacturing industry. During his spare time, he enjoys reading books, watching movie and gym.