Пример #1
0
        protected virtual string CreateTemplatePath(TemplateType templateType, string templateName)
        {
            // プロジェクト側のファイルを走査
            var path = Path.Combine(
                UnityEngine.Application.dataPath,
                TemplateDirectory,
                templateType.ToString(),
                // Windows 用に念のためディレクトリセパレータを置換
                templateName.Replace("/", Path.DirectorySeparatorChar.ToString()) + TemplateExtension
                );

            if (File.Exists(path))
            {
                return(path);
            }

            // umm 側のファイルを走査
            path = Path.Combine(
                UnityEngine.Application.dataPath,
                ModuleDirectory,
                ModuleName,
                TemplateDirectory,
                templateType.ToString(),
                // Windows 用に念のためディレクトリセパレータを置換
                templateName.Replace("/", Path.DirectorySeparatorChar.ToString()) + TemplateExtension
                );
            if (File.Exists(path))
            {
                return(path);
            }

            throw new FileNotFoundException("Template file not found.", path);
        }
        private async Task <string> Generate(ClassDefinition definition, TemplateType templateType)
        {
            // Try to find template.
            var cached = engine.TemplateCache.RetrieveTemplate(templateType.ToString());

            if (cached.Success)
            {
                // If template exists render template
                return(await engine.RenderTemplateAsync(cached.Template.TemplatePageFactory(), definition));
            }

            // Compile and generate template
            return(await engine.CompileRenderAsync(templateType.ToString(),
                                                   templateDefinitions[templateType], definition));
        }
Пример #3
0
        public static void DeSerirlizeStyles(TemplateType templateType)
        {
            string stylepath = GetStylePath(templateType.ToString());

            if (File.Exists(stylepath))
            {
                System.IO.FileStream stream = System.IO.File.Open(stylepath, System.IO.FileMode.Open);

                try
                {
                    _AvailbleWizardStyles = Webb.Utilities.Serializer.DeserializeObject(stream) as  WizardCustomStylesCollection;
                }
                catch (Exception ex)
                {
                    Webb.Utilities.MessageBoxEx.ShowError("Failed to read style files!\n" + ex.Message);

                    Environment.Exit(-1);
                }
                finally
                {
                    stream.Close();
                }
            }
            else
            {
                _AvailbleWizardStyles = new WizardCustomStylesCollection();

                _AvailbleWizardStyles.TemplateType = templateType;
            }
        }
        public Task <IReadOnlyList <T> > LoadFromTemplateAsync <T>(TemplateType templateType)
        {
            _templateTypeDisplay = templateType.ToString();
            _view.Caption        = PKSimConstants.UI.LoadItemFromTemplate(_templateTypeDisplay);
            _shouldAddItemIcons  = !_templateTaskQuery.IsPrimitiveType(templateType);

            updateIcon(templateType);

            _availableTemplates.AddRange(_templateTaskQuery.AllTemplatesFor(templateType)
                                         .Where(x => x.IsSupportedByCurrentVersion(_configuration.Version))
                                         .OrderBy(x => x.Name));

            if (!_availableTemplates.Any())
            {
                throw new NoTemplateAvailableException(_templateTypeDisplay);
            }

            updateView();
            _view.Display();

            if (_view.Canceled)
            {
                return(Task.FromResult <IReadOnlyList <T> >(Array.Empty <T>()));
            }

            return(shouldLoadTemplateWithReferences(templateType) ? loadMultipleTemplate <T>() : loadSingleTemplate <T>());
        }
        public override string ToString()
        {
            var validChoiceString = ValidChoices.Select(x => "'{0}'".ToFormat(x)).Join(", ");

            return("Unknown {0} template '{1}', valid choices are {2}"
                   .ToFormat(TemplateType.ToString(), Name, validChoiceString));
        }
        public static void SetTemplateType(TemplateType templateType)
        {
            WebApplication.PreferredApplicationWindowTemplateType = templateType;
            HttpCookie userTemplateCookie = HttpContext.Current.Response.Cookies[PreferredTemplateCookieName];

            userTemplateCookie.Value   = templateType.ToString();
            userTemplateCookie.Expires = DateTime.Now.AddMonths(1);
            HttpContext.Current.Response.SetCookie(userTemplateCookie);
        }
        public IActionResult ProgramJson(TrainerLevelType level = TrainerLevelType.Intermediate,
                                         DaysType days          = DaysType.FourDays, TemplateType templateType = TemplateType.ABC)
        {
            var template = GetTemplate(level, days, templateType.ToString());
            var program  = new FitnessProgram {
                Template = template
            };

            return(new JsonResult(GetProgramViewModel(program)));
        }
