Esempio n. 1
0
        static bool CheckSLMigrationLicense(ILogger logger, string activationAppPath, HashSet <string> flags)
        {
            //if the user tries to use the SL Migration edition, we check whether it is allowed or not here even though it has nothing to do with the Xaml Preprocessor because it is the only thing that the user cannot remove from the targets.
            if (!ActivationHelpers.IsFeatureEnabled(Constants.ENTERPRISE_EDITION_FEATURE_ID, flags) && !ActivationHelpers.IsFeatureEnabled(Constants.SL_MIGRATION_EDITION_FEATURE_ID, flags))
            {
                // Display the ActivationApp:
                string explanationToDisplayInActivationApp = string.Format("You need the Silverlight Migration Edition in order to compile Silverlight-compatible projects.");
                string explanationToDisplayInErrorsWindow  = explanationToDisplayInActivationApp + " It can be obtained from http://www.cshtml5.com - Please rebuild the project to try again.";
                ActivationHelpers.DisplayActivationApp(activationAppPath, Constants.SL_MIGRATION_EDITION_FEATURE_ID, explanationToDisplayInActivationApp);

                // If we are in trial mode, we can continue without displaying any errors, otherwise we must stop compilation and raise the error:
                int unused;
                if (TrialHelpers.IsTrial(Constants.SL_MIGRATION_EDITION_FEATURE_ID, out unused) == TrialHelpers.TrialStatus.Running) //Note: we don't check for the enterprise edition since there is no trial for this edition.
                {
                    //do nothing
                    return(true);
                }
                else
                {
                    logger.WriteError(explanationToDisplayInErrorsWindow);
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 2
0
        public void OnLoaded()
        {
            //LicenseCheckerBrowserContainer.Visibility = Visibility.Visible;
            bool onLoginPage = Browser.URL == LoginURL;

            if (_needToRedirectAfterLogout)
            {
                if (onLoginPage)
                {
                    _needToRedirectAfterLogout = false;
                    return;
                }
                Browser.LoadURL(LoginURL);
                return;
            }

            if (onLoginPage)
            {
                _wasLogged = IsLogged();
                ButtonGoToLoginPage.Visibility = Visibility.Collapsed;
            }
            else
            {
                MainWindow.ButtonProfil.Visibility = Visibility.Collapsed;
                ButtonKeyActivation.Visibility     = Visibility.Collapsed;
                ButtonHobbyist.Visibility          = Visibility.Collapsed;
                ButtonGoToLoginPage.Visibility     = Visibility.Visible;
            }

            UpdateUsername();
            if (IsLogged())
            {
                // we check activated keys
                if (IsCommercialKeyActivated())
                {
                    OnCommercialKeyActivated();
                    Enable = false;
                }
                // we check for the community key
                else if (IsCommunityKeyActivated())
                {
                    Enable = false;
                }
                // we check for trial versions
                else
                {
                    TrialHelpers.TrialStatus trialStatus;
                    do
                    {
                        trialStatus = TrialHelpers.IsTrial(TrialFeatureID, out _numberOfTrialDaysLeft);
                        switch (trialStatus)
                        {
                        case TrialHelpers.TrialStatus.NotStarted:
                            StartTrial(TrialFeatureID);
                            break;

                        case TrialHelpers.TrialStatus.Running:
                            OnTrialRunning(TrialFeatureID);
                            break;

                        case TrialHelpers.TrialStatus.Expired:
                            OnTrialExpired(TrialFeatureID);
                            break;

                        default:
                            break;
                        }
                    } while (trialStatus == TrialHelpers.TrialStatus.NotStarted);
                }
            }
            else if (_wasLogged)
            {
                if (onLoginPage)
                {
                    LogOut();
                    _needToRedirectAfterLogout = true;
                }
            }
        }
Esempio n. 3
0
        public static bool Check(Microsoft.Build.Framework.ITaskItem[] references, string allowedReferencesAsString, string activationAppPath, string flagsString, ILogger logger, bool isBridgeBasedVersion, string nameOfAssembliesThatDoNotContainUserCode, string projectDir, string referencesPaths, string typeForwardingAssemblyPath)
        {
            List <string> referencesThatAreOK            = new List <string>();
            List <string> referencesThatAreNotCompatible = new List <string>();

#if REQUIRE_PRO_EDITION_FOR_REFERENCING_ASSEMBLIES
            List <string> referencesThatRequireToUpgradeToTheProEdition = new List <string>();
#endif
            List <string> referencesThatRequireNewerVersionOfTheCompiler          = new List <string>();
            string        overall_minimumRequiredCompilerVersionFriendlyNameIfAny = null;

            HashSet <string> flags = (flagsString != null ? new HashSet <string>(flagsString.Split(';')) : new HashSet <string>());

            foreach (Microsoft.Build.Framework.ITaskItem taskItem in (references ?? new Microsoft.Build.Framework.ITaskItem[] { }))
            {
                string referencedName          = GetAssemblyNameFromIdentity(taskItem.GetMetadata("identity")); //Note: "GetMetadata" and "GetAssemblyName" never return null.
                string referencedHintPathIfAny = taskItem.GetMetadata("HintPath");                              //Note: "GetMetadata" never return null.

                ResultEnum result;
                string     minimumRequiredCompilerVersionFriendlyNameIfAny;
                IsReferenceAcceptable(referencedName, referencedHintPathIfAny, allowedReferencesAsString, flags, isBridgeBasedVersion, nameOfAssembliesThatDoNotContainUserCode, projectDir, referencesPaths, typeForwardingAssemblyPath, out result, out minimumRequiredCompilerVersionFriendlyNameIfAny);
                switch (result)
                {
                case ResultEnum.ReferenceIsOK:
                    referencesThatAreOK.Add(referencedName);
                    break;

                case ResultEnum.ReferenceIsNotCompatible:
                    referencesThatAreNotCompatible.Add(referencedName);
                    break;

                case ResultEnum.ReferenceRequiresNewerVersionOfTheCompiler:
                    referencesThatRequireNewerVersionOfTheCompiler.Add(referencedName);
                    overall_minimumRequiredCompilerVersionFriendlyNameIfAny = minimumRequiredCompilerVersionFriendlyNameIfAny;
                    break;

#if REQUIRE_PRO_EDITION_FOR_REFERENCING_ASSEMBLIES
                case ResultEnum.ReferenceRequiresToUpgradeToTheProEdition:
                    referencesThatRequireToUpgradeToTheProEdition.Add(referencedName);
                    break;
#endif
                default:
                    throw new NotSupportedException();
                }
            }

            if (referencesThatAreNotCompatible.Count == 1)
            {
                logger.WriteError(string.Format("Please remove the reference \"{0}\" from the Project references.  - Note: a CSHTML5 project can only reference assemblies compiled with CSHTML5. Sometimes Visual Studio automatically adds references such as \"System\" but those references should be removed. Other errors below can be ignored.", referencesThatAreNotCompatible[0]));
                return(false);
            }
            else if (referencesThatAreNotCompatible.Count > 1)
            {
                logger.WriteError(string.Format("Please remove the following references from the Project references: {0}  - Note: a CSHTML5 project can only reference assemblies compiled with CSHTML5. Sometimes Visual Studio automatically adds references such as \"System\" but those references should be removed. Other errors below can be ignored.", string.Join(", ", referencesThatAreNotCompatible)));
                return(false);
            }
            else if (referencesThatRequireNewerVersionOfTheCompiler.Count > 0)
            {
                if (referencesThatRequireNewerVersionOfTheCompiler.Count == 1)
                {
                    logger.WriteError(string.Format("The referenced assembly '{1}' requires a newer version of the CSHTML5 compiler ({0} or newer). You can download it from: http://www.cshtml5.com", overall_minimumRequiredCompilerVersionFriendlyNameIfAny ?? "", referencesThatRequireNewerVersionOfTheCompiler[0]));
                }
                else
                {
                    logger.WriteError(string.Format("The following referenced assemblies require a newer version of the CSHTML5 compiler ({0} or newer): {1}", overall_minimumRequiredCompilerVersionFriendlyNameIfAny ?? "", string.Join(", ", referencesThatRequireNewerVersionOfTheCompiler)));
                }
                return(false);
            }
#if REQUIRE_PRO_EDITION_FOR_REFERENCING_ASSEMBLIES
            else if (referencesThatRequireToUpgradeToTheProEdition.Count > 0)
            {
                // Display the ActivationApp:
                string explanationToDisplayInActivationApp = string.Format("Referencing compiled DLLs such as '{0}' requires the Professional Edition of CSHTML5. You can work around this limitation if you have the source code of '{0}': just add the project to the solution and reference it instead of referencing the compiled DLL. With the Free Edition, projects can reference other projects in the same solution, but they cannot reference external compiled DLLs. Upgrade to the Pro Edition to remove all the limitations.", referencesThatRequireToUpgradeToTheProEdition[0] + ".dll");
                //string explanationToDisplayInActivationApp = string.Format("With the Free Edition, projects can reference other projects in the same solution, but referencing a compiled DLL such as \"{0}\" requires the Professional Edition of C#/XAML for HTML5.", referencesThatRequireToUpgradeToTheProEdition[0] + ".dll");
                string explanationToDisplayInErrorsWindow = explanationToDisplayInActivationApp + " It can be obtained from http://www.cshtml5.com - Please rebuild the project to try again.";
                ActivationHelpers.DisplayActivationApp(activationAppPath, Constants.PROFESSIONAL_EDITION_FEATURE_ID, explanationToDisplayInActivationApp);

                // If we are in trial mode, we can continue without displaying any errors, otherwise we must stop compilation and raise the error:
                int unused;
                if (TrialHelpers.IsTrial(Constants.SL_MIGRATION_EDITION_FEATURE_ID, out unused) == TrialHelpers.TrialStatus.Running)
                {
                    return(true);
                }
                else
                {
                    if (TrialHelpers.IsTrial(Constants.PROFESSIONAL_EDITION_FEATURE_ID, out unused) == TrialHelpers.TrialStatus.Running)
                    {
                        return(true);
                    }
                    else
                    {
                        logger.WriteError(explanationToDisplayInErrorsWindow);
                        return(false);
                    }
                }
            }
#endif
            else
            {
                return(true);
            }
        }