• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IProjectItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IProjectItem的典型用法代码示例。如果您正苦于以下问题:C# IProjectItem类的具体用法?C# IProjectItem怎么用?C# IProjectItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IProjectItem类属于命名空间,在下文中一共展示了IProjectItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Merge

        protected override void Merge(IProjectItem newProjectItem, bool overwrite)
        {
            base.Merge(newProjectItem, overwrite);

            var newItemBase = newProjectItem as DatabaseProjectItem;
            Assert.Cast(newItemBase, nameof(newItemBase));

            if (overwrite)
            {
                ItemNameProperty.SetValue(newItemBase.ItemNameProperty);

                ItemIdOrPath = newItemBase.ItemIdOrPath;
                DatabaseName = newItemBase.DatabaseName;
            }

            if (!string.IsNullOrEmpty(newItemBase.DatabaseName))
            {
                DatabaseName = newItemBase.DatabaseName;
            }

            if (!string.IsNullOrEmpty(newItemBase.Icon))
            {
                IconProperty.SetValue(newItemBase.IconProperty, SetValueOptions.DisableUpdates);
            }

            IsEmittable = IsEmittable || newItemBase.IsEmittable;
            IsImport = IsImport || newItemBase.IsImport;

            References.AddRange(newItemBase.References);
        }
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:30,代码来源:DatabaseProjectItem.cs


示例2: Compile

        public override void Compile(ICompileContext context, IProjectItem projectItem)
        {
            var include = context.Configuration.GetString(Constants.Configuration.BuildProjectCompileBinFilesInclude);
            if (string.IsNullOrEmpty(include))
            {
                return;
            }

            var binFile = projectItem as BinFile;
            Assert.Cast(binFile, nameof(binFile));

            var exclude = context.Configuration.GetString(Constants.Configuration.BuildProjectCompileBinFilesExclude);

            var pathMatcher = new PathMatcher(include, exclude);
            if (!pathMatcher.IsMatch(binFile.FilePath))
            {
                return;
            }

            try
            {
                var assembly = Assembly.LoadFrom(binFile.Snapshots.First().SourceFile.AbsoluteFileName);

                foreach (var type in assembly.GetExportedTypes())
                {
                    context.Pipelines.Resolve<BinFileCompilerPipeline>().Execute(context, binFile, type);
                }
            }
            catch (Exception ex)
            {
                context.Trace.TraceError(Msg.C1059, ex.Message, binFile.FilePath);
            }
        }
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:33,代码来源:BinFileCompiler.cs


示例3: Compile

        public override void Compile(ICompileContext context, IProjectItem projectItem)
        {
            var rendering = projectItem as Rendering;
            if (rendering == null)
            {
                return;
            }

            var project = rendering.Project;
            var snapshot = rendering.Snapshots.First();
            var snapshotTextNode = new SnapshotTextNode(snapshot);
            var guid = StringHelper.GetGuid(project, rendering.ItemPath);
            var item = context.Factory.Item(project, snapshotTextNode, guid, rendering.DatabaseName, rendering.ItemName, rendering.ItemPath, rendering.TemplateIdOrPath);
            item.ItemNameProperty.AddSourceTextNode(new FileNameTextNode(rendering.ItemName, snapshot));
            item.OverwriteWhenMerging = true;

            var field = context.Factory.Field(item, snapshotTextNode, "Path", rendering.FilePath);
            field.ValueProperty.Flags = SourcePropertyFlags.IsFileName;
            item.Fields.Add(field);
            item.References.Add(new FileReference(item, field.ValueProperty));

            if (rendering.Placeholders.Any())
            {
                var placeholdersField = context.Factory.Field(item, TextNode.Empty, "Place Holders", string.Join(",", rendering.Placeholders));
                item.Fields.Add(placeholdersField);
            }

            var addedItem = rendering.Project.AddOrMerge(item);
            rendering.RenderingItemUri = addedItem.Uri;
        }
开发者ID:Hafeok,项目名称:Sitecore.Pathfinder,代码行数:30,代码来源:RenderingCompiler.cs


示例4: FolderModel

 public FolderModel(IProjectItem parent, string name)
 {
     Parent = parent;
     Name = name;
     RelativePath = Path.Combine(parent.RelativePath, name) + "/";
     Children = new List<IProjectItem>();
 }
开发者ID:modulexcite,项目名称:SourceBrowser,代码行数:7,代码来源:FolderModel.cs


