Exemple #1
0
        public static void RegisterAutoLoadPackages(this IPackageManager manager, IMafPackage package, Action loadAction)
        {
            if (package.LoadOption != PackageLoadOption.OnContextActivated)
            {
                return;
            }

            var attributes = package.GetType().GetAttributes <PackageAutoLoadAttribute>(true);

            foreach (var attribute in attributes)
            {
                var uiContext = UiContext.FromUiContextGuid(attribute.LoadGuid);
                if (Mapping.ContainsKey(attribute.LoadGuid))
                {
                    Mapping[attribute.LoadGuid].Add(package.Id);
                }
                else
                {
                    Mapping.Add(attribute.LoadGuid, new HashSet <Guid> {
                        package.Id
                    });
                }
                uiContext.WhenActivated(loadAction);
            }
        }
Exemple #2
0
        public void AddSinglePackage(IMafPackage package, bool initialize)
        {
            if (package.LoadOption != PackageLoadOption.Custom)
            {
                throw new InvalidOperationException("Only can load packages that have custom load option set");
            }
            var id = package.Id.ToString("N");

            if (Packages.ContainsKey(id))
            {
                throw new InvalidOperationException("Can not add duplicate Package");
            }
            Packages.Add(id, package);
            if (!initialize)
            {
                return;
            }
            LoadPackage(package.Id);
        }
Exemple #3
0
 private void LoadPackage(IMafPackage package)
 {
     ((Package)package).InitializeInternal();
 }