Ejemplo n.º 1
0
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            var service = base.GetService <DTE>(true);

            newValue = string.Empty;
            string selectedFolderPath = DteHelper.GetFilePathRelative((ProjectItem)DteHelper.GetTarget(service));

            string[] pathParts =
                selectedFolderPath.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar },
                                         StringSplitOptions.RemoveEmptyEntries);
            if (pathParts.Length > 3)
            {
                if (pathParts[1] == TemplateConfiguration.GetConfiguration().ExtRootFolderName&&
                    (pathParts[2].Equals(ExtJsClassType.Model.ToString(), StringComparison.InvariantCultureIgnoreCase) ||
                     pathParts[2].Equals(ExtJsClassType.View.ToString(), StringComparison.InvariantCultureIgnoreCase) ||
                     pathParts[2].Equals(ExtJsClassType.Store.ToString(), StringComparison.InvariantCultureIgnoreCase) ||
                     pathParts[2].Equals(ExtJsClassType.Controller.ToString(), StringComparison.InvariantCultureIgnoreCase)))
                {
                    for (var i = 3; i < pathParts.Length; i++)
                    {
                        newValue += pathParts[i] + ".";
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            var service = GetService <DTE>(true);

            newValue = TemplateConfiguration.GetConfiguration(service);
            return(true);
        }
Ejemplo n.º 3
0
        private void CreateFields()
        {
            string typeName = TypeFullName.Parse(ModelSelectedTemplate);
            TemplateConfiguration templateConfig = TemplateConfiguration.GetConfiguration(GetService <DTE>(true));

            foreach (ModelProvider modelProvider in templateConfig.ModelProviders)
            {
                Assembly modelAssembly = Assembly.LoadFrom(modelProvider.ProviderAssemblyLocation);
                Type     modelType     = modelAssembly.GetType(typeName);
                if (modelType != null)
                {
                    TraslateFields(modelType);
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            var service = GetService <DTE>(true);
            TemplateConfiguration templateConfig = TemplateConfiguration.GetConfiguration(service);
            var modelList = new List <string>();

            foreach (ModelProvider modelProvider in templateConfig.ModelProviders)
            {
                Assembly           modelAssembly = Assembly.LoadFrom(modelProvider.ProviderAssemblyLocation);
                IEnumerable <Type> modelTypes    = modelAssembly.GetTypes().Where(t => t.IsClass);
                modelList.AddRange(
                    modelTypes.Select(m => (new TypeFullName {
                    Name = m.Name, Namespace = m.Namespace
                }).ToString()));
            }
            newValue = modelList.OrderBy(m => m).ToList();
            return(true);
        }
Ejemplo n.º 5
0
        private void CreateStore()
        {
            string template         = @"Text\Store.js.t4";
            string templateBasePath = GetTemplateBasePath();

            if (!Path.IsPathRooted(template))
            {
                template = Path.Combine(templateBasePath, template);
            }
            template = new FileInfo(template).FullName;
            if (!template.StartsWith(templateBasePath))
            {
                throw new ArgumentException("Template Not found");
            }
            string templateCode = File.ReadAllText(template);

            var addProjectItemAction = new AddProjectItemAction();

            addProjectItemAction.Content        = Render(templateCode, template).ToString();
            addProjectItemAction.IsValid        = true;
            addProjectItemAction.TargetFileName = ModelClassName + "s.js";
            addProjectItemAction.Project        = CurrentProject;
            addProjectItemAction.Execute(DteHelper.FindInCollection(CurrentProject.ProjectItems, TemplateConfiguration.GetConfiguration().ExtRootFolderName + "\\Store"));
        }
Ejemplo n.º 6
0
 public override bool OnBeginRecipe(object currentValue, out object newValue)
 {
     newValue = TemplateConfiguration.GetConfiguration().ExtRootNamespace;
     return(true);
 }