예제 #1
0
        /// <summary>
        /// Gets the context menu by a given <see cref="FrameworkType"/>.
        /// </summary>
        public Menu GetContextMenuByFrameworkType(FrameworkType frameworkType)
        {
            if (frameworkType == FrameworkType.Win32)
            {
                // The main menu is directly under the desktop with the name "Context" or in a few cases "System"
                var desktop       = FrameworkAutomationElement.Automation.GetDesktop();
                var nameCondition = ConditionFactory.ByName("Context").Or(ConditionFactory.ByName("System"));
                var ctxMenu       = desktop.FindFirstChild(cf => cf.ByControlType(ControlType.Menu).And(nameCondition)).AsMenu();
                if (ctxMenu != null)
                {
                    ctxMenu.IsWin32Menu = true;
                    return(ctxMenu);
                }
            }
            var mainWindow = GetMainWindow();

            if (frameworkType == FrameworkType.WinForms)
            {
                var ctxMenu = mainWindow.FindFirstChild(cf => cf.ByControlType(ControlType.Menu).And(cf.ByName("DropDown")));
                return(ctxMenu.AsMenu());
            }
            if (frameworkType == FrameworkType.Wpf)
            {
                // In WPF, there is a window (Popup) where the menu is inside
                var popup   = Popup;
                var ctxMenu = popup.FindFirstChild(cf => cf.ByControlType(ControlType.Menu));
                return(ctxMenu.AsMenu());
            }
            // No menu found
            return(null);
        }
        public void TestCreateResult()
        {
            const string        resultProjectId     = "result-project-id";
            AspNetVersion       resultVersion       = AspNetVersion.AspNetCore11;
            const FrameworkType resultFrameworkType = FrameworkType.NetCore;

            _targetSdkVersions.Add("2.0.0");
            _targetSdkVersions.Add("1.0.0");

            var objectUnderTest = new AspNetCoreTemplateChooserViewModel(_closeWindowMock.Object)
            {
                SelectedFramework = resultFrameworkType,
                SelectedVersion   = resultVersion,
                GcpProjectId      = resultProjectId,
                IsWebApi          = true
            };

            objectUnderTest.OkCommand.Execute(null);

            Assert.IsNotNull(objectUnderTest.Result);
            Assert.AreEqual(resultProjectId, objectUnderTest.Result.GcpProjectId);
            Assert.AreEqual(resultFrameworkType, objectUnderTest.Result.SelectedFramework);
            Assert.AreEqual(resultVersion, objectUnderTest.Result.SelectedVersion);
            Assert.AreEqual(AppType.WebApi, objectUnderTest.Result.AppType);
        }
예제 #3
0
        public TService Get(FrameworkType frameworkType)
        {
            if (!_isInitialized)
            {
                InitializeSimpleInjector(_dependency);
                InitializeWindsor(_dependency);
                InitializeMicrosoftDependencyInjection(_dependency);

                _isInitialized = true;
            }

            switch (frameworkType)
            {
            case FrameworkType.Native:
                return((TService)_aspectWeaver.Weave(new TImplementation(), typeof(TService),
                                                     typeof(TImplementation)));

            case FrameworkType.CastleWindsor:
                return(_windsorContainer.Resolve <TService>());

            case FrameworkType.SimpleInjector:
                return(_simpleInjectorContainer.GetInstance <TService>());

            case FrameworkType.MicrosoftDependencyInjection:
                return(_serviceProvider.GetService <TService>());

            default:
                throw new ArgumentOutOfRangeException(nameof(frameworkType), frameworkType, null);
            }
        }
예제 #4
0
 internal PropertySymbol(string name,
                         FrameworkType returnType,
                         CodeGenerationInformation codeGenerationInfo) : base(name)
 {
     ReturnType         = returnType;
     CodeGenerationInfo = codeGenerationInfo;
 }
        /// <summary>
        /// Gets the platform tests project.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="testingFramework">The testing framework.</param>
        /// <param name="nugetCommands">The nuget commands.</param>
        /// <param name="projectSuffix">The project suffix.</param>
        /// <param name="projectType">Type of the project.</param>
        /// <returns></returns>
        protected ProjectTemplateInfo GetPlatFormTestsProject(
            FrameworkType frameworkType,
            string testingFramework,
            IEnumerable<string> nugetCommands,
            bool preSelect,
            string projectSuffix,
            string projectType)
        {
            TraceService.WriteLine("BaseProjectFactory::GetPlatFormTestsProject");

            ProjectTemplateInfo projectTemplateInfo = this.GetTestsProject(
                frameworkType,
                testingFramework,
                nugetCommands,
                preSelect,
                projectSuffix,
                projectType);

            projectTemplateInfo.ReferenceCoreProject = false;
            projectTemplateInfo.ReferencePlatformProject = true;

            TraceService.WriteLine("BaseProjectFactory::GetPlatFormTestsProject End");

            return projectTemplateInfo;
        }
