public virtual void OnImportDirective(ImportDirective import) { if (import.AssemblyReference != null) { OnAssemblyReference(import.AssemblyReference); } }
/// <inheritdoc/> public DataType TryResolve(ImportDirective import, XmlQualifiedName typeName) { if (import == null) { throw new ArgumentNullException(nameof(import)); } if (typeName.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(typeName)); } foreach (var resolver in _resolvers) { try { var type = resolver.TryResolve(import, typeName); if (type != null) { return(type); } } catch { continue; } } return(null); }
public static void WriteImport(CodeTextBuilder code, ImportDirective import) { code.Write("import "); if (import.AsDefault != null) { code.Write(import.AsDefault.Name); } else if (import.AsNamespace != null) { code.Write($"* as {import.AsNamespace.Name}"); } else if (import.AsTuple != null) { JavaScriptExpressionWriter.WriteTuple(code, import.AsTuple); } if (import.From != null) { code.Write($" from '{import.From.GetModulePath()}'"); } else if (import.What != null) { code.Write($"'{import.What.GetModulePath()}'"); } code.WriteLine(";"); }
public override void OnImportDirective(ImportDirective import) { base.OnImportDirective(import); if (import.AssemblyReference != null) { _typeManager.AddAssembly(import.AssemblyReference.ResolvedAssembly); } }
protected void import_directive( EngineConfiguration conf ) //throws RecognitionException, TokenStreamException { Token i = null; String ns; String assemblyName; ImportDirective import = null; try { // for error handling i = LT(1); match(IMPORT); ns = identifier(); import = new ImportDirective(ToLexicalInfo(i), ns); conf.Imports.Add(import); { switch (LA(1)) { case IN: { match(IN); assemblyName = identifier(); import.AssemblyReference = new AssemblyReference(ToLexicalInfo(i), assemblyName); break; } case EOF: case ASPECT: case IMPORT: case MIXINS: case INTERCEPTORS: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } } catch (RecognitionException ex) { reportError(ex); consume(); consumeUntil(tokenSet_1_); } }
public void CompileImportDirective(ImportDirective import) { XmlElement tmpElement = document.CreateElement("ImportDirective"); tmpElement.SetAttribute("ModuleName", import.ModuleName.ToString()); if (!string.IsNullOrEmpty(import.Alias)) { tmpElement.SetAttribute("Alias", import.Alias); } currentElement.AppendChild(tmpElement); }
public void CompileImportDirective(ImportDirective import) { if (string.IsNullOrEmpty(import.Alias)) { textWriter.WriteLine("import {0};", SafeName(import.ModuleName)); } else { textWriter.WriteLine("import {0} as {1};", SafeName(import.ModuleName), SafeName(import.Alias)); } }
public void ParsingImportDeclarations() { AspectParser parser = CreateParser("import my.ns.name"); EngineConfiguration conf = parser.Parse(); Assert.IsNotNull(conf); Assert.IsNotNull(conf.Imports); Assert.AreEqual(1, conf.Imports.Count); ImportDirective import = conf.Imports[0]; Assert.IsNotNull(import); Assert.AreEqual("my.ns.name", import.Namespace); }
public override void OnImportDirective(ImportDirective import) { Push(Document.CreateNode(XmlNodeType.Element, "import", null)); XmlAttribute att = Document.CreateAttribute("namespace"); att.Value = import.Namespace; Current.Attributes.Append(att); SerializeAssemblyReference(import.AssemblyReference); Pop(); }
private static IEnumerable <string> GetImportPaths(Uri sourceUri, ImportDirective importDirective) { try { return(CssDocumentHelpers.GetSourceUrisFromImport(sourceUri, importDirective) .Where(t => t.Item1.IsFile && !t.Item1.OriginalString.StartsWith("//", StringComparison.Ordinal)) // Skip protocol-relative paths .Select(t => t.Item1.LocalPath)); } catch (ArgumentException) { return(Enumerable.Empty <string>()); } }
private void LoadImports() { XmlNodeList imports = _node.SelectNodes("import"); foreach (XmlNode node in imports) { String ns = GetRequiredAttribute(node, "namespace"); ImportDirective import = new ImportDirective(LexicalInfo.Empty, ns); import.AssemblyReference = CreateAssemblyReference(node); Configuration.Imports.Add(import); } }
public void ParsingSimpleImportDeclarations() { AspectParser parser = CreateParser("import my\r\nimport two"); EngineConfiguration conf = parser.Parse(); Assert.IsNotNull(conf); Assert.IsNotNull(conf.Imports); Assert.AreEqual(2, conf.Imports.Count); ImportDirective import = conf.Imports[0]; Assert.IsNotNull(import); Assert.AreEqual("my", import.Namespace); import = conf.Imports[1]; Assert.IsNotNull(import); Assert.AreEqual("two", import.Namespace); }
/// <inheritdoc/> public DataType TryResolve(ImportDirective import, XmlQualifiedName typeName) { if (import == null) { throw new ArgumentNullException(nameof(import)); } if (typeName.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(typeName)); } // We only resolve if we own the namespace. if (import.Namespace == _dictionary.TargetNamespace && (import.TargetVersion == null || import.TargetVersion == _dictionary.TargetVersion)) { return(ResolveType(typeName)); } return(null); }
protected void ParseImportDirective(Group attrname, Group attrval) { ImportDirective id = new ImportDirective(); string name; string value; for (int i = 1; i < attrname.Captures.Count; i++) { name = attrname.Captures[i].Value; value = attrval.Captures[i].Value; switch (name.ToLower()) { case "namespace": id.Namespace = value; break; } } _doc.Directives.Add(id); }
public void BuildUsingCode() { CodeEngineBuilder builder = new CodeEngineBuilder(); EngineConfiguration conf = builder.GetConfiguration(); ImportDirective import = new ImportDirective(LexicalInfo.Empty, "AspectSharp.Tests.Classes"); import.AssemblyReference = new AssemblyReference(LexicalInfo.Empty, "AspectSharp.Tests"); conf.Imports.Add(import); conf.Mixins.Add("key", LexicalInfo.Empty).TypeReference = new TypeReference(LexicalInfo.Empty, "DummyMixin"); conf.Interceptors.Add("key", LexicalInfo.Empty).TypeReference = new TypeReference(LexicalInfo.Empty, "DummyInterceptor"); AspectDefinition aspect = new AspectDefinition(LexicalInfo.Empty, "McBrother"); aspect.TargetType = new TargetTypeDefinition(); aspect.TargetType.SingleType = new TypeReference(LexicalInfo.Empty, "DummyCustomer"); conf.Aspects.Add(aspect); MixinDefinition mixin = new MixinDefinition(LexicalInfo.Empty); mixin.TypeReference = new TypeReference(LexicalInfo.Empty, "key", TargetTypeEnum.Link); aspect.Mixins.Add(mixin); PointCutDefinition pointcut = new PointCutDefinition(LexicalInfo.Empty, PointCutFlags.Method); pointcut.Method = AllMethodSignature.Instance; InterceptorDefinition interceptor = new InterceptorDefinition(LexicalInfo.Empty); interceptor.TypeReference = new TypeReference(LexicalInfo.Empty, "key", TargetTypeEnum.Link); pointcut.Advices.Add(interceptor); aspect.PointCuts.Add(pointcut); AspectEngine engine = builder.Build(); AssertEngineConfiguration(engine); }
public virtual void EndVisit(ImportDirective node) { CommonEndVisit(node); }
ImportDirectives JoinImportDirectives(RoutineDirectives d1, RoutineDirectives d2, ImportDirective i) { var id = new ImportDirectives(i); id.Add(d1); id.Add(d2); return(id); }
public void Generate(AspxDocument doc, string outfile) { using (StreamWriter sw = new StreamWriter(outfile, false, new UTF8Encoding(true))) { if (!string.IsNullOrEmpty(doc.Inherits)) { //sw.WriteLine(string.Format("@inherits {0}", doc.Inherits)); } foreach (Directive directive in doc.Directives) { PageDirective pageDirective = directive as PageDirective; if (pageDirective != null) { if (!string.IsNullOrEmpty(pageDirective.MasterPageFile)) { sw.WriteLine(string.Format("@{{\r\n\tLayout = \"{0}\";\r\n}}", pageDirective.MasterPageFile.Replace(".Master", ".cshtml"))); } } ImportDirective importDirective = directive as ImportDirective; if (importDirective != null) { sw.WriteLine(string.Format("@using {0}", importDirective.Namespace)); } } bool afterCodeBlock = false; foreach (Block block in doc.Blocks) { HtmlBlock htmlBlock = block as HtmlBlock; if (htmlBlock != null) { string contents = doc.Contents.Substring(block.Index, block.Length); Regex regex = new Regex("^\\s*<"); //Check if started with < if (!afterCodeBlock || regex.IsMatch(contents)) { sw.Write(contents); //Write the contents directlhy } else { //Wrap it inside <text>...</text> sw.Write("<text>"); sw.Write(contents); sw.Write("</text>"); } } afterCodeBlock = false; CodeBlock codeBlock = block as CodeBlock; if (codeBlock != null) { if (codeBlock.IsFirst) { sw.WriteLine(" @{"); } sw.WriteLine("\r\n" + doc.Contents.Substring(block.Index + 2, block.Length - 4)); if (codeBlock.IsLast) { sw.WriteLine("}"); } afterCodeBlock = true; } ExpressionBlock expressionBlock = block as ExpressionBlock; if (expressionBlock != null) { sw.Write(string.Format("@{0} ", doc.Contents.Substring(block.Index + 3, block.Length - 5).Trim())); } CommentBlock commentBlock = block as CommentBlock; if (commentBlock != null) { sw.Write(string.Format("@*{0}*@", doc.Contents.Substring(block.Index + 3, block.Length - 6))); } ContentPlaceHolderBlock cphBlock = block as ContentPlaceHolderBlock; if (cphBlock != null) { if ("MainContent".Equals(cphBlock.ID)) { sw.WriteLine("\r\n\t@RenderBody()"); } } } } }
public override bool Visit(ImportDirective node) { return(false); }
public ImportDirectives(ImportDirective dir) { Importdir = dir; }
/// <inheritdoc/> public DataType TryResolve(ImportDirective import, XmlQualifiedName typeName) { return(_typeResolver.TryResolve(import, typeName)); }
public override void OnImportDirective(ImportDirective import) { Push( Document.CreateNode(XmlNodeType.Element, "import", null) ); XmlAttribute att = Document.CreateAttribute("namespace"); att.Value = import.Namespace; Current.Attributes.Append( att ); SerializeAssemblyReference( import.AssemblyReference ); Pop(); }
private static IEnumerable<string> GetImportPaths(Uri sourceUri, ImportDirective importDirective) { return CssDocumentHelpers.GetSourceUrisFromImport(sourceUri, importDirective) .Where(t => t.Item1.IsFile && !t.Item1.OriginalString.StartsWith("//", StringComparison.Ordinal)) // Skip protocol-relative paths .Select(t => t.Item1.LocalPath); }
public virtual bool Visit(ImportDirective node) { return(CommonVisit(node)); }