Пример #8
0
 private static IEnumerable <string> GetEmbeddedTemplates(TemplateType templateType, string templateCategory)
 {
     foreach (var name in typeof(TemplateManager).Assembly.GetManifestResourceNames())
     {
         if (name.Contains(templateType.ToString()) && name.Contains(templateCategory))
         {
             yield return(name);
         }
     }
 }
Пример #9
0
 public override string ToString()
 {
     return(string.Format("Title: [{0}] Url: [{1}] TemplateType:[{2}] TemplateName:[{3}]",
                          new[] {
         Title,
         Url,
         TemplateType.ToString(),
         TemplateName
     }));
 }
Пример #10
0
        private static async Task <string> ReplaceTokensAsync(Project project,
                                                              string name,
                                                              string relative,
                                                              string templateFile,
                                                              TemplateType templateType,
                                                              string inputCamel)
        {
            if (string.IsNullOrEmpty(templateFile))
            {
                return(templateFile);
            }

            string rootNs = project.GetRootNamespace();
            string ns     = string.IsNullOrEmpty(rootNs) ? "MyNamespace" : rootNs;

            if (!string.IsNullOrEmpty(relative))
            {
                ns += "." + ProjectHelpers.CleanNameSpace(relative);
            }

            if (templateType.ToString().EndsWith("Dto") && !ns.EndsWith("Dto"))
            {
                ns += ".Dto";
            }

            using (var reader = new StreamReader(templateFile))
            {
                string content = await reader.ReadToEndAsync();

                content = content.Replace("{namespace}", ns)
                          .Replace("{classname}", name);

                if (templateType == TemplateType.Class || templateType == TemplateType.Interface)
                {
                    content = content.Replace("{entity}", inputCamel)
                              .Replace("{pageddto}", $"Paged{inputCamel}ResultRequestDto")
                              .Replace("{defaultdto}", $"{inputCamel}Dto")
                              .Replace("{createdto}", $"Create{inputCamel}Dto")
                              .Replace("{updatedto}", $"Update{inputCamel}Dto")
                              .Replace("{interface}", $"I{inputCamel}AppService")
                    ;
                }
                else if (templateType == TemplateType.MapProfile)
                {
                    content = content.Replace("{entity}", inputCamel)
                              .Replace("{defaultdto}", $"{inputCamel}Dto")
                              .Replace("{createdto}", $"Create{inputCamel}Dto")
                              .Replace("{updatedto}", $"Update{inputCamel}Dto")
                    ;
                }


                return(content);
            }
        }
        public DirectoryInfo[] ExtractBuiltinZip(TemplateType templateType)
        {
            var tempFilePath = Path.Combine(TempDirectory.FullName, $"{templateType.ToString()}.zip");

            File.WriteAllBytes(tempFilePath,
                               templateType == TemplateType.Module ? Resources.ModuleTemplates : Resources.SolutionTemplates);
            var extractPath = ExtractTemplateZipFile(tempFilePath,
                                                     Path.Combine(TempDirectory.FullName, $"{templateType.ToString().Substring(0, 2)}"));

            return(GetTemplateDirectories(extractPath));
        }
Пример #12
0
 public override string ToString()
 {
     return(string.Format("Title: [{0}] Url: [{1}] ContentTypesEnabled:[{4}] TemplateType:[{2}] TemplateName:[{3}]",
                          new[] {
         Title,
         Url,
         TemplateType.ToString(),
         TemplateName,
         ContentTypesEnabled.ToString()
     }));
 }
