Beispiel #1
0
        public override RdProjectTemplateContent CreateContent(DotNetProjectTemplateExpander expander, IDotNetTemplateContentFactory factory,
                                                               int index, IDictionary <string, string> context)
        {
            var content   = factory.CreateNextParameters(new[] { expander }, index + 1, context);
            var parameter = expander.TemplateInfo.GetParameter(Name);

            if (parameter == null)
            {
                return(content);
            }

            var possiblePaths = myUnityMonoPathProvider.GetPossibleMonoPaths().Select(a => a.Directory.Combine("Managed/UnityEngine.dll")).Where(b => b.ExistsFile).ToArray();

            if (possiblePaths.IsEmpty())
            {
                return(new RdProjectTemplateInvalidParameter(Name, Name, "Unity installation is not found", null, null, null, content)); //TODO what is 'Message'?
            }

            var options = new List <RdProjectTemplateGroupOption>();

            foreach (var path in possiblePaths)
            {
                var optionContext = new Dictionary <string, string>(context)
                {
                    { Name, path.FullPath }
                };
                var content1 = factory.CreateNextParameters(new[] { expander }, index + 1, optionContext);
                options.Add(new RdProjectTemplateGroupOption(path.FullPath, path.FullPath, content1));
            }

            options.Add(new RdProjectTemplateGroupOption("Custom", "Custom",
                                                         new RdProjectTemplateTextParameter(Name, "Path", null, Tooltip, RdTextParameterStyle.FileChooser, content)));

            return(new RdProjectTemplateGroupParameter(Name, "UnityEngine", possiblePaths.Last().FullPath, Tooltip, options));
        }
        public override RdProjectTemplateContent CreateContent(DotNetProjectTemplateExpander expander, IDotNetTemplateContentFactory factory,
                                                               int index, IDictionary <string, string> context)
        {
            var content   = factory.CreateNextParameters(new[] { expander }, index + 1, context);
            var parameter = expander.TemplateInfo.GetParameter(Name);

            if (parameter == null)
            {
                return(content);
            }

            var defaultPath  = "";
            var possiblePath = myUnityMonoPathProvider.GetPossibleMonoPaths().Select(a => a.Directory.Combine("Managed/UnityEngine.dll")).FirstOrDefault(b => b.ExistsFile);

            if (possiblePath != null)
            {
                defaultPath = possiblePath.FullPath;
            }
            return(new RdProjectTemplateTextParameter(Name, defaultPath, Tooltip, RdTextParameterStyle.FileChooser, content));
        }