PackageStore

We found 10 examples in language CSharp for this search. You will see 47 fragments of code.

		protected override void Dispose (bool disposing)
		{
			imageLoader.Loaded -= ImageLoaded;
			imageLoader.Dispose ();

			RemoveSelectedPackagePropertyChangedEventHandler ();
			viewModel.PropertyChanged -= ViewModelPropertyChanged;
			viewModel.Dispose ();
			DisposeExistingTimer ();
			DisposePopulatePackageVersionsTimer ();
			packageStore.Clear ();
			viewModel = null;
			base.Dispose (disposing);
		}

		void InitializeListView ()
		{
			packageStore = new ListStore (packageHasBackgroundColorField, packageCheckBoxAlphaField, packageImageField, packageViewModelField);
			packagesListView.DataSource = packageStore;

			AddPackageCellViewToListView ();

			packagesListView.SelectionChanged += PackagesListViewSelectionChanged;
			packagesListView.RowActivated += PackagesListRowActivated;
			packagesListView.VerticalScrollControl.ValueChanged += PackagesListViewScrollValueChanged;
		}

		PackageSearchResultViewModel GetSelectedPackageViewModel ()
		{
			if (packagesListView.SelectedRow != -1) {
				return packageStore.GetValue (packagesListView.SelectedRow, packageViewModelField);
			}
			return null;
		}

		void ClearPackages ()
		{
			packageStore.Clear ();
			ResetPackagesListViewScroll ();
			UpdatePackageListViewSelectionColor ();
			ShowLoadingMessage ();
			ShrinkImageCache ();
			DisposePopulatePackageVersionsTimer ();
		}

		void AppendPackageToListView (PackageSearchResultViewModel packageViewModel)
		{
			int row = packageStore.AddRow ();
			packageStore.SetValue (row, packageHasBackgroundColorField, IsOddRow (row));
			packageStore.SetValue (row, packageCheckBoxAlphaField, GetPackageCheckBoxAlpha ());
			packageStore.SetValue (row, packageViewModelField, packageViewModel);
		}

		void ImageLoaded (object sender, ImageLoadedEventArgs e)
		{
			if (!e.HasError) {
				int row = (int)e.State;
				if (IsValidRowAndUrl (row, e.Uri)) {
					packageStore.SetValue (row, packageImageField, e.Image);
				}
			}
		}


        #region public Methods

        // 
        /// <summary>
        /// Retrieves a package from the store for the given Uri.
        /// </summary>
        /// <param name="uri">key uri</param>
        /// <returns>Package</returns>
        /// <permission cref="EnvironmentPermission"></permission>
        /// <remarks>
        /// </remarks>
        ///<SecurityNote>
        /// Demands EnvironmentPermission() if package is custom type of Package.
        /// This prevents Partially Trusted callers from performing this operation on custom type of Package.
        ///</SecurityNote>
        public static Package GetPackage(Uri uri)
        {
            ValidatePackageUri(uri);
  
            lock (_globalLock)
            {
                Package package = null;

                if (_packages != null && _packages.Contains(uri))
                {
                    package = (Package) _packages[uri];
                    DemandSecurityPermissionIfCustomPackage(package);
                }
                
                return package;
            }
        }

        /// <summary>
        /// Adds a uri, package pair to the package store.
        /// </summary>
        /// <param name="uri">key uri</param>
        /// <param name="package">package</param>
        /// <permission cref="EnvironmentPermission"></permission>
        /// <remarks>
        /// If a package with the uri is already in the store,it throws an exception.
        /// The package will not be automatically replaced within the store.
        /// </remarks>
        ///<SecurityNote>
        /// Demands EnvironmentPermission() if package is custom type of Package.
        /// This prevents Partially Trusted callers from performing this operation. However, Partially Trusted callers can still
        /// add well-known platform Package type (ZipPackage) to PackageStore.
        /// the application's PackageStore.
        ///</SecurityNote>
        public static void AddPackage(Uri uri, Package package)
        {
            // Allow well known platform Package to be added into PackageStore under Partial Trust.
            // Otherwise, demand Environment Permission to make sure only Full Trust app can add a custom Package
            DemandSecurityPermissionIfCustomPackage(package);

            ValidatePackageUri(uri);

            // There are well-known package types that are only for internal use (for resource loading)
            //  (i.e. ResourceContainer - "application://" and SiteOriginContainer - "siteoforigin://"
            // Adding packages with such key uri will have no effect on PackWebRequest since
            //  they cannot be overriden. So, calling this method with such key Uris should be prevented 
            //  However, uri.Equal cannot be used here since the key Uris are used as a pack Uri form and
            //  only PackUriHelper.ComparePackUri can do the proper comparison of pack Uris.

            Uri packUri = PackUriHelper.Create(uri);
       
            if (PackUriHelper.ComparePackUri(packUri, BaseUriHelper.PackAppBaseUri) == 0
                    || PackUriHelper.ComparePackUri(packUri, BaseUriHelper.SiteOfOriginBaseUri) == 0)
            {
                throw new ArgumentException(SR.Get(SRID.NotAllowedPackageUri), "uri");
            }

            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            lock (_globalLock)
            {
                if (_packages == null)
                {
                    _packages = new HybridDictionary(2);
                }

                if (_packages.Contains(uri))
                {
                    throw new InvalidOperationException(SR.Get(SRID.PackageAlreadyExists));
                }
                
                _packages.Add(uri, package);
            }
        }

        /// <summary>
        /// Removes a uri, package pair from the package store.
        /// </summary>
        /// <param name="uri">key uri</param>
        /// <permission cref="EnvironmentPermission"></permission>
        /// <remarks>
        /// </remarks>
        ///<SecurityNote>
        /// Demands EnvironmentPermission() if package is custom type of Package.
        /// This prevents Partially Trusted callers from performing this operation on custom type of Package.
        ///</SecurityNote>
        public static void RemovePackage(Uri uri)
        {
            ValidatePackageUri(uri);

            lock (_globalLock)
            {
                if (_packages != null)
                {
                    DemandSecurityPermissionIfCustomPackage((Package) _packages[uri]);

                    // If the key doesn't exist, it is no op
                    _packages.Remove(uri);
                }
            }
        }

        #endregion Public Methods

        #region Private Methods

        private static void ValidatePackageUri(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            if (!uri.IsAbsoluteUri)
            {
                throw new ArgumentException(SR.Get(SRID.UriMustBeAbsolute), "uri");
            }
        }

        private static void DemandSecurityPermissionIfCustomPackage(Package package)
        {
            // Although ZipPackage is sealed and cannot be subclassed, we shouldn't depend on
            //  the "sealedness" of ZipPackage. Checking the object type is more reliable way
            //  than using "as" or "is" operator.
            if (package != null && package.GetType() != typeof(ZipPackage))
            {
                SecurityHelper.DemandEnvironmentPermission();
            }
        }


        #region public Methods

        // 
        /// <summary>
        /// Retrieves a package from the store for the given Uri.
        /// </summary>
        /// <param name="uri">key uri</param>
        /// <returns>Package</returns>
        /// <permission cref="EnvironmentPermission"></permission>
        /// <remarks>
        /// </remarks>
        ///<SecurityNote>
        /// Demands EnvironmentPermission() if package is custom type of Package.
        /// This prevents Partially Trusted callers from performing this operation on custom type of Package.
        ///</SecurityNote>
        public static Package GetPackage(Uri uri)
        {
            ValidatePackageUri(uri);
  
            lock (_globalLock)
            {
                Package package = null;

                if (_packages != null && _packages.Contains(uri))
                {
                    package = (Package) _packages[uri];
                    DemandSecurityPermissionIfCustomPackage(package);
                }
                
                return package;
            }
        }

        /// <summary>
        /// Adds a uri, package pair to the package store.
        /// </summary>
        /// <param name="uri">key uri</param>
        /// <param name="package">package</param>
        /// <permission cref="EnvironmentPermission"></permission>
        /// <remarks>
        /// If a package with the uri is already in the store,it throws an exception.
        /// The package will not be automatically replaced within the store.
        /// </remarks>
        ///<SecurityNote>
        /// Demands EnvironmentPermission() if package is custom type of Package.
        /// This prevents Partially Trusted callers from performing this operation. However, Partially Trusted callers can still
        /// add well-known platform Package type (ZipPackage) to PackageStore.
        /// the application's PackageStore.
        ///</SecurityNote>
        public static void AddPackage(Uri uri, Package package)
        {
            // Allow well known platform Package to be added into PackageStore under Partial Trust.
            // Otherwise, demand Environment Permission to make sure only Full Trust app can add a custom Package
            DemandSecurityPermissionIfCustomPackage(package);

            ValidatePackageUri(uri);

            // There are well-known package types that are only for internal use (for resource loading)
            //  (i.e. ResourceContainer - "application://" and SiteOriginContainer - "siteoforigin://"
            // Adding packages with such key uri will have no effect on PackWebRequest since
            //  they cannot be overriden. So, calling this method with such key Uris should be prevented 
            //  However, uri.Equal cannot be used here since the key Uris are used as a pack Uri form and
            //  only PackUriHelper.ComparePackUri can do the proper comparison of pack Uris.

            Uri packUri = PackUriHelper.Create(uri);
       
            if (PackUriHelper.ComparePackUri(packUri, BaseUriHelper.PackAppBaseUri) == 0
                    || PackUriHelper.ComparePackUri(packUri, BaseUriHelper.SiteOfOriginBaseUri) == 0)
            {
                throw new ArgumentException(SR.Get(SRID.NotAllowedPackageUri), "uri");
            }

            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            lock (_globalLock)
            {
                if (_packages == null)
                {
                    _packages = new HybridDictionary(2);
                }

                if (_packages.Contains(uri))
                {
                    throw new InvalidOperationException(SR.Get(SRID.PackageAlreadyExists));
                }
                
                _packages.Add(uri, package);
            }
        }

        /// <summary>
        /// Removes a uri, package pair from the package store.
        /// </summary>
        /// <param name="uri">key uri</param>
        /// <permission cref="EnvironmentPermission"></permission>
        /// <remarks>
        /// </remarks>
        ///<SecurityNote>
        /// Demands EnvironmentPermission() if package is custom type of Package.
        /// This prevents Partially Trusted callers from performing this operation on custom type of Package.
        ///</SecurityNote>
        public static void RemovePackage(Uri uri)
        {
            ValidatePackageUri(uri);

            lock (_globalLock)
            {
                if (_packages != null)
                {
                    DemandSecurityPermissionIfCustomPackage((Package) _packages[uri]);

                    // If the key doesn't exist, it is no op
                    _packages.Remove(uri);
                }
            }
        }

        #endregion Public Methods

        #region Private Methods

        private static void ValidatePackageUri(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            if (!uri.IsAbsoluteUri)
            {
                throw new ArgumentException(SR.Get(SRID.UriMustBeAbsolute), "uri");
            }
        }

        private static void DemandSecurityPermissionIfCustomPackage(Package package)
        {
            // Although ZipPackage is sealed and cannot be subclassed, we shouldn't depend on
            //  the "sealedness" of ZipPackage. Checking the object type is more reliable way
            //  than using "as" or "is" operator.
            if (package != null && package.GetType() != typeof(ZipPackage))
            {
                SecurityHelper.DemandEnvironmentPermission();
            }
        }

        
        public override void ReloadPreview()
        {
            if (CurrentPaper != null)
                ReloadPreview(PageOrientation, CurrentPaper);
        }
        public void ReloadPreview(PageOrientation pageOrientation, PaperSize currentPaper)
        {
            ReloadingPreview = true;
            if (FullScreenPrintWindow != null)
            {
                WaitScreen.Show("Loading Preview");
            }
            
            if (PageOrientation == PageOrientation.Portrait)
            {
                FlowDocument.PageHeight = currentPaper.Height;
                FlowDocument.PageWidth = currentPaper.Width;
            }
            else
            {
                FlowDocument.PageHeight = currentPaper.Width;
                FlowDocument.PageWidth = currentPaper.Height;
            }

            _ms = new MemoryStream();
            _pkg = Package.Open(_ms, FileMode.Create, FileAccess.ReadWrite);
            const string pack = "pack://temp.xps";
            var oldPackage = PackageStore.GetPackage(new Uri(pack));
            if (oldPackage == null)
                PackageStore.AddPackage(new Uri(pack), _pkg);
            else
            {
                PackageStore.RemovePackage(new Uri(pack));
                PackageStore.AddPackage(new Uri(pack), _pkg);
            }
            _xpsDocument = new XpsDocument(_pkg, CompressionOption.SuperFast, pack);
            var xpsWriter = XpsDocument.CreateXpsDocumentWriter(_xpsDocument);

            var documentPaginator = ((IDocumentPaginatorSource)FlowDocument).DocumentPaginator;
            xpsWriter.Write(documentPaginator);
            Paginator = documentPaginator;
            MaxCopies = NumberOfPages = ApproaxNumberOfPages = Paginator.PageCount;
            PagesAcross = 2;
            DisplayPagePreviewsAll(documentPaginator);
            WaitScreen.Hide();
            ReloadingPreview = false;
        }
        

        public void ShowPrintPreview(FlowDocument flowDocument)
        {
            FlowDocument = flowDocument;
            if (FullScreenPrintWindow == null)
                CreatePrintPreviewWindow();
            Loading = true;
            if (FullScreenPrintWindow != null) FullScreenPrintWindow.ShowDialog();
            ApplicationExtention.MainWindow = null;
        }

        public override void FullScreenPrintWindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (_xpsDocument != null)
                _xpsDocument.Close();
            if (_pkg != null)
                _pkg.Close();
            if (_ms != null)
                _ms.Close();
            base.FullScreenPrintWindowClosing(sender, e);
        }

        
        public override void ReloadPreview()
        {
            if (CurrentPaper != null)
                ReloadPreview(PageOrientation, CurrentPaper);
        }
        public void ReloadPreview(PageOrientation pageOrientation, PaperSize currentPaper)
        {
            ReloadingPreview = true;
            if (FullScreenPrintWindow != null)
            {
                WaitScreen.Show("Loading Preview");
            }
            
            if (PageOrientation == PageOrientation.Portrait)
            {
                FlowDocument.PageHeight = currentPaper.Height;
                FlowDocument.PageWidth = currentPaper.Width;
            }
            else
            {
                FlowDocument.PageHeight = currentPaper.Width;
                FlowDocument.PageWidth = currentPaper.Height;
            }

            _ms = new MemoryStream();
            _pkg = Package.Open(_ms, FileMode.Create, FileAccess.ReadWrite);
            const string pack = "pack://temp.xps";
            var oldPackage = PackageStore.GetPackage(new Uri(pack));
            if (oldPackage == null)
                PackageStore.AddPackage(new Uri(pack), _pkg);
            else
            {
                PackageStore.RemovePackage(new Uri(pack));
                PackageStore.AddPackage(new Uri(pack), _pkg);
            }
            _xpsDocument = new XpsDocument(_pkg, CompressionOption.SuperFast, pack);
            var xpsWriter = XpsDocument.CreateXpsDocumentWriter(_xpsDocument);

            var documentPaginator = ((IDocumentPaginatorSource)FlowDocument).DocumentPaginator;
            xpsWriter.Write(documentPaginator);
            Paginator = documentPaginator;
            MaxCopies = NumberOfPages = ApproaxNumberOfPages = Paginator.PageCount;
            PagesAcross = 2;
            DisplayPagePreviewsAll(documentPaginator);
            WaitScreen.Hide();
            ReloadingPreview = false;
        }
        

        public void ShowPrintPreview(FlowDocument flowDocument)
        {
            FlowDocument = flowDocument;
            if (FullScreenPrintWindow == null)
                CreatePrintPreviewWindow();
            Loading = true;
            if (FullScreenPrintWindow != null) FullScreenPrintWindow.ShowDialog();
            ApplicationExtention.MainWindow = null;
        }

        public override void FullScreenPrintWindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (_xpsDocument != null)
                _xpsDocument.Close();
            if (_pkg != null)
                _pkg.Close();
            if (_ms != null)
                _ms.Close();
            base.FullScreenPrintWindowClosing(sender, e);
        }

        
        public override void ReloadPreview()
        {
            if (CurrentPaper != null)
                ReloadPreview(PageOrientation, CurrentPaper);
        }
        public void ReloadPreview(PageOrientation pageOrientation, PaperSize currentPaper)
        {
            ReloadingPreview = true;
            if (FullScreenPrintWindow != null)
            {
                WaitScreen.Show("Loading Preview");
            }
            
            if (PageOrientation == PageOrientation.Portrait)
            {
                FlowDocument.PageHeight = currentPaper.Height;
                FlowDocument.PageWidth = currentPaper.Width;
            }
            else
            {
                FlowDocument.PageHeight = currentPaper.Width;
                FlowDocument.PageWidth = currentPaper.Height;
            }

            _ms = new MemoryStream();
            _pkg = Package.Open(_ms, FileMode.Create, FileAccess.ReadWrite);
            const string pack = "pack://temp.xps";
            var oldPackage = PackageStore.GetPackage(new Uri(pack));
            if (oldPackage == null)
                PackageStore.AddPackage(new Uri(pack), _pkg);
            else
            {
                PackageStore.RemovePackage(new Uri(pack));
                PackageStore.AddPackage(new Uri(pack), _pkg);
            }
            _xpsDocument = new XpsDocument(_pkg, CompressionOption.SuperFast, pack);
            var xpsWriter = XpsDocument.CreateXpsDocumentWriter(_xpsDocument);

            var documentPaginator = ((IDocumentPaginatorSource)FlowDocument).DocumentPaginator;
            xpsWriter.Write(documentPaginator);
            Paginator = documentPaginator;
            MaxCopies = NumberOfPages = ApproaxNumberOfPages = Paginator.PageCount;
            PagesAcross = 2;
            DisplayPagePreviewsAll(documentPaginator);
            WaitScreen.Hide();
            ReloadingPreview = false;
        }
        

        public void ShowPrintPreview(FlowDocument flowDocument)
        {
            FlowDocument = flowDocument;
            if (FullScreenPrintWindow == null)
                CreatePrintPreviewWindow();
            Loading = true;
            if (FullScreenPrintWindow != null) FullScreenPrintWindow.ShowDialog();
            ApplicationExtention.MainWindow = null;
        }

        public override void FullScreenPrintWindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (_xpsDocument != null)
                _xpsDocument.Close();
            if (_pkg != null)
                _pkg.Close();
            if (_ms != null)
                _ms.Close();
            base.FullScreenPrintWindowClosing(sender, e);
        }

        
        public override void ReloadPreview()
        {
            if (CurrentPaper != null)
                ReloadPreview(PageOrientation, CurrentPaper);
        }
        public void ReloadPreview(PageOrientation pageOrientation, PaperSize currentPaper)
        {
            ReloadingPreview = true;
            if (FullScreenPrintWindow != null)
            {
                WaitScreen.Show("Loading Preview");
            }
            
            if (PageOrientation == PageOrientation.Portrait)
            {
                FlowDocument.PageHeight = currentPaper.Height;
                FlowDocument.PageWidth = currentPaper.Width;
            }
            else
            {
                FlowDocument.PageHeight = currentPaper.Width;
                FlowDocument.PageWidth = currentPaper.Height;
            }

            _ms = new MemoryStream();
            _pkg = Package.Open(_ms, FileMode.Create, FileAccess.ReadWrite);
            const string pack = "pack://temp.xps";
            var oldPackage = PackageStore.GetPackage(new Uri(pack));
            if (oldPackage == null)
                PackageStore.AddPackage(new Uri(pack), _pkg);
            else
            {
                PackageStore.RemovePackage(new Uri(pack));
                PackageStore.AddPackage(new Uri(pack), _pkg);
            }
            _xpsDocument = new XpsDocument(_pkg, CompressionOption.SuperFast, pack);
            var xpsWriter = XpsDocument.CreateXpsDocumentWriter(_xpsDocument);

            var documentPaginator = ((IDocumentPaginatorSource)FlowDocument).DocumentPaginator;
            xpsWriter.Write(documentPaginator);
            Paginator = documentPaginator;
            MaxCopies = NumberOfPages = ApproaxNumberOfPages = Paginator.PageCount;
            PagesAcross = 2;
            DisplayPagePreviewsAll(documentPaginator);
            WaitScreen.Hide();
            ReloadingPreview = false;
        }
        

        public void ShowPrintPreview(FlowDocument flowDocument)
        {
            FlowDocument = flowDocument;
            if (FullScreenPrintWindow == null)
                CreatePrintPreviewWindow();
            Loading = true;
            if (FullScreenPrintWindow != null) FullScreenPrintWindow.ShowDialog();
            ApplicationExtention.MainWindow = null;
        }

        public override void FullScreenPrintWindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (_xpsDocument != null)
                _xpsDocument.Close();
            if (_pkg != null)
                _pkg.Close();
            if (_ms != null)
                _ms.Close();
            base.FullScreenPrintWindowClosing(sender, e);
        }

        
        public override void ReloadPreview()
        {
            if (CurrentPaper != null)
                ReloadPreview(PageOrientation, CurrentPaper);
        }
        public void ReloadPreview(PageOrientation pageOrientation, PaperSize currentPaper)
        {
            ReloadingPreview = true;
            if (FullScreenPrintWindow != null)
            {
                WaitScreen.Show("Loading Preview");
            }
            
            if (PageOrientation == PageOrientation.Portrait)
            {
                FlowDocument.PageHeight = currentPaper.Height;
                FlowDocument.PageWidth = currentPaper.Width;
            }
            else
            {
                FlowDocument.PageHeight = currentPaper.Width;
                FlowDocument.PageWidth = currentPaper.Height;
            }

            _ms = new MemoryStream();
            _pkg = Package.Open(_ms, FileMode.Create, FileAccess.ReadWrite);
            const string pack = "pack://temp.xps";
            var oldPackage = PackageStore.GetPackage(new Uri(pack));
            if (oldPackage == null)
                PackageStore.AddPackage(new Uri(pack), _pkg);
            else
            {
                PackageStore.RemovePackage(new Uri(pack));
                PackageStore.AddPackage(new Uri(pack), _pkg);
            }
            _xpsDocument = new XpsDocument(_pkg, CompressionOption.SuperFast, pack);
            var xpsWriter = XpsDocument.CreateXpsDocumentWriter(_xpsDocument);

            var documentPaginator = ((IDocumentPaginatorSource)FlowDocument).DocumentPaginator;
            xpsWriter.Write(documentPaginator);
            Paginator = documentPaginator;
            MaxCopies = NumberOfPages = ApproaxNumberOfPages = Paginator.PageCount;
            PagesAcross = 2;
            DisplayPagePreviewsAll(documentPaginator);
            WaitScreen.Hide();
            ReloadingPreview = false;
        }
        

        public void ShowPrintPreview(FlowDocument flowDocument)
        {
            FlowDocument = flowDocument;
            if (FullScreenPrintWindow == null)
                CreatePrintPreviewWindow();
            Loading = true;
            if (FullScreenPrintWindow != null) FullScreenPrintWindow.ShowDialog();
            ApplicationExtention.MainWindow = null;
        }

        public override void FullScreenPrintWindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (_xpsDocument != null)
                _xpsDocument.Close();
            if (_pkg != null)
                _pkg.Close();
            if (_ms != null)
                _ms.Close();
            base.FullScreenPrintWindowClosing(sender, e);
        }


		protected override void Dispose (bool disposing)
		{
			imageLoader.Loaded -= ImageLoaded;
			imageLoader.Dispose ();

			RemoveSelectedPackagePropertyChangedEventHandler ();
			viewModel.PropertyChanged -= ViewModelPropertyChanged;
			viewModel.Dispose ();
			DisposeExistingTimer ();
			DisposePopulatePackageVersionsTimer ();
			packageStore.Clear ();
			viewModel = null;
			base.Dispose (disposing);
		}

		void UpdatePackageSearchEntryWithInitialText (string initialSearch)
		{
			packageSearchEntry.Text = initialSearch;
			if (!String.IsNullOrEmpty (initialSearch)) {
				packageSearchEntry.CursorPosition = initialSearch.Length;
			}
		}

		void InitializeListView ()
		{
			packageStore = new ListStore (packageHasBackgroundColorField, packageCheckBoxAlphaField, packageImageField, packageViewModelField);
			packagesListView.DataSource = packageStore;

			AddPackageCellViewToListView ();

			packagesListView.SelectionChanged += PackagesListViewSelectionChanged;
			packagesListView.RowActivated += PackagesListRowActivated;
			packagesListView.VerticalScrollControl.ValueChanged += PackagesListViewScrollValueChanged;
		}

		void AddPackageCellViewToListView ()
		{
			packageCellView = new PackageCellView {
				PackageField = packageViewModelField,
				HasBackgroundColorField = packageHasBackgroundColorField,
				CheckBoxAlphaField = packageCheckBoxAlphaField,
				ImageField = packageImageField,
				CellWidth = 535
			};
			var textColumn = new ListViewColumn ("Package", packageCellView);
			packagesListView.Columns.Add (textColumn);

			packageCellView.PackageChecked += PackageCellViewPackageChecked;
		}

		void ShowLoadingMessage ()
		{
			UpdateSpinnerLabel ();
			noPackagesFoundFrame.Visible = false;
			packagesListView.Visible = false;
			loadingSpinnerFrame.Visible = true;
			loadingMessageVisible = true;
		}

		void HideLoadingMessage ()
		{
			loadingSpinnerFrame.Visible = false;
			packagesListView.Visible = true;
			noPackagesFoundFrame.Visible = false;
			loadingMessageVisible = false;
		}


        #region public Methods

        // 
        /// <summary>
        /// Retrieves a package from the store for the given Uri.
        /// </summary>
        /// <param name="uri">key uri</param>
        /// <returns>Package</returns>
        /// <permission cref="EnvironmentPermission"></permission>
        /// <remarks>
        /// </remarks>
        ///<SecurityNote>
        /// Demands EnvironmentPermission() if package is custom type of Package.
        /// This prevents Partially Trusted callers from performing this operation on custom type of Package.
        ///</SecurityNote>
        public static Package GetPackage(Uri uri)
        {
            ValidatePackageUri(uri);
  
            lock (_globalLock)
            {
                Package package = null;

                if (_packages != null && _packages.Contains(uri))
                {
                    package = (Package) _packages[uri];
                    DemandSecurityPermissionIfCustomPackage(package);
                }
                
                return package;
            }
        }

        /// <summary>
        /// Adds a uri, package pair to the package store.
        /// </summary>
        /// <param name="uri">key uri</param>
        /// <param name="package">package</param>
        /// <permission cref="EnvironmentPermission"></permission>
        /// <remarks>
        /// If a package with the uri is already in the store,it throws an exception.
        /// The package will not be automatically replaced within the store.
        /// </remarks>
        ///<SecurityNote>
        /// Demands EnvironmentPermission() if package is custom type of Package.
        /// This prevents Partially Trusted callers from performing this operation. However, Partially Trusted callers can still
        /// add well-known platform Package type (ZipPackage) to PackageStore.
        /// the application's PackageStore.
        ///</SecurityNote>
        public static void AddPackage(Uri uri, Package package)
        {
            // Allow well known platform Package to be added into PackageStore under Partial Trust.
            // Otherwise, demand Environment Permission to make sure only Full Trust app can add a custom Package
            DemandSecurityPermissionIfCustomPackage(package);

            ValidatePackageUri(uri);

            // There are well-known package types that are only for internal use (for resource loading)
            //  (i.e. ResourceContainer - "application://" and SiteOriginContainer - "siteoforigin://"
            // Adding packages with such key uri will have no effect on PackWebRequest since
            //  they cannot be overriden. So, calling this method with such key Uris should be prevented 
            //  However, uri.Equal cannot be used here since the key Uris are used as a pack Uri form and
            //  only PackUriHelper.ComparePackUri can do the proper comparison of pack Uris.

            Uri packUri = PackUriHelper.Create(uri);
       
            if (PackUriHelper.ComparePackUri(packUri, BaseUriHelper.PackAppBaseUri) == 0
                    || PackUriHelper.ComparePackUri(packUri, BaseUriHelper.SiteOfOriginBaseUri) == 0)
            {
                throw new ArgumentException(SR.Get(SRID.NotAllowedPackageUri), "uri");
            }

            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            lock (_globalLock)
            {
                if (_packages == null)
                {
                    _packages = new HybridDictionary(2);
                }

                if (_packages.Contains(uri))
                {
                    throw new InvalidOperationException(SR.Get(SRID.PackageAlreadyExists));
                }
                
                _packages.Add(uri, package);
            }
        }

        /// <summary>
        /// Removes a uri, package pair from the package store.
        /// </summary>
        /// <param name="uri">key uri</param>
        /// <permission cref="EnvironmentPermission"></permission>
        /// <remarks>
        /// </remarks>
        ///<SecurityNote>
        /// Demands EnvironmentPermission() if package is custom type of Package.
        /// This prevents Partially Trusted callers from performing this operation on custom type of Package.
        ///</SecurityNote>
        public static void RemovePackage(Uri uri)
        {
            ValidatePackageUri(uri);

            lock (_globalLock)
            {
                if (_packages != null)
                {
                    DemandSecurityPermissionIfCustomPackage((Package) _packages[uri]);

                    // If the key doesn't exist, it is no op
                    _packages.Remove(uri);
                }
            }
        }

        #endregion Public Methods

        #region Private Methods

        private static void ValidatePackageUri(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            if (!uri.IsAbsoluteUri)
            {
                throw new ArgumentException(SR.Get(SRID.UriMustBeAbsolute), "uri");
            }
        }

        private static void DemandSecurityPermissionIfCustomPackage(Package package)
        {
            // Although ZipPackage is sealed and cannot be subclassed, we shouldn't depend on
            //  the "sealedness" of ZipPackage. Checking the object type is more reliable way
            //  than using "as" or "is" operator.
            if (package != null && package.GetType() != typeof(ZipPackage))
            {
                SecurityHelper.DemandEnvironmentPermission();
            }
        }

Microsoft.Azure.Management.DataFactory.Models.PackageStore : Object

Constructors :

public PackageStore()
public PackageStore(String name = , EntityReference packageStoreLinkedService = )

Methods :

public String get_Name()
public Void set_Name(String value = )
public EntityReference get_PackageStoreLinkedService()
public Void set_PackageStoreLinkedService(EntityReference value = )
public Void Validate()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods

Other methods