本文整理汇总了C#中SourceFile类的典型用法代码示例。如果您正苦于以下问题:C# SourceFile类的具体用法?C# SourceFile怎么用?C# SourceFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceFile类属于命名空间,在下文中一共展示了SourceFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
public virtual void Process(SourceFile file)
{
foreach (var step in internalSteps)
{
step.Process(file);
}
}
示例2: Process
public void Process(SourceFile file) {
file.RenderBody = Internal.RegularExpressions.ContentTag.Replace(
file.RenderBody,
delegate(Match match)
{
var parsedAttributes = match.Groups["attributes"].Value;
var attributes = Utilities.GetAttributesDictionaryFrom(parsedAttributes);
if (attributes.Contains("runat") && String.Equals("server", (attributes["runat"] as string), StringComparison.InvariantCultureIgnoreCase))
{
if (!attributes.Contains("contentplaceholderid"))
throw new AspViewException(ExceptionMessages.ContentPlaceHolderIdAttributeNotFound);
if (String.IsNullOrEmpty((string)attributes["contentplaceholderid"]))
throw new AspViewException(ExceptionMessages.ContentPlaceHolderIdAttributeEmpty);
var contentplaceholderid = (string)attributes["contentplaceholderid"];
// handle ViewContents special case
if (contentplaceholderid == "ViewContents")
return match.Groups["content"].Value;
var capturefortagformat = @"<component:capturefor id=""{0}"">{1}</component:capturefor>";
return string.Format(capturefortagformat, contentplaceholderid, match.Groups["content"].Value);
}
else
return match.Value;
}
);
}
示例3: tokenize_file
void tokenize_file (SourceFile sourceFile, ModuleContainer module, ParserSession session)
{
Stream input;
try {
input = File.OpenRead (sourceFile.Name);
} catch {
Report.Error (2001, "Source file `" + sourceFile.Name + "' could not be found");
return;
}
using (input){
SeekableStreamReader reader = new SeekableStreamReader (input, ctx.Settings.Encoding);
var file = new CompilationSourceFile (module, sourceFile);
Tokenizer lexer = new Tokenizer (reader, file, session, ctx.Report);
int token, tokens = 0, errors = 0;
while ((token = lexer.token ()) != Token.EOF){
tokens++;
if (token == Token.ERROR)
errors++;
}
Console.WriteLine ("Tokenized: " + tokens + " found " + errors + " errors");
}
return;
}
示例4: Process
public virtual void Process(SourceFile file)
{
foreach (IPreCompilationStep step in internalSteps)
{
step.Process(file);
}
}
示例5: ItemTests
public void ItemTests()
{
var sourceFile = new SourceFile(Services.FileSystem, "test.txt", "test.txt");
var doc = Services.CompositionService.Resolve<JsonTextSnapshot>().With(SnapshotParseContext.Empty, sourceFile, "{ \"Item\": { \"Fields\": [ { \"Name\": \"Text\", \"Value\": \"123\" } ] } }");
var root = doc.Root;
Assert.IsNotNull(root);
Assert.AreEqual("Item", root.Key);
Assert.AreEqual(1, root.ChildNodes.Count());
var fields = root.ChildNodes.First();
Assert.AreEqual(1, fields.ChildNodes.Count());
var field = fields.ChildNodes.First();
Assert.AreEqual("Text", field.GetAttributeValue("Name"));
Assert.AreEqual("123", field.GetAttributeValue("Value"));
Assert.AreEqual(0, field.ChildNodes.Count());
var attribute = field.GetAttribute("Name");
Assert.IsNotNull(attribute);
Assert.AreEqual("Text", attribute.Value);
Assert.AreEqual(0, attribute.Attributes.Count());
Assert.AreEqual(0, attribute.ChildNodes.Count());
Assert.AreEqual(field.Snapshot, attribute.Snapshot);
Assert.AreEqual(doc, attribute.Snapshot);
}
示例6: CodeIssueFile
internal CodeIssueFile(CodeIssue codeIssue, SourceFile file, string message)
{
this.codeIssue = codeIssue;
this.file = file;
this.message = message;
}
示例7: Process
public void Process(SourceFile file)
{
file.RenderBody = Internal.RegularExpressions.LayoutContentPlaceHolder.Replace(
file.RenderBody,
delegate(Match match)
{
string parsedAttributes = match.Groups["attributes"].Value;
IDictionary attributes = Utilities.GetAttributesDictionaryFrom(parsedAttributes);
if(attributes.Contains("runat") && String.Equals("server",(attributes["runat"] as string), StringComparison.InvariantCultureIgnoreCase))
{
if (!attributes.Contains("id"))
throw new AspViewException(ExceptionMessages.IdAttributeNotFound);
if (String.IsNullOrEmpty((string)attributes["id"]))
throw new AspViewException(ExceptionMessages.IdAttributeEmpty);
string placeholderid = (string) attributes["id"];
if(!file.Properties.ContainsKey(placeholderid))
{
// handle ViewContents special case
if (placeholderid != "ViewContents")
file.Properties.Add(placeholderid, new ViewProperty(placeholderid, "string", @""""""));
}
else if(!String.Equals(file.Properties[placeholderid].Type, "string", StringComparison.InvariantCultureIgnoreCase))
{
throw new AspViewException(String.Format(ExceptionMessages.ViewPropertyAllreadyRegisteredWithOtherTypeFormat, placeholderid));
}
return String.Format("<%={0}%>", placeholderid);
}
else
{
return match.Value;
}
});
}
示例8: RunSteps
private void RunSteps(SourceFile file)
{
foreach (IPreCompilationStep step in provider.GetSteps())
{
step.Process(file);
}
}
示例9: AddNewImport
public void AddNewImport(SourcePoint start, string namespaceName, SourceFile sourceFile, bool isLast)
{
string newImportCall = CodeRush.Language.GenerateElement(new NamespaceReference(namespaceName), sourceFile.Project.Language);
if (isLast && newImportCall.EndsWith(Environment.NewLine)) // Remove cr/lf from last entry.
newImportCall = newImportCall.Remove(newImportCall.Length - Environment.NewLine.Length);
_NewImportCalls.Add(new FileChange(sourceFile.Name, start, newImportCall));
}
示例10: CheckFile
internal CheckFile(IssueServices issueService,
SourceFile file,
IssueProcessor issueProcessor)
{
this.issueService = issueService;
this.file = file;
this.issueProcessor = issueProcessor;
}
示例11: TokenInfo
public TokenInfo(Token token, string value, SourceFile sourceFile, int ln, int col)
{
this.token = token;
this.value = value;
this.ln = ln;
this.col = col;
this.sourceFile = sourceFile;
}
示例12:
/// <summary>
/// Performs server side comment stripping
/// </summary>
/// <param name="file">The source file object to act upon.</param>
void IPreCompilationStep.Process(SourceFile file)
{
file.RenderBody = Internal.RegularExpressions.ServerSideComment.Replace(
file.RenderBody,
string.Empty
);
}
示例13: RegisterSectionHandler
private void RegisterSectionHandler(string handlerName, string sectionContent, SourceFile file)
{
var processedSection = sectionContent;
if (Internal.RegularExpressions.ViewComponentTags.IsMatch(sectionContent))
processedSection = Process(sectionContent, file);
processedSection = scriptTransformer.Transform(processedSection);
file.ViewComponentSectionHandlers[handlerName] = processedSection;
}
示例14: Process
public void Process(SourceFile file)
{
file.RenderBody = Internal.RegularExpressions.ImportDirective.Replace(file.RenderBody, delegate(Match match)
{
file.Imports.Add(match.Groups["namespace"].Value);
return string.Empty;
});
}
示例15: Process
public void Process(SourceFile file)
{
file.Imports.Add("System");
file.Imports.Add("System.IO");
file.Imports.Add("System.Collections");
file.Imports.Add("System.Collections.Generic");
file.Imports.Add("Castle.MonoRail.Framework");
file.Imports.Add("Castle.MonoRail.Views.AspView");
}