Пример #13
0
            StringBuilder GetSBTemplate(TemplateType templateType)
            {
                StringBuilder sb       = null;
                string        propName = templateType.ToString();

                if (!templateDic.TryGetValue(propName, out sb))
                {
                    sb = new StringBuilder();
                    templateDic.Add(propName, sb);
                }
                return(sb);
            }
Пример #14
0
        static IEnumerable <string> GetEmbeddedTemplates(TemplateType templateType, string templateCategory)
        {
            Assembly assy = LoadPlatformSpecificTemplateManagerAssembly();

            foreach (var name in assy.GetManifestResourceNames())
            {
                if (name.Contains(templateType.ToString()) && name.Contains(templateCategory))
                {
                    yield return(name);
                }
            }
        }
Пример #15
0
        public override string ToString()
        {
            return(string.Format("Title: [{0}] Url: [{1}] ContentTypesEnabled:[{4}] TemplateType:[{2}] TemplateName:[{3}]",
                                 new[] {
                Title,
#pragma warning disable 618
                string.IsNullOrEmpty(Url) ? CustomUrl : Url,
#pragma warning restore 618
                TemplateType.ToString(),
                TemplateName,
                ContentTypesEnabled.ToString()
            }));
        }
Пример #16
0
        private void createBuildingBlockTypeIfMissing(TemplateType templateType)
        {
            var keys = new Cache <string, string> {
                { TemplateTypeTable.Columns.TEMPLATE_TYPE, templateType.ToString() }
            };
            var newRow = createNewRow(TemplateTypeTable.NAME, keys);

            if (newRow.ExistsInDB())
            {
                return;
            }
            newRow.InsertIntoDB();
        }
Пример #17
0
        private void SaveTemplate()
        {
            string       base64 = string.Empty;
            TemplateType type   = TemplateType.Word;

            if (Template != null)
            {
                base64 = Template.ToBase64();
                type   = Template.Type;
            }
            ConfigData[ConstTemplateBase64String] = base64;
            ConfigData[ConstTemplateType]         = type.ToString();
        }
Пример #18
0
        private DASDataRow createTemplateRow(TemplateType templateType, string name)
        {
            var templateRow = createNewRow(TemplateTable.NAME,
                                           new[] { TemplateTable.Columns.TEMPLATE_TYPE, TemplateTable.Columns.NAME },
                                           new[] { templateType.ToString(), name }
                                           );

            if (templateRow.ExistsInDB())
            {
                templateRow.SelectFromDB();
                templateRow.AcceptChanges();
            }
            return(templateRow);
        }
Пример #19
0
        private void updateIcon(TemplateType templateType)
        {
            if (!_shouldAddItemIcons)
            {
                return;
            }

            var icon = ApplicationIcons.IconByName(templateType.ToString());

            if (icon != ApplicationIcons.EmptyIcon)
            {
                _view.SetIcon(icon);
            }
        }
Пример #20
0
        private string GetLocalizedTemplateTypeName(TemplateType templateType)
        {
            switch (templateType)
            {
            case TemplateType.Feature:
                return(StringRes.TemplateTypeFeature);

            case TemplateType.Page:
                return(StringRes.TemplateTypePage);

            case TemplateType.Project:
                return(StringRes.TemplateTypeProjectType);

            default:
                return(templateType.ToString());
            }
        }
Пример #21
0
        static IEnumerable <string> GetEmbeddedTemplates(TemplateType templateType, string templateCategory)
        {
            Assembly assy = null;

#if NETDESKTOP
            assy = typeof(TemplateManager).Assembly;
#else
            assy = typeof(TemplateManager).GetTypeInfo().Assembly;
#endif

            foreach (var name in assy.GetManifestResourceNames())
            {
                if (name.Contains(templateType.ToString()) && name.Contains(templateCategory))
                {
                    yield return(name);
                }
            }
        }
Пример #22
0
        private static String BaseQueryString(TemplateType type, dtoBaseTemplateOwner template)
        {
            String query = "type=" + type.ToString();

            if (template != null)
            {
                query += "&ownType=" + template.Type.ToString();
                query += ((template.IdPerson > 0) ? "&idPerson=" + template.IdPerson.ToString() : "");
                query += ((template.IdCommunity > 0) ? "&idCommunity=" + template.IdCommunity.ToString() : "");
                query += ((template.IdModule > 0) ? "&idModule=" + template.IdModule.ToString() : "");
                query += ((!String.IsNullOrEmpty(template.ModuleCode)) ? "&moduleCode=" + template.ModuleCode : "");
                query += ((template.ModulePermission > 0) ? "&idModuleP=" + template.ModulePermission.ToString() : "");
                query += ((template.IdObject > 0) ? "&idObj=" + template.IdObject.ToString() : "");
                query += ((template.IdObjectType > 0) ? "&idObjType=" + template.IdObjectType.ToString() : "");
                query += ((template.IdObjectModule > 0) ? "&idObjModule=" + template.IdObjectModule.ToString() : "");
                query += ((template.IdObjectCommunity > 0) ? "&idObjCommunity=" + template.IdObjectCommunity.ToString() : "");
            }
            return(query);
        }
Пример #23
0
        /// <summary>
        /// returns the template for the corresponding type
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        internal static TemplateFile findTemplate(TemplateType type)
        {
            if (SharpFactorySettings.Instance.templates == null ||
                SharpFactorySettings.Instance.templates.Count == 0)
            {
                return(null);
            }

            foreach (TemplateFile tf in SharpFactorySettings.Instance.templates)
            {
                if (tf.type == type)
                {
                    return(tf);
                }
            }

            Debug.LogError("No template file defined for " + type.ToString());

            return(null);
        }