示例5: Emit

        public override void Emit(IEmitContext context, IProjectItem projectItem)
        {
            var unicornFile = projectItem as UnicornFile;
            Assert.Cast(unicornFile, nameof(unicornFile));

            var snapshot = unicornFile.Snapshots.First();

            // todo: use real Unicorn configuration instead of hacking it
            var log = new TraceLogger(context.Trace);
            var logger = new DefaultDeserializerLogger(log);
            var fieldFilter = new AllFieldFilter();
            var defaultDeserializer = new DefaultDeserializer(logger, fieldFilter);

            // todo: file has already been read and parsed - do not read it again
            var formatter = new YamlSerializationFormatter(null, null);
            using (var stream = new FileStream(snapshot.SourceFile.AbsoluteFileName, FileMode.Open))
            {
                var serializedItem = formatter.ReadSerializedItem(stream, unicornFile.ShortName);

                if (string.IsNullOrEmpty(serializedItem.DatabaseName))
                {
                    serializedItem.DatabaseName = unicornFile.DatabaseName;
                }

                try
                {
                    defaultDeserializer.Deserialize(serializedItem);
                }
                catch (Exception ex)
                {
                    throw new RetryableEmitException(Texts.Failed_to_deserialize_item, unicornFile.Snapshots.First(), ex.Message);
                }
            }
        }
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:34,代码来源:UnicornFileEmitter.cs


示例6: Compile

        public override void Compile(ICompileContext context, IProjectItem projectItem)
        {
            var serializationFile = projectItem as SerializationFile;
            if (serializationFile == null)
            {
                return;
            }

            var textDocument = (ITextSnapshot)serializationFile.Snapshots.First();
            var rootTextNode = textDocument.Root;
            if (rootTextNode == TextNode.Empty)
            {
                context.Trace.TraceError(Msg.C1050, Texts.Document_is_not_valid, textDocument.SourceFile.AbsoluteFileName, TextSpan.Empty);
                return;
            }

            var lines = textDocument.SourceFile.ReadAsLines();
            var itemBuilder = context.Factory.ItemBuilder();

            ParseItem(context, textDocument, itemBuilder, lines, 0);

            var item = itemBuilder.Build(serializationFile.Project, rootTextNode);
            item.IsEmittable = false;

            var addedItem = serializationFile.Project.AddOrMerge(item);
            serializationFile.SerializationItemUri = addedItem.Uri;
        }
开发者ID:Hafeok,项目名称:Sitecore.Pathfinder,代码行数:27,代码来源:SerializationFileCompiler.cs


示例7: FindSettingsFilePath

        /// <summary>
        /// Searches directories of the project items project file and the parents thereof to see 
        /// if a Settings file exists.
        /// </summary>
        /// <param name="projectItem">
        /// File being examined.
        /// </param>
        /// <returns>
        /// Path to the settings file.
        /// </returns>
        public string FindSettingsFilePath(IProjectItem projectItem)
        {
            StyleCopTrace.In(projectItem);

            string cacheKey = string.Format("{0}::{1}", "FindSettingsFilePath", projectItem.Location.FullPath.ToLowerInvariant());

            string settings;

            if (StringCache.TryGetValue(cacheKey, out settings))
            {
                StyleCopTrace.Out();

                return settings;
            }

            IProject projectFile = projectItem.GetProject();

            string result = this.FindSettingsFilePath(projectFile);

            // TODO: This is adding a watcher for settings.stylecop in the folder of the source file
            // This is creating a watcher for *ALL* source files that are monitored!
            this.AddWatcherForSettingsFile(projectItem.Location.FullPath);
            StringCache[cacheKey] = result;

            return StyleCopTrace.Out(result);
        }
开发者ID:icnocop,项目名称:StyleCop,代码行数:36,代码来源:StyleCopSettings.cs


示例8:

        bool IMvcQuickFixTemplateProvider.IsAvailable(IProjectItem context)
        {
            // ReSharper will suggest the "default" quickfix items for MVC-like projects, which include ASPX views generation.
            // ASPX views are not used in Nancy, so we return false here to prevent R# from suggesting them.

            return false;
        }
开发者ID:jimmason,项目名称:Nancy.ReSharper,代码行数:7,代码来源:NancyAspCSharpMvcQuickFixTemplateProvider.cs


示例9: ParseRenderingReferences

 protected override void ParseRenderingReferences(ItemParseContext context, ICollection<IReference> references, IProjectItem projectItem, ITextNode renderingTextNode)
 {
     var childNode = renderingTextNode.ChildNodes.FirstOrDefault();
     if (childNode != null)
     {
         base.ParseRenderingReferences(context, references, projectItem, childNode);
     }
 }
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:8,代码来源:JsonLayoutTextNodeParser.cs


