示例#1
0
        void _windowEvents_WindowActivated(Window gotFocus, Window lostFocus)
        {
            if (gotFocus.ProjectItem == null || gotFocus.ProjectItem.Name == null || gotFocus.ProjectItem.Name.Length == 0)
            {
                return;
            }

            object schemaContext = GetXmlSchemaContextFromTextView(GetIVsTextViewFromWindow(gotFocus));

            if (schemaContext == null)
            {
                return;
            }



            var projectItem = new EnvDTEProjectItemInfo(gotFocus.ProjectItem);
            var schemas     = projectItem.GetXmlSchemaInfos(new XmlSchemaSourceFile {
                FilePath = projectItem.FullName
            }).ToList();

            if (schemas.Count() == 0)
            {
                return;
            }


            var helper = new SchemaContextHelper(schemaContext);

            helper.ApplySchemaInfos(schemas);
        }
示例#2
0
        protected override byte[] GenerateCode(string inputFileContent)
        {
            var inputFile = new CustomToolInputFile {
                CodeDomProvider = this.GetCodeProvider(),
                FileContent     = inputFileContent,
                FilePath        = this.InputFilePath,
                FileNameSpace   = this.FileNameSpace
            };

            var projectItem = new EnvDTEProjectItemInfo(this.GetProjectItem());

            using (projectItem.Project.AssemblyResolve()) {
                var customToolInfo = projectItem.GetCustomToolInfo(inputFile);

                if (customToolInfo == null)
                {
                    this.GeneratorError(0, "NO CODEGENERATOR-CLASS!", 0, 0);
                    return(new byte[0]);
                }


                var customToolType = Type.GetType(customToolInfo.TypeName);
                var customTool     = (ICustomTool)Activator.CreateInstance(customToolType);
                var content        = customTool.GenerateCode(inputFile, customToolInfo.Parameters);

                return(content);
            }
        }