Example #1
0
 /// <inheritdoc />
 public bool Handle(CodeNamespaceImport obj, Context ctx)
 {
     if (ctx.ImportedNamespaces.Add(obj.Namespace))
     {
         ctx.Writer.WriteLine(
             $"Imports {VisualBasicUtils.GetValidNamespaceIdentifier(obj.Namespace)}");
     }
     return(true);
 }
Example #2
0
 /// <inheritdoc />
 protected override void DoHandle(CodeNamespace obj, Context ctx)
 {
     ctx.CurrentNamespace = obj.Name;
     ctx.Writer.Write($"Namespace {VisualBasicUtils.GetValidNamespaceIdentifier(ctx.CurrentNamespace)}");
     VisualBasicUtils.BeginBlock(BlockType.Namespace, ctx);
     GeneralUtils.HandleCollection(obj.Types.Cast <CodeTypeDeclaration>(), ctx.HandlerProvider.TypeDeclarationHandler, ctx,
                                   preAction: (c) => c.Writer.Indent(c),
                                   postAction: (c) => c.Writer.NewLine(), doPostActionOnLast: false);
     VisualBasicUtils.EndBlock(ctx);
 }
        /// <summary>
        /// Returns the provided string as a valid VB identifier
        /// </summary>
        /// <param name="self"></param>
        /// <returns></returns>
        public static string AsVbId(this string self)
        {
            if (self.Length == 0)
            {
                return(null);
            }

            if (self.Contains("."))
            {
                return(VisualBasicUtils.GetValidNamespaceIdentifier(self));
            }
            if (self.IsVbKeyword())
            {
                return("[" + self + "]");
            }
            return(self);
        }
 /// <inheritdoc />
 protected override string AsValidNamespace(string s)
 {
     return(VisualBasicUtils.GetValidNamespaceIdentifier(s));
 }