public virtual PresenterMetadata GetMetadata(Type view) { if (m_ViewMetadata.ContainsKey(view)) return m_ViewMetadata[view]; var metadata = new PresenterMetadata(); metadata.TypeName = view.FullName; var viewMetadataAttribute = Attribute.GetCustomAttribute(view, typeof(PresenterAttribute)) as PresenterAttribute; if (viewMetadataAttribute != null) { if (viewMetadataAttribute.Module != null) { var type = viewMetadataAttribute.Module.GetType(); var applicationMetadataAttribute = Attribute.GetCustomAttribute(type, typeof(ModuleCatalogAttribute)) as ModuleCatalogAttribute; if (applicationMetadataAttribute != null) metadata.Module.AppType = applicationMetadataAttribute.AppType; metadata.Module.Type = viewMetadataAttribute.Module; metadata.Module.TypeName = type.FullName + "." + viewMetadataAttribute.Module; } metadata.Uri = viewMetadataAttribute.Uri; metadata.Properties["Icon"] = viewMetadataAttribute.Icon; } m_ViewMetadata.Add(view, metadata); return metadata; }
/// <summary> /// 獲取權限 /// </summary> /// <param name="viewModel"></param> /// <param name="command"></param> /// <returns></returns> public static bool GetPermission(PresenterMetadata metadata, string command) { #if !Admin return true; #else var key = metadata.ModuleMetadata.Code.ToLower(); if (RuntimeContext.AppContext.User.Permission.ContainsKey(key)) return RuntimeContext.AppContext.User.Permission[key].Contains(command); return false; #endif }
public ViewModelBase() { CommandContext = new CommandContext(); if (Util.IsDesignMode) return; metadata = RuntimeContext.Service.GetObject<IMetadataDescriptor>().GetMetadata(GetType()); RuntimeContext.Service.L10N.PropertyChanged += (s, e) => { RefreshTitle(); }; //初始化視圖狀態 ViewStatus.StatusText = RuntimeContext.Service.L10N.GetText("Status.Ready"); CommandContext.Init(this); Initialize(); RefreshTitle(); }