Esempio n. 1
0
        public override ConversionType GetVersion(ConversionTarget project)
        {
            ConversionType conversionType;

            if (!project.IsProject)
            {
                return(ConversionType.Unsupported);
            }
            using (IEnumerator <IProjectItemData> enumerator = project.ProjectStore.GetItems("Reference").GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    IProjectItemData current      = enumerator.Current;
                    AssemblyName     assemblyName = ProjectConverterBase.GetAssemblyName(current.Value);
                    if (assemblyName == null || !this.IsOverqualifiedSdkAssembly(current, assemblyName))
                    {
                        continue;
                    }
                    conversionType = ConversionType.BlendSdk3;
                    return(conversionType);
                }
                return(ConversionType.Unknown);
            }
            return(conversionType);
        }
        public override ConversionType GetVersion(ConversionTarget file)
        {
            if (!file.IsProject)
            {
                return(ConversionType.Unknown);
            }
            IProjectStore projectStore = file.ProjectStore;

            if (Microsoft.Expression.Framework.Interop.TypeHelper.ConvertType <bool>(projectStore.GetProperty("WindowsCEEnabled")) || Microsoft.Expression.Framework.Interop.TypeHelper.ConvertType <bool>(projectStore.GetProperty("SilverlightMobile")))
            {
                return(ConversionType.Unsupported);
            }
            Version silverlightVersion = ProjectStoreHelper.GetSilverlightVersion(projectStore);

            if (silverlightVersion == CommonVersions.Version2_0)
            {
                return(ConversionType.ProjectSilverlight2);
            }
            if (silverlightVersion == CommonVersions.Version3_0)
            {
                return(ConversionType.ProjectSilverlight3);
            }
            if (silverlightVersion == CommonVersions.Version4_0)
            {
                return(ConversionType.ProjectSilverlight4);
            }
            return(ConversionType.Unknown);
        }
Esempio n. 3
0
        public override ConversionType GetVersion(ConversionTarget file)
        {
            if (!file.IsProject)
            {
                return(ConversionType.Unknown);
            }
            FrameworkName targetFrameworkName = ProjectStoreHelper.GetTargetFrameworkName(file.ProjectStore);

            if (targetFrameworkName == null || targetFrameworkName.Identifier != ".NETFramework")
            {
                return(ConversionType.Unknown);
            }
            if (ProjectStoreHelper.UsesWpf(file.ProjectStore))
            {
                if (targetFrameworkName.Version == CommonVersions.Version3_0)
                {
                    return(ConversionType.ProjectWpf30);
                }
                if (targetFrameworkName.Version == CommonVersions.Version3_5)
                {
                    return(ConversionType.ProjectWpf35);
                }
                if (targetFrameworkName.Version == CommonVersions.Version4_0)
                {
                    return(ConversionType.ProjectWpf40);
                }
            }
            return(ConversionType.Unknown);
        }
Esempio n. 4
0
 protected sealed override bool InternalConvert(ConversionTarget file, ConversionType initialState, ConversionType targetState)
 {
     if (this.GetVersion(file) == targetState)
     {
         return(true);
     }
     if (!ProjectPathHelper.AttemptToMakeWritable(file.ProjectStore.DocumentReference, base.Context))
     {
         return(false);
     }
     if (!this.UpgradeProject(file.ProjectStore, initialState, targetState))
     {
         return(false);
     }
     file.ProjectStore.Save();
     return(true);
 }