예제 #6
0
 public ResolverBase(ModuleDefinition module, ISimpleDeobfuscator simpleDeobfuscator, IDeobfuscator deob)
 {
     this.module = module;
     this.frameworkType = DotNetUtils.getFrameworkType(module);
     this.simpleDeobfuscator = simpleDeobfuscator;
     this.deob = deob;
 }
예제 #7
0
 public ResolverBase(ModuleDefMD module, ISimpleDeobfuscator simpleDeobfuscator, IDeobfuscator deob)
 {
     this.module             = module;
     frameworkType           = DotNetUtils.GetFrameworkType(module);
     this.simpleDeobfuscator = simpleDeobfuscator;
     this.deob = deob;
 }
예제 #8
0
 public AssemblyResolver(ModuleDefinition module, DecrypterType decrypterType)
 {
     this.module = module;
     this.frameworkType = DotNetUtils.getFrameworkType(module);
     this.decrypterType = decrypterType;
     this.codeCompilerMethodCallRestorer = new CodeCompilerMethodCallRestorer(module);
 }
예제 #9
0
 public AssemblyResolver(ModuleDefMD module, DecrypterType decrypterType)
 {
     this.module        = module;
     this.frameworkType = DotNetUtils.GetFrameworkType(module);
     this.decrypterType = decrypterType;
     this.codeCompilerMethodCallRestorer = new CodeCompilerMethodCallRestorer(module);
 }
        /// <summary>
        /// Gets the versions available for specified version of Visual Studio and Framework type.
        /// </summary>
        /// <param name="framework">The <see cref="FrameworkType"/> that will run this template.</param>
        /// <returns>A new list of AspNetVersions from which are compatible with the vsVersion and framework.</returns>
        public static IList <AspNetVersion> GetAvailableVersions(FrameworkType framework)
        {
            switch (framework)
            {
            case FrameworkType.NetFramework:
                return(new List <AspNetVersion> {
                    AspNet4
                });

            case FrameworkType.NetCore:
                switch (GoogleCloudExtensionPackage.VsVersion)
                {
                case VsVersionUtils.VisualStudio2015Version:
                    return(GetVs2015AspNetCoreVersions());

                default:
                    // For forward compatibility, give future versions of VS the same options as VS2017.
                    return(GetVs2017AspNetCoreVersions());
                }

            case FrameworkType.None:
                return(new List <AspNetVersion>());

            default:
                throw new InvalidOperationException($"Unknown Famework type: {framework}");
            }
        }
예제 #11
0
파일: FrameworkIds.cs 프로젝트: ywscr/FlaUI
 /// <summary>
 /// Converts a <see cref="FrameworkType"/> to a string.
 /// </summary>
 /// <param name="frameworkType">The <see cref="FrameworkType"/> to convert.</param>
 /// <returns>The matched string.</returns>
 public static string Convert(FrameworkType frameworkType)
 {
     if (TypeMapping.TryGetValue(frameworkType, out var frameworkId))
     {
         return(frameworkId);
     }
     return(null);
 }
예제 #12
0
 internal ImplicitConversionSymbol(FrameworkType sourceType,
                                   FrameworkType returnType,
                                   CodeGenerationInformation codeGenerationInfo)
 {
     SourceType         = sourceType;
     ReturnType         = returnType;
     CodeGenerationInfo = codeGenerationInfo;
 }
예제 #13
0
        public async Task ThrowException_In_OnSuccessBlock_ShouldFaultInvocation(FrameworkType frameworkType)
        {
            // Arrange
            var service = _serviceProvider.Get(frameworkType);

            // Act & Assert
            await Assert.ThrowsAsync <ArgumentNullException>(async() => await service.ShouldThrowArgumentNullExceptionAsync(10));
        }
        public void ThrowException_In_OnSuccessBlock_ShouldFaultInvocation(FrameworkType frameworkType)
        {
            // Arrange
            var service = _serviceProvider.Get(frameworkType);

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => service.ShouldThrowArgumentNullException(10));
        }
 public GraphicsBaseTestMethods(FrameworkType frameworkType)
 {
     MockDataPng = new MockData <PngMockData>(frameworkType);
     MockDataJpg = new MockData <JpgMockData>(frameworkType);
     MockDataGif = new MockData <GifMockData>(frameworkType);
     MockDataBmp = new MockData <BmpMockData>(frameworkType);
     MockDataTif = new MockData <TifMockData>(frameworkType);
 }
