public ApplicationPrincipal(IApplicationIdentity identity, string[] roles, string[] permissions)
        {
            Contract.Assert(identity != null);
            Contract.Assert(roles != null);
            Contract.Assert(permissions != null);

            this.Identity = identity;
            this.roles = roles;
            this.permissions = permissions;
        }
Exemplo n.º 2
0
        public ApplicationPrincipal(IApplicationIdentity identity, string[] roles, string[] permissions)
        {
            Contract.Assert(identity != null);
            Contract.Assert(roles != null);
            Contract.Assert(permissions != null);

            this.Identity    = identity;
            this.roles       = roles;
            this.permissions = permissions;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the model associated with the specified framework element.
        /// This will walk up the parent hierarchy to find a model if the specified
        /// element does not have a model.
        /// </summary>
        /// <param name="element">The element to lookup.</param>
        /// <returns>The associated model object if any.</returns>
        public static object GetModel(FrameworkElement element)
        {
            object model = element.GetValue(ModelProperty);

            if (model == null)
            {
                element = element.GetParentVisual();
                while (element != null)
                {
                    model = element.GetValue(ModelProperty);
                    if (model != null)
                    {
                        break;
                    }

                    element = element.GetParentVisual();
                }
            }

            if (model == null)
            {
                IApplicationIdentity appID = null;

                IServiceProvider sp = Application.Current as IServiceProvider;
                if (sp != null)
                {
                    appID = (IApplicationIdentity)sp.GetService(typeof(IApplicationIdentity));
                }

                if (appID != null)
                {
                    model = appID.Model;
                }
            }

            return(model);
        }