Esempio n. 5
0
        protected override bool InternalConvert(ConversionTarget file, ConversionType initialState, ConversionType targetState)
        {
            IEnumerable <UpgradeAction> conversionTargets =
                from target in this.GetConversionTargets()
                from upgradeAction in ConversionHelper.CheckAndAddFile(target, this.Converters, this.VersionMapping, this.IgnoreEnabled)
                select upgradeAction;
            bool flag = true;

            foreach (UpgradeAction conversionTarget in conversionTargets)
            {
                if (conversionTarget.Converter.Convert(conversionTarget.TargetFile, conversionTarget.InitialType, conversionTarget.TargetType))
                {
                    continue;
                }
                flag = false;
            }
            return(flag);
        }
 public override ConversionType GetVersion(ConversionTarget file)
 {
     if (file.IsProject && BlendSdkHelper.IsAnyCurrentVersionSdkInstalled)
     {
         IEnumerable <string> projectImports = file.ProjectStore.ProjectImports;
         if (projectImports != null)
         {
             if (BlendSdkHelper.IsSdkInstalled(BlendSdkHelper.CurrentWpfVersion))
             {
                 if (projectImports.Contains <string>("SubsetFont.targets"))
                 {
                     return(ConversionType.BlendSdkFontEmbedding2);
                 }
                 if (projectImports.Contains <string>("$(MSBuildExtensionsPath)\\Microsoft\\Expression\\Blend\\3.0\\WPF\\Microsoft.Expression.Blend.WPF.targets"))
                 {
                     return(ConversionType.BlendSdkFontEmbedding3);
                 }
                 if (projectImports.Contains <string>(BlendSdkHelper.CurrentVersionWpfTargetsFile))
                 {
                     return(ConversionType.BlendSdkFontEmbedding4);
                 }
             }
             if (BlendSdkHelper.IsSdkInstalled(BlendSdkHelper.CurrentSilverlightVersion))
             {
                 if (projectImports.Contains <string>("SubsetFontSilverlight.targets"))
                 {
                     return(ConversionType.BlendSdkFontEmbedding2);
                 }
                 if (projectImports.Contains <string>("$(MSBuildExtensionsPath)\\Microsoft\\Expression\\Blend\\3.0\\Silverlight\\Microsoft.Expression.Blend.Silverlight.targets"))
                 {
                     return(ConversionType.BlendSdkFontEmbedding3);
                 }
                 if (projectImports.Contains <string>(BlendSdkHelper.CurrentVersionSilverlightTargetsFile))
                 {
                     return(ConversionType.BlendSdkFontEmbedding4);
                 }
             }
         }
     }
     return(ConversionType.Unknown);
 }