예제 #16
0
 internal TypeSymbol(string name,
                     FrameworkType frameworkType,
                     IList <ImplicitConversionSymbol>?implicitConversions = null,
                     IList <PropertySymbol>?properties = null) : base(name)
 {
     FrameworkType       = frameworkType;
     ImplicitConversions = implicitConversions.MakeReadOnly();
     Properties          = properties.MakeReadOnly();
 }
예제 #17
0
 internal FunctionSymbol(string name,
                         FrameworkType returnType,
                         CodeGenerationInformation codeGenerationInfo,
                         IList <ParameterSymbol>?parameters = null) : base(name)
 {
     ReturnType         = returnType;
     CodeGenerationInfo = codeGenerationInfo;
     Parameters         = parameters.MakeReadOnly();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Framework"/> class.
 /// </summary>
 /// <param name="name">The framework namr.</param>
 /// <param name="type">The framework type.</param>
 /// <param name="major">The framework major version.</param>
 /// <param name="minor">The framework minor version.</param>
 public Framework(string name, FrameworkType type, int major, int minor)
 {
     Name         = name;
     Type         = type;
     Major        = major;
     Minor        = minor;
     Moniker      = FrameworkMoniker.none;
     MonikerMajor = -1;
     MonikerMinor = -1;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Framework"/> class.
 /// </summary>
 /// <param name="name">The framework namr.</param>
 /// <param name="type">The framework type.</param>
 /// <param name="major">The framework major version.</param>
 /// <param name="minor">The framework minor version.</param>
 /// <param name="moniker">The target framework moniker (TFM).</param>
 /// <param name="monikerMajor">The moniker major version.</param>
 /// <param name="monikerMinor">The moniker minor version.</param>
 public Framework(string name, FrameworkType type, int major, int minor, FrameworkMoniker moniker, int monikerMajor, int monikerMinor)
 {
     Name         = name;
     Type         = type;
     Major        = major;
     Minor        = minor;
     Moniker      = moniker;
     MonikerMajor = monikerMajor;
     MonikerMinor = monikerMinor;
 }
예제 #20
0
 internal UnaryOperationSymbol(Operator @operator,
                               FrameworkType operandType,
                               FrameworkType returnType,
                               CodeGenerationInformation codeGenerationInfo)
 {
     Operator           = @operator;
     OperandType        = operandType;
     ReturnType         = returnType;
     CodeGenerationInfo = codeGenerationInfo;
 }
 internal TemplateChooserViewModelResult(
     string gcpProjectId,
     FrameworkType selectedFramework,
     AspNetVersion selectedVersion,
     AppType appType)
 {
     GcpProjectId      = gcpProjectId;
     SelectedFramework = selectedFramework;
     SelectedVersion   = selectedVersion;
     AppType           = appType;
 }
        /// <summary>
        /// Gets the view template.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="pageType">Type of the page.</param>
        /// <returns>The View Template.</returns>
        protected string GetViewTemplate(
            FrameworkType frameworkType,
            string pageType)
        {
            if (frameworkType == FrameworkType.XamarinForms)
            {
                return("BlankView.t4");
            }

            return($"{pageType}View.t4");
        }
        /// <summary>
        /// Gets the test view model template.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="pageType">Type of the page.</param>
        /// <returns>
        /// The Test View Model Template.
        /// </returns>
        internal string GetTestViewModelTemplate(
            FrameworkType frameworkType,
            string pageType)
        {
            if (pageType == ViewType.SampleData.GetDescription())
            {
                return(frameworkType == FrameworkType.XamarinForms ? "TestSampleDataViewModel.t4" : "TestMvxSampleDataViewModel.t4");
            }

            return(pageType == ViewType.Web.GetDescription() ? "TestWebViewModel.t4" : "TestBlankViewModel.t4");
        }
        public void SwallowException_In_OnExceptionBlock_ShouldReturnDefault(FrameworkType frameworkType)
        {
            // Arrange
            var service = _serviceProvider.Get(frameworkType);

            // Act
            var result = service.ShouldNotThrowArgumentException();

            // Assert
            Assert.Equal(0, result);
        }
        public void OnEntry_ReturnValue_ShouldNotTriggerMethod_Invocation(FrameworkType frameworkType)
        {
            // Arrange
            var service = _serviceProvider.Get(frameworkType);

            // Act
            var result = service.ShouldReturnNewObjectInsteadOfNull();

            // Assert
            Assert.NotNull(result);
        }
        public void OnSuccess_ChangeReturnResult_By_ReturnValueProp(FrameworkType frameworkType)
        {
            // Arrange
            var service = _serviceProvider.Get(frameworkType);

            // Act
            var result = service.ShouldReturnArgumentPlusOne(10);

            // Assert
            Assert.Equal(11, result);
        }
예제 #27
0
 internal BinaryOperationSymbol(Operator @operator,
                                FrameworkType leftType,
                                FrameworkType rightType,
                                FrameworkType returnType,
                                CodeGenerationInformation codeGenerationInfo)
 {
     Operator           = @operator;
     LeftType           = leftType;
     RightType          = rightType;
     ReturnType         = returnType;
     CodeGenerationInfo = codeGenerationInfo;
 }
        public void Test_ExceptionChain_Correct(FrameworkType frameworkType)
        {
            // Arrange
            var parser = _parserProvider.Get(frameworkType);

            // Act & Assert
            var exception = Assert.Throws <InvalidOperationException>(() => parser.Parse(""));

            Assert.IsType <ApplicationException>(exception.InnerException);
            Assert.IsType <ArgumentException>(exception.InnerException.InnerException);
            Assert.IsType <Exception>(exception.InnerException.InnerException.InnerException);
        }
예제 #29
0
                internal FrameworkInfo()
                {
                    Assembly     xnaAssembly     = typeof(Microsoft.Xna.Framework.Vector2).Assembly;
                    AssemblyName xnaAssemblyName = xnaAssembly.GetName();

                    this.Version = xnaAssemblyName.Version;
                    this.Name    = xnaAssemblyName.Name;

                    Type monoType = Assembly.GetEntryAssembly().GetType("MonoGame.Framework.Utilities.PlatformInfo");

                    this.Type = (monoType == null) ? FrameworkType.XNA : FrameworkType.MonoGame;
                }
예제 #30
0
        /// <summary>
        /// Gets the application framework.
        /// </summary>
        /// <returns>The Framework Type.</returns>
        public FrameworkType GetApplicationFramework()
        {
            FrameworkType frameworkType = this.visualStudioService.GetFrameworkType();

            if (frameworkType == FrameworkType.NotSet)
            {
                //// new solution
                frameworkType = this.settingsService.FrameworkType;
            }

            return(frameworkType);
        }
        public void Test_ExceptionThrowed_BaseService_Resolve(FrameworkType frameworkType)
        {
            // Arrange
            var executor = _commandExecutorBaseProvider.Get(frameworkType);
            var action   = new IdentityCommand <int>();

            // Act
            var exception = Assert.Throws <ArgumentException>(
                () => executor.ExecuteAction(action, throwOnException: true));

            // Assert
            Assert.IsType <Exception>(exception.InnerException);
        }
예제 #32
0
        private void SetNet4Version(AssemblyDefinition assemblyDefinition)
        {
            NetFrameworkVersion   = new Version(0, 0);
            AssemblyFrameworkType = FrameworkType.Unknown;

            var targetFrameworkAttribute = assemblyDefinition.CustomAttributes.FirstOrDefault(x =>
                                                                                              x.AttributeType.FullName == "System.Runtime.Versioning.TargetFrameworkAttribute");

            if (targetFrameworkAttribute == null)
            {
                return;
            }

            if (targetFrameworkAttribute.ConstructorArguments.Count < 1)
            {
                return;
            }

            if (targetFrameworkAttribute.ConstructorArguments[0].Type.Name != "String")
            {
                return;
            }

            string versionInfo = (string)targetFrameworkAttribute.ConstructorArguments[0].Value;

            var values = versionInfo.Split(',');



            foreach (var value in values)
            {
                if (value.StartsWith(".NET"))
                {
                    AssemblyFrameworkType = value switch
                    {
                        ".NETFramework" => FrameworkType.NetFramework,
                        ".NETCoreApp" => FrameworkType.NetCore,
                        ".NETStandard" => FrameworkType.NetStandard,
                        _ => FrameworkType.Unknown
                    };
                }
                else if (value.StartsWith("Version=v"))
                {
                    try
                    {
                        NetFrameworkVersion = new Version(value.Substring("Version=v".Length));
                    }
                    catch { }
                }
            }
        }
        public static DotNetFramework Get(FrameworkType type, Version version)
        {
            var key = new FrameworkKey(type, version);

            DotNetFramework framework;

            if (!_frameworks.TryGetValue(key, out framework))
            {
                framework = Create(type, version);
                _frameworks.Add(key, framework);
            }

            return(framework);
        }
        /// <summary>
        /// Gets the allowed projects.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <returns>
        /// The allowed projects.
        /// </returns>
        public IEnumerable<ProjectTemplateInfo> GetAllowedProjects(FrameworkType frameworkType)
        {
            TraceService.WriteLine("ProjectFactory::GetAllowedProjects");

            switch (frameworkType)
            {
                case FrameworkType.NoFramework:
                    return this.resolverService.Resolve<INoFrameworkProjectFactory>().GetAllowedProjects();

                case FrameworkType.MvvmCross:
                    return this.resolverService.Resolve<IMvvmCrossProjectFactory>().GetAllowedProjects();

                case FrameworkType.XamarinForms:
                    return this.resolverService.Resolve<XamarinFormsProjectFactory>().GetAllowedProjects();

                default:
                    return this.resolverService.Resolve<MvvmCrossAndXamarinFormsProjectFactory>().GetAllowedProjects();
            }
        }
예제 #35
0
 public TamperDetection(ModuleDefinition module)
 {
     this.module = module;
     frameworkType = DotNetUtils.getFrameworkType(module);
 }
        /// <summary>
        /// Gets the view model template.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="pageType">Type of the page.</param>
        /// <returns>
        /// The View Model Template.
        /// </returns>
        internal string GetViewModelTemplate(
            FrameworkType frameworkType,
            string pageType)
        {
            if (pageType == ViewType.SampleData.GetDescription())
            {
                return frameworkType == FrameworkType.XamarinForms ? "SampleDataViewModel.t4" : "MvxSampleDataViewModel.t4";
            }

            return pageType == ViewType.Web.GetDescription() ? "WebViewModel.t4" : "BlankViewModel.t4";
        }
예제 #37
0
		public VersionDetector(ModuleDefMD module, StringDecrypter stringDecrypter) {
			this.stringDecrypter = stringDecrypter;
			this.frameworkType = DotNetUtils.GetFrameworkType(module);
		}
        /// <summary>
        /// Gets the core tests project.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="testingFramework">The testing framework.</param>
        /// <param name="nugetCommands">The nuget commands.</param>
        /// <param name="preSelect">if set to <c>true</c> [pre select].</param>
        /// <param name="projectSuffix">The project suffix.</param>
        /// <param name="projectType">Type of the project.</param>
        /// <returns>
        /// A unit tests project.
        /// </returns>
        protected ProjectTemplateInfo GetTestsProject(
            FrameworkType frameworkType,
            string testingFramework,
            IEnumerable<string> nugetCommands,
            bool preSelect,
            string projectSuffix,
            string projectType)
        {
            TraceService.WriteLine("BaseProjectFactory::GetTestsProject");

            string friendlyName = projectType;

            string templateName = ProjectTemplate.NUnitTests.GetDescription();

            if (testingFramework == TestingConstants.MsTest.Name)
            {
                templateName = ProjectTemplate.MsTestTests.GetDescription();
            }

            if (frameworkType == FrameworkType.MvvmCross ||
                frameworkType == FrameworkType.MvvmCrossAndXamarinForms)
            {
                templateName = ProjectTemplate.NUnitTests.GetDescription();

                if (testingFramework == TestingConstants.MsTest.Name)
                {
                    templateName = ProjectTemplate.MsTestTests.GetDescription();
                }
            }

            TraceService.WriteLine("BaseProjectFactory::GetTestsProject End");

            return new ProjectTemplateInfo
            {
                FriendlyName = friendlyName,
                ProjectSuffix = projectSuffix,
                TemplateName = templateName,
                PreSelected = preSelect,
                ReferenceCoreProject = true,
                NugetCommands = nugetCommands
            };
        }
        /// <summary>
        /// Gets the core tests project.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="testingFramework">The testing framework.</param>
        /// <param name="nugetCommands">The nuget commands.</param>
        /// <param name="preSelect">if set to <c>true</c> [pre select].</param>
        /// <param name="projectSuffix">The project suffix.</param>
        /// <param name="projectType">Type of the project.</param>
        /// <returns>
        /// A unit tests project.
        /// </returns>
        protected ProjectTemplateInfo GetTestsProject(
            FrameworkType frameworkType,
            string testingFramework,
            IEnumerable<string> nugetCommands,
            bool preSelect,
            string projectSuffix,
            string projectType)
        {
            string friendlyName = projectType;

            string templateName = ProjectTemplate.NUnitTests.GetDescription();

            if (testingFramework == TestingConstants.MsTest.Name)
            {
                templateName = ProjectTemplate.MsTestTests.GetDescription();
            }

            if (frameworkType.IsMvvmCrossSolutionType())
            {
                templateName = ProjectTemplate.NUnitTests.GetDescription();

                if (testingFramework == TestingConstants.MsTest.Name)
                {
                    templateName = ProjectTemplate.MsTestTests.GetDescription();
                }
            }

            return new ProjectTemplateInfo
            {
                FriendlyName = friendlyName,
                ProjectSuffix = projectSuffix,
                TemplateName = templateName,
                PreSelected = preSelect,
                ReferenceCoreProject = true,
                NugetCommands = nugetCommands
            };
        }
        /// <summary>
        /// Gets the platform tests project.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="testingFramework">The testing framework.</param>
        /// <param name="nugetCommands">The nuget commands.</param>
        /// <param name="preSelect">if set to <c>true</c> [pre select].</param>
        /// <param name="projectSuffix">The project suffix.</param>
        /// <param name="projectType">Type of the project.</param>
        protected ProjectTemplateInfo GetPlatFormTestsProject(
            FrameworkType frameworkType,
            string testingFramework,
            IEnumerable<string> nugetCommands,
            bool preSelect,
            string projectSuffix,
            string projectType)
        {
            ProjectTemplateInfo projectTemplateInfo = this.GetTestsProject(
                frameworkType,
                testingFramework,
                nugetCommands,
                preSelect,
                projectSuffix,
                projectType);

            projectTemplateInfo.ReferenceCoreProject = false;
            projectTemplateInfo.ReferencePlatformProject = true;

            return projectTemplateInfo;
        }
        /// <summary>
        /// Gets the view template.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="type">The type.</param>
        /// <param name="pageType">Type of the page.</param>
        /// <returns>
        /// The View Template.
        /// </returns>
        internal string GetViewTemplate(
            FrameworkType frameworkType,
            string type,
            string pageType)
        {
            if (frameworkType == FrameworkType.XamarinForms)
            {
                return "Xamarin.Forms.View.Blank.zip";
            }

            return string.Format(
                "MvvmCross{0}.View.{1}.zip",
                type,
                pageType);
        }
        /// <summary>
        /// Gets the project items.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="projectType">Type of the project.</param>
        /// <returns>A list of TextTemplateInfos.</returns>
        protected IEnumerable<TextTemplateInfo> GetProjectItems(
            FrameworkType frameworkType,
            ProjectType projectType)
        {
            string uri = string.Empty;

            switch (frameworkType)
            {
                case FrameworkType.NoFramework:
                    uri = this.SettingsService.NoFrameworkProjectsUri;
                    break;

                case FrameworkType.MvvmCross:
                    uri = this.SettingsService.MvvmCrossProjectsUri;
                    break;

                case FrameworkType.XamarinForms:
                    uri = this.SettingsService.XamarinFormsProjectsUri;
                    break;

                case FrameworkType.MvvmCrossAndXamarinForms:
                    uri = this.SettingsService.MvvmCrossAndXamarinFormsProjectsUri;
                    break;
            }

            if (uri != string.Empty)
            {
                IEnumerable<ProjectTemplateInfo> projectTemplateInfos = this.GetPojectTemplateInfos(uri);

                ProjectTemplateInfo projectTemplateInfo = projectTemplateInfos.FirstOrDefault(x => x.Name == projectType.ToString());

                if (projectTemplateInfo != null)
                {
                    return projectTemplateInfo.ItemTemplates;
                }
            }

            return new List<TextTemplateInfo>();
        }
        /// <summary>
        /// Gets the test view model template.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="pageType">Type of the page.</param>
        /// <returns>
        /// The Test View Model Template.
        /// </returns>
        internal string GetTestViewModelTemplate(
            FrameworkType frameworkType,
            string pageType)
        {
            if (frameworkType == FrameworkType.XamarinForms)
            {
                return string.Format(
                    "MvvmCross.{0}.TestViewModel.Blank.zip",
                    this.settingsService.TestingFramework);
            }

            return string.Format(
                "MvvmCross.{0}.TestViewModel.{1}.zip",
                this.settingsService.TestingFramework,
                pageType);
        }
        /// <summary>
        /// Gets the view model template.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="pageType">Type of the page.</param>
        /// <returns>
        /// The View Model Template.
        /// </returns>
        internal string GetViewModelTemplate(
            FrameworkType frameworkType,
            string pageType)
        {
            if (frameworkType == FrameworkType.XamarinForms)
            {
                return string.Format("XamarinForms.ViewModel.Blank.zip");
            }

            return string.Format(
                "MvvmCross.ViewModel.{0}.zip",
                pageType);
        }
        /// <summary>
        /// Gets the view template.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <param name="pageType">Type of the page.</param>
        /// <returns>The View Template.</returns>
        protected string GetViewTemplate(
            FrameworkType frameworkType, 
            string pageType)
        {
            if (frameworkType == FrameworkType.XamarinForms)
            {
                return "BlankView.t4";
            }

            return $"{pageType}View.t4";
        }
예제 #46
0
		public ResourceDecrypter(ModuleDefMD module, ISimpleDeobfuscator simpleDeobfuscator) {
			this.module = module;
			frameworkType = DotNetUtils.GetFrameworkType(module);
			Find(simpleDeobfuscator);
		}
        /// <summary>
        /// Gets the route modifier.
        /// </summary>
        /// <param name="frameworkType">Type of the framework.</param>
        /// <returns>The RouteModifier.</returns>
        public RouteModifier GetRouteModifier(FrameworkType frameworkType)
        {
            RouteModifier routeModifier = new RouteModifier
                                              {
                                                  ExcludeViewTypes = new List<Type>()
                                              };

            //// if no framework we cant setup up the viewmodels and views.
            if (frameworkType == FrameworkType.NoFramework)
            {
                routeModifier.ExcludeViewTypes.Add(typeof(ViewsControl));
                routeModifier.ExcludeViewTypes.Add(typeof(PluginsControl));
            }

            if (frameworkType == FrameworkType.XamarinForms)
            {
                routeModifier.ExcludeViewTypes.Add(typeof(PluginsControl));
            }

            if (this.cachingService.HasNinjaNugetPackages == false &&
                this.cachingService.HasNinjaCommunityNugetPackages == false &&
                this.cachingService.HasLocalNugetPackages == false)
            {
                routeModifier.ExcludeViewTypes.Add(typeof(NinjaCoderOptionsControl));
            }

            IEnumerable<Plugin> samplePlugins = this.cachingService.ApplicationSamplePlugIns;

            if (samplePlugins != null &&
                samplePlugins.Any() == false)
            {
                routeModifier.ExcludeViewTypes.Add(typeof(ApplicationSamplesOptionsControl));
            }

            if (this.cachingService.XamarinFormsLabsNugetPackageRequested == false)
            {
                routeModifier.ExcludeViewTypes.Add(typeof(XamarinFormsLabsControl));
            }

            if (this.settingsService.AddProjectsSkipViewOptions)
            {
                routeModifier.ExcludeViewTypes.Add(typeof(ViewsControl));
            }

            if (this.settingsService.AddProjectsSkipNinjaCoderOptions)
            {
                routeModifier.ExcludeViewTypes.Add(typeof(NinjaCoderOptionsControl));
            }

            if (this.settingsService.AddProjectsSkipApplicationOptions)
            {
                routeModifier.ExcludeViewTypes.Add(typeof(ApplicationOptionsControl));
                routeModifier.ExcludeViewTypes.Add(typeof(ApplicationSamplesOptionsControl));
            }

            if (this.settingsService.AddProjectsSkipMvvmCrossPluginOptions)
            {
                routeModifier.ExcludeViewTypes.Add(typeof(PluginsControl));
            }

            if (this.settingsService.AddProjectsSkipNugetPackageOptions)
            {
                routeModifier.ExcludeViewTypes.Add(typeof(NugetPackagesControl));
            }

            return routeModifier;
        }