示例10: Emit

        public override void Emit(IEmitContext context, IProjectItem projectItem)
        {
            var item = projectItem as Item;
            Assert.Cast(item, nameof(item));

            if (!item.IsEmittable || item.IsImport)
            {
                return;
            }

            var templateIdOrPath = ResolveTemplateIdOrPath(item);
            if (string.IsNullOrEmpty(templateIdOrPath))
            {
                throw new RetryableEmitException(Texts.Template_missing, TraceHelper.GetTextNode(item.TemplateIdOrPathProperty, item.ItemNameProperty), item.TemplateIdOrPath);
            }

            var database = Factory.GetDatabase(item.DatabaseName);
            var templateItem = database.GetItem(templateIdOrPath);
            if (string.IsNullOrEmpty(templateIdOrPath))
            {
                throw new RetryableEmitException(Texts.Template_missing, TraceHelper.GetTextNode(item.TemplateIdOrPathProperty), item.TemplateIdOrPath);
            }

            var template = TemplateManager.GetTemplate(templateItem.ID, templateItem.Database);
            if (template == null)
            {
                throw new RetryableEmitException(Texts.Template_missing, TraceHelper.GetTextNode(item.TemplateIdOrPathProperty), item.TemplateIdOrPath);
            }

            // todo: convert to pipeline
            ValidateFields(database, template, item);

            var itemWriter = new ItemWriter
            {
                Snapshot = item.Snapshots.First(),
                DatabaseName = item.DatabaseName,
                Guid = projectItem.Uri.Guid,
                ItemName = item.ItemName,
                ItemIdOrPath = item.ItemIdOrPath,
                TemplateIdOrPath = templateIdOrPath
            };

            foreach (var field in item.Fields)
            {
                var templateField = template.GetField(field.FieldName);
                if (templateField == null)
                {
                    throw new RetryableEmitException(Texts.Template_field_missing, TraceHelper.GetTextNode(field.FieldNameProperty, item.ItemNameProperty), field.FieldName);
                }

                var fieldWriter = new FieldWriter(field.FieldIdProperty, field.FieldNameProperty, field.Language, field.Version, field.CompiledValue);
                itemWriter.Fields.Add(fieldWriter);
            }

            var dataItem = itemWriter.Write(context);

            Check(context, item, dataItem);
        }
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:58,代码来源:ItemEmitter.cs


示例11: Emit

        public override void Emit(IEmitContext context, IProjectItem projectItem)
        {
            var configFile = (ConfigFile)projectItem;

            var destinationFileName = FileUtil.MapPath(configFile.FilePath);

            context.FileSystem.CreateDirectoryFromFileName(destinationFileName);
            context.FileSystem.Copy(projectItem.Snapshots.First().SourceFile.AbsoluteFileName, destinationFileName, context.ForceUpdate);
        }
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:9,代码来源:ConfigFileEmitter.cs


示例12: DocumentModel

 public DocumentModel(IProjectItem parent, string name, int numberOfLines)
 {
     Parent = parent;
     Name = name;
     RelativePath = Path.Combine(parent.RelativePath, name); ;
     NumberOfLines = numberOfLines;
     Children = new List<IProjectItem>();
     Tokens = new List<Token>();
 }
开发者ID:george2giga,项目名称:SourceBrowser,代码行数:9,代码来源:DocumentModel.cs


示例13: TextItemViewModel

 public TextItemViewModel(IProjectItem item)
 {
     Item = item;
     Title = "Item: " + Item.Name;
     MenuItems = new BindableCollection<MenuItemViewModel> {
         new MenuItemViewModel {
             Header = "_hello"
         }
     };
 }
开发者ID:veggielane,项目名称:OpenCAD,代码行数:10,代码来源:TextItemViewModel.cs


示例14: SelectProjectItemViewModel

        /// <summary>
        /// Initializes a new instance of the <see cref="SelectProjectItemViewModel" /> class.
        /// </summary>
        /// <param name="rootProjectItem">The root Project Item.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="rootProjectItem" /> is <c>null</c>.</exception>
        public SelectProjectItemViewModel(IProjectItem rootProjectItem)
        {
            Argument.IsNotNull("rootProjectItem", rootProjectItem);

            RootProjectItems = new List<IProjectItem>();
            foreach (var projectItem in rootProjectItem.ProjectItems)
            {
                RootProjectItems.Add(projectItem);
            }
        }
开发者ID:GeertvanHorrik,项目名称:Caitlyn,代码行数:15,代码来源:SelectProjectItemViewModel.cs


示例15: CanCompile

        public override bool CanCompile(ICompileContext context, IProjectItem projectItem)
        {
            var item = projectItem as Item;
            if (item == null)
            {
                return false;
            }

            return item.SourceTextNodes.Select(n => n.GetAttributeValue("Template.CreateFromFields")).Any(value => string.Equals(value, "true", StringComparison.OrdinalIgnoreCase));
        }
