当前位置: 首页>>代码示例>>C#>>正文


C# ProjectItem.GetType方法代码示例

本文整理汇总了C#中ProjectItem.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectItem.GetType方法的具体用法?C# ProjectItem.GetType怎么用?C# ProjectItem.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectItem的用法示例。


在下文中一共展示了ProjectItem.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Build

        public static SProjectItem Build(ProjectItem item)
        {
            if(item is SmartCodeProject)
                return new SSmartCodeProject(item as SmartCodeProject);

            if(item is ProjectItemFolder)
                return new SProjectItemFolder(item as ProjectItemFolder);

            if(item is ProjectItemCodeDocument)
                return new SProjectItemCodeDocument(item as ProjectItemCodeDocument);

            throw new NotSupportedException("Don't know how to serialize type: " + item.GetType().Name);
        }
开发者ID:RaptorOne,项目名称:SmartDevelop,代码行数:13,代码来源:SProjectItem.cs

示例2: ItemAdded

        public static void ItemAdded(ProjectItem projectItem)
        {
            if (projectItem.Properties == null)
                return;

            // Troubles loading F# projects.
            if (projectItem.GetType().ToString().Equals("Microsoft.VisualStudio.FSharp.ProjectSystem.Automation.OAFileItem", StringComparison.InvariantCultureIgnoreCase))
                return;

            // Only try and copy physical files (ignore folders, sub projects, virtual files.
            if (Guid.Parse(projectItem.Kind) != Guid.Parse("6bb5f8ee-4483-11d3-8bcf-00c04f8ec28c")) // GUID_ItemType_PhysicalFile
                return;

            var isPermittedFileType = FuncEx.Create((List<string> fileTypes, ProjectItemBuildAction action) =>
            {
                if (!fileTypes.Contains(Path.GetExtension(projectItem.Name).TrimStart('.')))
                    return false;

                var buildAction = (ProjectItemBuildAction)projectItem.Properties.Item("BuildAction").Value;
                if (buildAction != action)
                    return false;

                return true;
            });

            if (!(isPermittedFileType(EmbeddedResourceFileTypes, ProjectItemBuildAction.EmbeddedResource) || isPermittedFileType(ContentFileTypes, ProjectItemBuildAction.Content)))
                return;

            // If this is a cshtml file then check to see if it has a customtool property value. If there's no value then the cshtml file
            // is probably coming from a theme and shouldn't be copied at all.
            if (Path.GetExtension(projectItem.Name).Equals(".cshtml", StringComparison.InvariantCultureIgnoreCase))
            {
                if (projectItem.FileNames[0].ToLower().Contains("app_code"))
                    return;
                string customTool = projectItem.Properties.Item("CustomTool").Value.ToString();
                if (String.IsNullOrEmpty(customTool))
                    return;
            }

            // If the file belongs to the start up application don't copy it anywhere
            var startupProject = Infrastructure.Core.Instance.StartupProject;
            if (projectItem.ContainingProject.Equals(startupProject))
                return;

            CopiedFiles.Add(startupProject, projectItem);

            var ie = projectItem.ProjectItems.GetEnumerator();
            while (ie.MoveNext())
            {
                ProjectItem subProjectItem = projectItem.ProjectItems.Item(((dynamic)ie.Current).Name);
                ItemAdded(subProjectItem);
            }

            // Copy the file from the project into the same folder structure under the Startup Application
            // Have to be careful to keep folders like /content/styles/cool.css
            //var saveTo = startupProject.Combine(projectItem.FilenameAsRelativePath());
            //if (!Directory.Exists(Path.GetDirectoryName(saveTo)))
            //    Directory.CreateDirectory(Path.GetDirectoryName(saveTo));
            //File.Copy(projectItem.FileNames[0], saveTo, true);

            //Infrastructure.Core.Instance.Notity("Embedded resource exported to " + saveTo);
        }
开发者ID:Mozketo,项目名称:Suction,代码行数:62,代码来源:FileHandler.cs

示例3: GetProjectItemParent

        private static object GetProjectItemParent(ProjectItem projectItem)
        {
            object projectItemParent = null;

              //Folder Items in Custom Projects behave different than their ComObject counterparts.
              if (projectItem.GetType ().FullName == "Microsoft.VisualStudioTools.Project.Automation.OAFolderItem")
              {
            try
            {
              if (projectItem.Object == null)
              {
            OutputWindowHandler.WriteMessage (
              string.Format (
                  "Property 'Object' of the FolderItem of Type {0} is null. Can't find LicenseHeaderFile.",
                  projectItem.GetType ().FullName));
              }
              else
              {
            var parentProperty = projectItem.Object.GetType ().GetProperty ("Parent").GetValue (projectItem.Object, null);
            var parentUrl = parentProperty.GetType ().GetProperty ("Url").GetValue (parentProperty, null) as string;
            projectItemParent = projectItem.DTE.Solution.FindProjectItem (parentUrl);

            //If the ProjectItemParent could not be found by "FindProjectItem" this means we are a Folder at TopLevel and only the ContainingProject is above us
            if (projectItemParent == null)
            {
              projectItemParent = projectItem.ContainingProject;
            }
              }
            }
            catch (Exception exception)
            {
              //We catch everything as a multitude of Execptions can be thrown if the projectItem.Object is not structured as we assume
              OutputWindowHandler.WriteMessage (
              string.Format (
                  "Exception got thrown when searching for the LicenseHeaderFile on FolderItem of Type '{0}'. Exception: {1}",
                  projectItem.GetType ().FullName,
                  exception));
            }
              }
              else
              {
            projectItemParent = projectItem.Collection.Parent;
              }

              return projectItemParent;
        }
开发者ID:rubicon-oss,项目名称:LicenseHeaderManager,代码行数:46,代码来源:LicenseHeaderFinder.cs


注:本文中的ProjectItem.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。