Esempio n. 7
0
        public override ConversionType GetVersion(ConversionTarget file)
        {
            ConversionType conversionType;

            if (!file.IsProject)
            {
                return(ConversionType.Unknown);
            }
            FrameworkName targetFrameworkName = ProjectStoreHelper.GetTargetFrameworkName(file.ProjectStore);

            if (targetFrameworkName == null || targetFrameworkName.Identifier != ".NETFramework")
            {
                return(ConversionType.Unknown);
            }
            string property = file.ProjectStore.GetProperty("ProjectTypeGuids");

            if (!string.IsNullOrEmpty(property) && property.IndexOf("{349c5851-65df-11da-9384-00065b846f21}", StringComparison.OrdinalIgnoreCase) != -1)
            {
                using (IEnumerator <string> enumerator = file.ProjectStore.ProjectImports.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string current = enumerator.Current;
                        Match  match   = WebProjectConverter.webApplicationTargetVersion.Match(current);
                        if (!match.Success || !string.Equals(match.Groups["version"].Value, "v9.0", StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        conversionType = ConversionType.WebAppProject9;
                        return(conversionType);
                    }
                    return(ConversionType.Unknown);
                }
                return(conversionType);
            }
            return(ConversionType.Unknown);
        }
Esempio n. 8
0
 public override ConversionType GetVersion(ConversionTarget project)
 {
     if (project.IsProject && ProjectStoreHelper.DoesLanguageSupportXaml(project.ProjectStore))
     {
         Version storeVersion = project.ProjectStore.StoreVersion;
         if (storeVersion == CommonVersions.Version2_0)
         {
             return(ConversionType.BuildToolsVersion20);
         }
         if (storeVersion == CommonVersions.Version3_5)
         {
             return(ConversionType.BuildToolsVersion35);
         }
         if (storeVersion == CommonVersions.Version4_0)
         {
             return(ConversionType.BuildToolsVersion40);
         }
         if (storeVersion == null)
         {
             return(ConversionType.BuildToolsVersionNone);
         }
     }
     return(ConversionType.Unknown);
 }
Esempio n. 9
0
 internal static IEnumerable <UpgradeAction> CheckAndAddFile(ConversionTarget file, IEnumerable <IProjectConverter> converters, IDictionary <ConversionType, ConversionType> versionMapping, bool ignoreEnabled)
 {
     foreach (IProjectConverter projectConverter in converters)
     {
         if (!ignoreEnabled && !projectConverter.IsEnabled)
         {
             continue;
         }
         ConversionType version = projectConverter.GetVersion(file);
         ConversionType item    = versionMapping[version];
         if (version == item || item == ConversionType.DoNothing || item == ConversionType.Unsupported || item == ConversionType.Unknown)
         {
             continue;
         }
         UpgradeAction upgradeAction = new UpgradeAction()
         {
             TargetFile  = file,
             InitialType = version,
             TargetType  = item,
             Converter   = projectConverter
         };
         yield return(upgradeAction);
     }
 }
Esempio n. 10
0
 protected abstract bool InternalConvert(ConversionTarget file, ConversionType initialState, ConversionType targetState);
Esempio n. 11
0
 public abstract ConversionType GetVersion(ConversionTarget project);
Esempio n. 12
0
 public bool Convert(ConversionTarget file, ConversionType initialState, ConversionType targetState)
 {
     return(this.InternalConvert(file, initialState, targetState));
 }
Esempio n. 13
0
        internal UpgradeWizard.UpgradeResponse PromptToUpgrade(Dictionary <ConversionType, ConversionType> conversionMapping, out bool?doNotShowAgain, ref string backupLocation, out IEnumerable <UpgradeAction> proposedUpgrades)
        {
            doNotShowAgain   = null;
            proposedUpgrades = Enumerable.Empty <UpgradeAction>();
            List <UpgradeAction> list = this.GetProposedUpgrades(conversionMapping).ToList <UpgradeAction>();

            if (list.Count == 0)
            {
                return(UpgradeWizard.UpgradeResponse.DontUpgrade);
            }
            List <ConversionType> conversionTypes  = new List <ConversionType>();
            List <ConversionType> conversionTypes1 = new List <ConversionType>();
            bool flag  = false;
            bool flag1 = false;

            if (!this.sketchFlowSolution)
            {
                using (IEnumerator <ConversionTarget> enumerator = this.GetConversionTargets().GetEnumerator())
                {
                    do
                    {
Label0:
                        if (!enumerator.MoveNext())
                        {
                            break;
                        }
                        ConversionTarget current             = enumerator.Current;
                        FrameworkName    targetFrameworkName = ProjectStoreHelper.GetTargetFrameworkName(current.ProjectStore);
                        if (targetFrameworkName == null || targetFrameworkName.Version == CommonVersions.Version4_0)
                        {
                            goto Label0;
                        }
                        else if (flag || !ProjectStoreHelper.UsesSilverlight(current.ProjectStore) || targetFrameworkName.Version.Major <= 1)
                        {
                            if (flag1 || !ProjectStoreHelper.UsesWpf(current.ProjectStore) || !(targetFrameworkName.Version >= CommonVersions.Version3_0))
                            {
                                continue;
                            }
                            flag1 = true;
                        }
                        else
                        {
                            flag = true;
                        }
                    }while (!flag1 || !flag);
                }
                if (flag1)
                {
                    conversionTypes1.Add(ConversionType.ProjectWpf35);
                    conversionTypes1.Add(ConversionType.ProjectWpf40);
                }
                if (flag)
                {
                    conversionTypes.Add(ConversionType.ProjectSilverlight3);
                    conversionTypes.Add(ConversionType.ProjectSilverlight4);
                }
            }
            bool flag2 = this.targetStore != null;
            bool flag3 = !flag2;
            bool flag4 = !flag2;
            UpgradeProjectDialog upgradeProjectDialog = new UpgradeProjectDialog(base.Services.ExpressionInformationService(), conversionTypes, conversionTypes1, flag3, flag4);
            ProjectDialogResult  projectDialogResult  = upgradeProjectDialog.ShowProjectDialog();

            doNotShowAgain = new bool?(upgradeProjectDialog.DoNotShowAgain);
            if (upgradeProjectDialog.Backup && projectDialogResult == ProjectDialogResult.Yes)
            {
                string      parentDirectory              = Microsoft.Expression.Framework.Documents.PathHelper.GetParentDirectory(Microsoft.Expression.Framework.Documents.PathHelper.GetDirectory(base.Solution.DocumentReference.Path));
                CultureInfo invariantCulture             = CultureInfo.InvariantCulture;
                string      newNameCopyTemplate          = StringTable.NewNameCopyTemplate;
                object[]    fileNameWithoutExtension     = new object[] { Path.GetFileNameWithoutExtension(base.Solution.DocumentReference.DisplayName) };
                string      availableFileOrDirectoryName = string.Format(invariantCulture, newNameCopyTemplate, fileNameWithoutExtension);
                availableFileOrDirectoryName = Microsoft.Expression.Framework.Documents.PathHelper.GetAvailableFileOrDirectoryName(availableFileOrDirectoryName, null, parentDirectory, false);
                backupLocation = Path.Combine(parentDirectory, availableFileOrDirectoryName);
                string    str        = backupLocation;
                Exception exception1 = null;
                using (IDisposable disposable = TemporaryCursor.SetWaitCursor())
                {
                    ErrorHandling.HandleBasicExceptions(() => ProjectManager.CopyDirectory(Microsoft.Expression.Framework.Documents.PathHelper.GetDirectory(this.Solution.DocumentReference.Path), str), (Exception exception) => exception1 = exception);
                }
                if (exception1 != null)
                {
                    ErrorArgs errorArg = new ErrorArgs()
                    {
                        Message      = StringTable.UpgradeBackupFailed,
                        Exception    = exception1,
                        AutomationId = "BackupProjectErrorDialog"
                    };
                    base.Services.MessageDisplayService().ShowError(errorArg);
                    return(UpgradeWizard.UpgradeResponse.Cancel);
                }
            }
            switch (projectDialogResult)
            {
            case ProjectDialogResult.Yes:
            {
                if (this.sketchFlowSolution)
                {
                    proposedUpgrades = list;
                }
                else
                {
                    this.VersionMapping[ConversionType.ProjectSilverlight2] = upgradeProjectDialog.SelectedSilverlightVersion;
                    this.VersionMapping[ConversionType.ProjectSilverlight3] = upgradeProjectDialog.SelectedSilverlightVersion;
                    this.VersionMapping[ConversionType.ProjectWpf30]        = upgradeProjectDialog.SelectedDotNetVersion;
                    this.VersionMapping[ConversionType.ProjectWpf35]        = upgradeProjectDialog.SelectedDotNetVersion;
                    proposedUpgrades = this.GetProposedUpgrades(conversionMapping);
                }
                return(UpgradeWizard.UpgradeResponse.Upgrade);
            }

            case ProjectDialogResult.No:
            {
                return(UpgradeWizard.UpgradeResponse.DontUpgrade);
            }
            }
            return(UpgradeWizard.UpgradeResponse.Cancel);
        }
Esempio n. 14
0
        public override ConversionType GetVersion(ConversionTarget project)
        {
            ConversionType conversionType;

            this.silverlightSolution = false;
            this.sketchFlowSolution  = false;
            this.frameworkSolution   = false;
            if (!project.IsSolution)
            {
                return(ConversionType.Unknown);
            }
            using (IEnumerator <IProjectStore> enumerator = this.contextProjectStores.GetEnumerator())
            {
                do
                {
                    if (!enumerator.MoveNext())
                    {
                        break;
                    }
                    IProjectStore current             = enumerator.Current;
                    FrameworkName targetFrameworkName = ProjectStoreHelper.GetTargetFrameworkName(current);
                    if (targetFrameworkName == null)
                    {
                        continue;
                    }
                    if (!this.frameworkSolution && targetFrameworkName.Identifier == ".NETFramework")
                    {
                        this.frameworkSolution = true;
                    }
                    if (!this.silverlightSolution && targetFrameworkName.Identifier == "Silverlight")
                    {
                        this.silverlightSolution = true;
                    }
                    if (this.sketchFlowSolution || !ProjectStoreHelper.IsSketchFlowProject(current))
                    {
                        continue;
                    }
                    this.sketchFlowSolution = true;
                }while (!this.silverlightSolution || !this.sketchFlowSolution || !this.frameworkSolution);
            }
            if (!this.silverlightSolution && !this.frameworkSolution)
            {
                return(ConversionType.Unknown);
            }
            ILicenseService service = base.Services.GetService <ILicenseService>();

            if (this.sketchFlowSolution && service != null && !LicensingHelper.IsSketchFlowLicensed(service))
            {
                return(ConversionType.Unknown);
            }
            using (IEnumerator <ConversionTarget> enumerator1 = this.GetConversionTargets().GetEnumerator())
            {
                while (enumerator1.MoveNext())
                {
                    ConversionTarget conversionTarget = enumerator1.Current;
                    if (!ConversionHelper.CheckAndAddFile(conversionTarget, this.Converters, this.VersionMapping, true).Any <UpgradeAction>())
                    {
                        continue;
                    }
                    conversionType = ConversionType.SolutionBlendV3;
                    return(conversionType);
                }
                return(ConversionType.SolutionBlendV4);
            }
            return(conversionType);
        }