// For Demo internal override void Convert(VBNetCodeFileWriter writer) { var ctx = ParserContext as VisualBasic6Parser.PropertySetStmtContext; var propName = ctx.ambiguousIdentifier().GetText(); if (!RootModule.PropsSet.ContainsKey(propName)) { return; // Already converted by another prop pair. } // Check if Get property pair exist VBPropertyGetStmt getProp = null; if (RootModule.PropsGet.ContainsKey(propName)) { getProp = RootModule.PropsGet[propName]; } // Convert to VB.net prop format: Public Property PropName(ByVal arg1 As DataType) As DataType if (PropVisibility != null) { PropVisibility.Convert(writer); writer.Write(" "); } if (PropStatic != null) { PropStatic.Convert(writer); writer.Write(" "); } if (getProp == null) { // Write only prop writer.Write("WriteOnly "); } writer.Write("Property "); PropName.Convert(writer); if (getProp != null) { // Use arg list & return type from Get prop if exist. It is the same with Set prop. if (getProp.PropTypeHint != null) { getProp.PropTypeHint.Convert(writer); } getProp.PropArgList.Convert(writer); if (getProp.PropAsType != null) { writer.Write(" "); getProp.PropAsType.Convert(writer); } } else { // This is write only prop. Use arg list from Set prop. var propSetTypeHint = PropSetArg.CodeModels.OfType <VBTypeHint>().FirstOrDefault(); if (propSetTypeHint != null) { propSetTypeHint.Convert(writer); } writer.Write("("); if (PropArgs.Count > 0) { int i = 0; for (i = 0; i < PropArgs.Count - 1; i++) { PropArgs[i].Convert(writer); writer.Write(", "); } PropArgs[i].Convert(writer); // Last one } writer.Write(")"); var propSetAsType = PropSetArg.CodeModels.OfType <VBAsTypeClause>().FirstOrDefault(); if (propSetAsType != null) { writer.Write(" "); propSetAsType.Convert(writer); } } var canConvert = false; if (getProp != null) { // Convert to VB.net Get prop code block (Get ... End Get) writer.NewLine(); writer.Write("Get"); writer.NewLine(); foreach (var model in getProp.CodeModels) { // Actual Get code block starts after a new line if (canConvert) { model.Convert(writer); } else { canConvert = (model is VBNewLine); } } //writer.NewLine(); writer.Write("End Get"); } // Convert to VB.net Set prop code block (Set ... End Set) writer.NewLine(); writer.Write("Set("); PropSetArg.Convert(writer); writer.Write(")"); writer.NewLine(); canConvert = false; foreach (var model in this.CodeModels) { // Actual Set code block starts after a new line if (canConvert) { model.Convert(writer); } else { canConvert = (model is VBNewLine); } } //writer.NewLine(); writer.Write("End Set"); writer.NewLine(); writer.Write("End Property"); // Make sure to remove cache data from module, so that prop conversion is not duplicated. if (RootModule.PropsGet.ContainsKey(propName)) { RootModule.PropsGet.Remove(propName); } if (RootModule.PropsSet.ContainsKey(propName)) { RootModule.PropsSet.Remove(propName); } }
// For Demo internal override void Convert(VBNetCodeFileWriter writer) { var ctx = ParserContext as VisualBasic6Parser.PropertyGetStmtContext; var propName = ctx.ambiguousIdentifier().GetText(); if (!RootModule.PropsGet.ContainsKey(propName)) { return; // Already converted by another prop pair. } // Check if Let property pair exist VBPropertyLetStmt letProp = null; if (RootModule.PropsLet.ContainsKey(propName)) { letProp = RootModule.PropsLet[propName]; } // Check if Set property pair exist VBPropertySetStmt setProp = null; if (RootModule.PropsSet.ContainsKey(propName)) { setProp = RootModule.PropsSet[propName]; } if (letProp != null) { // Let prop do the conversion letProp.Convert(writer); return; } if (setProp != null) { // Set prop do the conversion setProp.Convert(writer); return; } // Reach here if this is a read only prop // Convert to VB.net prop format: Public Property PropName(ByVal arg1 As DataType) As DataType if (PropVisibility != null) { PropVisibility.Convert(writer); writer.Write(" "); } if (PropStatic != null) { PropStatic.Convert(writer); writer.Write(" "); } if ((letProp == null) && (setProp == null)) { // Read only prop writer.Write("ReadOnly "); } writer.Write("Property "); PropName.Convert(writer); // Use arg list & return type from Get prop if (PropTypeHint != null) { PropTypeHint.Convert(writer); } PropArgList.Convert(writer); if (PropAsType != null) { writer.Write(" "); PropAsType.Convert(writer); } // Convert to VB.net Get prop code block (Get ... End Get) writer.NewLine(); writer.Write("Get"); writer.NewLine(); var canConvert = false; foreach (var model in CodeModels) { // Actual Get code block starts after a new line if (canConvert) { model.Convert(writer); } else { canConvert = (model is VBNewLine); } } writer.Write("End Get"); writer.NewLine(); writer.Write("End Property"); // Make sure to remove cache data from module, so that prop conversion is not duplicated. if (RootModule.PropsGet.ContainsKey(propName)) { RootModule.PropsGet.Remove(propName); } }