开发者ID:Hafeok,项目名称:Sitecore.Pathfinder,代码行数:10,代码来源:TemplateCompiler.cs


示例16: Emit

        public override void Emit(IEmitContext context, IProjectItem projectItem)
        {
            var template = (Template)projectItem;
            if (!template.IsEmittable || template.IsImport)
            {
                return;
            }

            var templateWriter = new TemplateWriter(template);
            templateWriter.Write(context);
        }
开发者ID:Hafeok,项目名称:Sitecore.Pathfinder,代码行数:11,代码来源:TemplateEmitter.cs


示例17: RemoveProjectItemNode

 protected void RemoveProjectItemNode(IProjectItem projectItem)
 {
     foreach (ItemNode node in Nodes)
     {
         if (node is IProjectItemNode && ((IProjectItemNode)node).ProjectItem == projectItem)
         {
             node.Delete();
             return;
         }
     }
 }
开发者ID:BachelorEric,项目名称:ModelFirst,代码行数:11,代码来源:ContainerNode.cs


示例18: ProjectItem

        public ProjectItem(EnvDTE.ProjectItem projectItem, IProjectItem parent = null)
        {
            Argument.IsNotNull("projectItem", projectItem);

            Initialize(projectItem.GetObjectName(), projectItem.IsFolder() ? ProjectItemType.Folder : ProjectItemType.File, parent);

            foreach (EnvDTE.ProjectItem subProjectItem in projectItem.ProjectItems)
            {
                ProjectItems.Add(new ProjectItem(subProjectItem, this));
            }
        }
开发者ID:GeertvanHorrik,项目名称:Caitlyn,代码行数:11,代码来源:ProjectItem.cs


示例19: Compile

        public override void Compile(ICompileContext context, IProjectItem projectItem)
        {
            var item = projectItem as Item;
            Assert.Cast(item, nameof(item));

            var fileName = item.GetValue<string>(LayoutPage)?.Trim() ?? string.Empty;
            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            var property = item.GetProperty<string>(LayoutPage);

            // find page html file
            var rendering = item.Project.Files.FirstOrDefault(i => string.Equals(i.FilePath, fileName, StringComparison.OrdinalIgnoreCase));
            if (rendering == null)
            {
                context.Trace.TraceError(Msg.C1047, Texts.Rendering_reference_not_found, TraceHelper.GetTextNode(property), fileName);
            }

            // find MvcLayout
            var layoutItem = item.Project.ProjectItems.OfType<Item>().FirstOrDefault(i => i.ItemIdOrPath == "/sitecore/layout/Layouts/MvcLayout");
            if (layoutItem == null)
            {
                context.Trace.TraceError(Msg.C1048, Texts.Layout_reference_not_found, TraceHelper.GetTextNode(property), "/sitecore/layout/Layouts/MvcLayout");
            }

            if (rendering == null || layoutItem == null)
            {
                return;
            }

            var sourceFile = rendering.Snapshots.First().SourceFile;

            var writer = new StringWriter();
            var output = new XmlTextWriter(writer);
            output.Formatting = Formatting.Indented;

            var buildContext = new BuildContext(context, sourceFile, output, item, layoutItem);

            var literalRendering = FindRendering(buildContext, "Literal", string.Empty, TextSpan.Empty);
            if (literalRendering == null)
            {
                return;
            }

            buildContext.Placeholder = layoutItem["Place Holders"];
            buildContext.LiteralRendering = literalRendering;

            ParseHtml(buildContext);

            SetRenderingsField(buildContext, buildContext.Item, writer.ToString());
        }
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:53,代码来源:PageHtmlPropertyCompiler.cs


示例20: Emit

        public override void Emit(IEmitContext context, IProjectItem projectItem)
        {
            var binFile = (BinFile)projectItem;
            var destinationFileName = FileUtil.MapPath(binFile.FilePath);

            if (!CanCopyBinFile(context, binFile, destinationFileName))
            {
                return;
            }

            context.FileSystem.CreateDirectory(Path.GetDirectoryName(destinationFileName) ?? string.Empty);
            context.FileSystem.Copy(projectItem.Snapshots.First().SourceFile.AbsoluteFileName, destinationFileName, context.ForceUpdate);
        }
开发者ID:pveller,项目名称:Sitecore.Pathfinder,代码行数:13,代码来源:BinFileEmitter.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IProjectManager类代码示例发布时间:2022-05-24
下一篇:
C# IProjectFile类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap