本文整理汇总了C#中IProjectItem类的典型用法代码示例。如果您正苦于以下问题:C# IProjectItem类的具体用法?C# IProjectItem怎么用?C# IProjectItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IProjectItem类属于命名空间,在下文中一共展示了IProjectItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
}
示例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;
}
示例4: FolderModel
public FolderModel(IProjectItem parent, string name)
{
Parent = parent;
Name = name;
RelativePath = Path.Combine(parent.RelativePath, name) + "/";
Children = new List<IProjectItem>();
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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>();
}
示例13: TextItemViewModel
public TextItemViewModel(IProjectItem item)
{
Item = item;
Title = "Item: " + Item.Name;
MenuItems = new BindableCollection<MenuItemViewModel> {
new MenuItemViewModel {
Header = "_hello"
}
};
}
示例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);
}
}
示例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));
}