Пример #24
0
        /// <summary>
        /// Get template data
        /// </summary>
        /// <param name="templateName"></param>
        /// <param name="templateType"></param>
        /// <returns></returns>
        public static ResultModel <string> GetTemplateBody(string templateName, TemplateType templateType = TemplateType.Html)
        {
            var result = new ResultModel <string>();

            if (string.IsNullOrEmpty(templateName))
            {
                throw new ArgumentNullException($"{nameof(templateName)} is null");
            }
            var path = $"Templates/{templateName}.{templateType.ToString().ToLower()}_template";

            Templates.TryGetValue(path, out var template);
            if (!template.IsNullOrEmpty())
            {
                result.IsSuccess = true;
                result.Result    = template;
                return(result);
            }

            var filePath = Path.Combine(AppContext.BaseDirectory, path);

            if (!File.Exists(filePath))
            {
                return(result
                       .AddError("Template not found"));
            }

            try
            {
                result.Result    = File.ReadAllText(filePath);
                result.IsSuccess = true;

                Templates.TryAdd(path, result.Result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(result);
        }
Пример #25
0
        private DASDataRow createTemplateRow(TemplateType templateType, string name)
        {
            var keys = new Cache <string, string>
            {
                { TemplateTable.Columns.TEMPLATE_TYPE, templateType.ToString() },
                { TemplateTable.Columns.NAME, name },
            };

            var defaultValues = new Cache <string, string>
            {
                { TemplateTable.Columns.XML, string.Empty }
            };

            var templateRow = createNewRow(TemplateTable.NAME, keys, defaultValues);

            if (templateRow.ExistsInDB())
            {
                templateRow.SelectFromDB();
                templateRow.AcceptChanges();
            }

            return(templateRow);
        }
 public static string GetTempletPath(TemplateType type)
 {
     string dir = "", path = null;
     FileSettingsSection section = ConfigurationManager.GetSection("fileSettings") as FileSettingsSection;
     if (section.IsAbsolute)
     {
         if (!Directory.Exists(section.BaseDirectory)) Directory.CreateDirectory(section.BaseDirectory);
         dir = section.BaseDirectory;
     }
     else
     {
         dir = HttpContext.Current.Server.MapPath(section.BaseDirectory);
         if(!Directory.Exists(dir)) Directory.CreateDirectory(dir);
     }
     for (int i = 0; i < section.TemplateFiles.Count; i++)
     {
         if (section.TemplateFiles.AllKeys[i].ToLower() == type.ToString().ToLower())
         {
             path = Path.Combine(dir, section.TemplateFiles[section.TemplateFiles.AllKeys[i]].Value);
             break;
         }
     }
     return path;
 }
 private static string GetTemplateSettingsKey(TestFramework testFramework, MockFramework mockFramework, TemplateType templateType)
 {
     return(GetTemplateSettingsKey(testFramework.Name, mockFramework.Name, templateType.ToString()));
 }
        /// <summary>
        /// Builds a single condition element
        /// </summary>
        /// <param name="condition">Current Condition</param>
        /// <param name="project">Project</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Condition Build Result</returns>
        public async Task <string> BuildSingleConditionElement(ParsedConditionData condition, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            ExportTemplate template = await _templateProvider.GetDefaultTemplateByType(project.Id, _templateType);

            if (!_renderers.ContainsKey(template.RenderingEngine))
            {
                throw new KeyNotFoundException(string.Format("Unknown rendering engine {0} for Condition {1}", template.RenderingEngine.ToString(), _templateType.ToString()));
            }

            return(await _renderers[template.RenderingEngine].BuildSingleConditionElement(template, condition, project, errorCollection, flexFieldObject, exportSettings));
        }
Пример #29
0
 public AdrEntry(TemplateType templateType)
 {
     this.docFolder    = AdrSettings.Current.DocFolder;
     this.templateType = templateType;
     this.templatePath = $"{AdrSettings.Current.TemplateFolder}{Path.DirectorySeparatorChar}{templateType.ToString()}.md";
 }
Пример #30
0
 public List<Release> GetReleasesByCategoryGuid(Guid categoryGuid, TemplateType templateType)
 {
     DbCommand command = DbProviderHelper.CreateCommand("SelectReleasesByCategoryGuidAndTemplateType", CommandType.StoredProcedure);
     command.Parameters.Add(DbProviderHelper.CreateParameter("@CategoryGuid", DbType.Guid, categoryGuid));
     command.Parameters.Add(DbProviderHelper.CreateParameter("@TemplateType", DbType.String, templateType.ToString()));
     DbDataReader dataReader = DbProviderHelper.ExecuteReader(command);
     return GetReleases(dataReader);
 }
Пример #31
0
 /// <summary>
 /// ��ȡģ���б�
 /// </summary>
 /// <param name="tempClass">����</param>
 /// <param name="tempType">����</param>
 /// <returns></returns>
 public static ArrayList List(TemplateClasses tempClass, TemplateType tempType)
 {
     char tc = tempClass == TemplateClasses.U ? '0' : Convert.ToChar(tempClass.ToString());
     char tt = tempType == TemplateType.U ? '0' : Convert.ToChar(tempType.ToString());
     return List(tc, tt);
 }
Пример #32
0
 private static string GetTemplateSettingsKey(MockFramework mockFramework, TemplateType templateType)
 {
     return(GetTemplateSettingsKey(mockFramework.ToString(), templateType.ToString()));
 }
Пример #33
0
        private static string GetTemplatePath(TemplateType type)
        {
            var templateName = type.ToString();

            return(Path.Combine(_templatePath, $"Templates{Path.DirectorySeparatorChar}.{templateName}.mustache"));
        }
Пример #34
0
 /// <summary>
 /// A method used to Create a list by configured list name and specified list template. 
 /// </summary>
 /// <param name="listTemplate">A parameter represents the template type of list template</param>
 /// <returns>A return value represents the added list's id</returns>
 protected string AddListToSUT(TemplateType listTemplate)
 {
     string uniqueListName = this.GetUniqueListName(listTemplate.ToString());
     string listId = this.AddListToSUT(uniqueListName, listTemplate);
     return listId;
 }