Ejemplo n.º 1
0
        static void WhatIfExamples()
        {
            // Get the first What If article
            WhatIfArticle first = WhatIf.GetFirstArticle();

            // Get the latest What If article
            WhatIfArticle latest = WhatIf.GetLatestArticle();

            // Get a random What If article
            WhatIfArticle random = WhatIf.GetRandomArticle();

            // Get a specific What If article by ID
            WhatIfArticle fortyTwo = WhatIf.GetArticle(42);

            // Get the next article
            WhatIfArticle fortyThree = fortyTwo.Next();

            // Get the previous article
            WhatIfArticle fortyOne = fortyTwo.Previous();

            // There's nothing before the first article
            WhatIfArticle badFirst = first.Previous();

            // ...and nothing after the latest
            WhatIfArticle badLast = latest.Next();

            // Get the dictionary of What If article entries, keyed on article ID
            Dictionary <int, WhatIfArchiveEntry> dict = WhatIf.WhatIfDictionary;

            // Refresh the article dictionary
            WhatIf.RefreshWhatIfDictionary();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the previous What If article
        /// </summary>
        /// <returns>Previous What If article, null if no previous article</returns>
        public WhatIfArticle Previous()
        {
            WhatIfArchiveEntry prevArchiveEntry = WhatIf.WhatIfDictionary.OrderByDescending(x => x.Key).SkipWhile(x => x.Key >= Id).FirstOrDefault().Value;

            if (prevArchiveEntry != null)
            {
                return(WhatIf.GetArticle(prevArchiveEntry));
            }
            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the next What If article
        /// </summary>
        /// <returns>Next What If article, null if no next article</returns>
        public WhatIfArticle Next()
        {
            WhatIfArchiveEntry nextArchiveEntry = WhatIf.WhatIfDictionary.OrderBy(x => x.Key).SkipWhile(x => x.Key <= Id).FirstOrDefault().Value;

            if (nextArchiveEntry != null)
            {
                return(WhatIf.GetArticle(nextArchiveEntry));
            }
            return(null);
        }
Ejemplo n.º 4
0
        public void Dispose()
        {
            // Clearing all of these ensures that the transient APIs
            // can't be called outside of the appropriate scope.

            #region dispose-dispatcher service-apis
            _GetNuGetExePath             = null;
            _GetNuGetDllPath             = null;
            _DownloadFile                = null;
            _AddPinnedItemToTaskbar      = null;
            _RemovePinnedItemFromTaskbar = null;
            _CreateShortcutLink          = null;
            _UnzipFileIncremental        = null;
            _UnzipFile                 = null;
            _AddFileAssociation        = null;
            _RemoveFileAssociation     = null;
            _AddExplorerMenuItem       = null;
            _RemoveExplorerMenuItem    = null;
            _SetEnvironmentVariable    = null;
            _RemoveEnvironmentVariable = null;
            _AddFolderToPath           = null;
            _RemoveFolderFromPath      = null;
            _InstallMSI                = null;
            _RemoveMSI                 = null;
            _StartProcess              = null;
            _InstallVSIX               = null;
            _UninstallVSIX             = null;
            _InstallPowershellScript   = null;
            _UninstallPowershellScript = null;
            _SearchForExecutable       = null;
            _GetUserBinFolder          = null;
            _GetSystemBinFolder        = null;
            _CopyFile                = null;
            _CopyFolder              = null;
            _Delete                  = null;
            _DeleteFolder            = null;
            _CreateFolder            = null;
            _DeleteFile              = null;
            _BeginTransaction        = null;
            _AbortTransaction        = null;
            _EndTransaction          = null;
            _GenerateUninstallScript = null;
            _GetKnownFolder          = null;
            _IsElevated              = null;
            #endregion

            #region dispose-dispatcher core-apis
            _Warning          = null;
            _Message          = null;
            _Error            = null;
            _Debug            = null;
            _Verbose          = null;
            _ExceptionThrown  = null;
            _Progress         = null;
            _ProgressComplete = null;
            _GetHostDelegate  = null;
            _IsCancelled      = null;
            #endregion

            #region dispose-dispatcher request-apis
            _OkToContinue                       = null;
            _YieldPackage                       = null;
            _YieldPackageDetails                = null;
            _YieldPackageSwidtag                = null;
            _YieldSource                        = null;
            _YieldMetadataDefinition            = null;
            _YieldInstallationOptionsDefinition = null;
            #endregion

            #region dispose-dispatcher host-apis
            _GetMetadataKeys             = null;
            _GetMetadataValues           = null;
            _GetInstallationOptionKeys   = null;
            _GetInstallationOptionValues = null;
            _PackageSources   = null;
            _GetConfiguration = null;
            _ShouldContinueWithUntrustedPackageSource = null;
            _ShouldProcessPackageInstall                = null;
            _ShouldProcessPackageUninstall              = null;
            _ShouldContinueAfterPackageInstallFailure   = null;
            _ShouldContinueAfterPackageUninstallFailure = null;
            _ShouldContinueRunningInstallScript         = null;
            _ShouldContinueRunningUninstallScript       = null;
            _AskPermission = null;
            _WhatIf        = null;
            #endregion

            #region dispose-dispatcher protocol-apis
            _ProtocolGetNames        = null;
            _ProtocolIsValidSource   = null;
            _ProtocolGetItemMetadata = null;
            _ProtocolDownloadItem    = null;
            _ProtocolUnpackItem      = null;
            _InstallItem             = null;
            #endregion

            _callback = null;
        }
Ejemplo n.º 5
0
 public bool WhatIf( )
 {
     CheckDisposed();
     return((_WhatIf ?? (_WhatIf = (_callback.Resolve <WhatIf>() ?? (() => default(bool)))))());
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Article for this archive entry
 /// </summary>
 public WhatIfArticle Article() => WhatIf.GetArticle(this);