コード例 #1
0
        /// <summary>
        /// Creates an ITemplateInfo with the given path to a template file and the dictioanry from the config file.
        /// </summary>
        /// <param name="fullPath">The path to the template file</param>
        /// <param name="templateDictionary">the template dictionary from the config file</param>
        /// <returns>A new ITemplateInfo</returns>
        private ITemplateInfo Create(string fullPath, Dictionary <string, string> templateDictionary)
        {
            var fileInfo = new TemplateFileInfo();

            fileInfo.FullPath = fullPath;

            // <rootPath>/<grandparent>/<parent>/<fileName>.<fileExtension>.tt
            fileInfo.TemplateName  = Path.GetFileNameWithoutExtension(fullPath);                 // <fileName>.<fileExtension>
            fileInfo.FileExtension = Path.GetExtension(fileInfo.TemplateName).Substring(1);      // <fileExtension>

            fileInfo.TemplateBaseName = Path.GetFileNameWithoutExtension(fileInfo.TemplateName); // <fileName>

            string parentPath      = Path.GetDirectoryName(fullPath);                            // <rootPath>/<grandparent>/<parent>
            string parentName      = Path.GetFileNameWithoutExtension(parentPath);
            string grandparentPath = Path.GetDirectoryName(parentPath);                          // <rootPath>/<grandparent>
            string grandparentName = Path.GetFileNameWithoutExtension(grandparentPath);          // <grandparent>

            fileInfo.OutputParentDirectory = parentName;
            fileInfo.TemplateLanguage      = grandparentName;
            fileInfo.TemplateType          = this.GetTemplate(templateDictionary);
            fileInfo.SubprocessorType      = this.GetSubProcessor(templateDictionary);
            fileInfo.Casing = this.GetFileNameCasing(templateDictionary);


            IEnumerable <string> includedObjects      = this.IncludedObjects(templateDictionary);
            IEnumerable <string> excludedObjects      = this.ExcludedObjects(templateDictionary);
            IEnumerable <string> ignoreDescriptions   = this.IgnoreDescriptions(templateDictionary);
            IEnumerable <string> matchingDescriptions = this.MatchingDescriptions(templateDictionary);

            //TODO aclev: these are mutally exclusive and should throw here if they are both set
            if (includedObjects.Count() != 0)
            {
                fileInfo.IncludedObjects = includedObjects;
            }
            else if (excludedObjects.Count() != 0)
            {
                fileInfo.ExcludedObjects = excludedObjects;
            }

            if (matchingDescriptions.Count() != 0)
            {
                fileInfo.MatchingDescriptions = matchingDescriptions;
            }
            if (ignoreDescriptions.Count() != 0)
            {
                fileInfo.IgnoreDescriptions = ignoreDescriptions;
            }

            string nameFormat;

            if (templateDictionary.TryGetValue("Name", out nameFormat))
            {
                fileInfo.NameFormat = nameFormat;
            }
            return(fileInfo);
        }
コード例 #2
0
 virtual protected bool Equals(TemplateFileInfo other)
 {
     return(this.Id == other.Id);
 }