private void GenerateVB() { using (Microsoft.VisualBasic.VBCodeProvider provider = new Microsoft.VisualBasic.VBCodeProvider()) { CodeGeneratorOptions opts = new CodeGeneratorOptions(); StringWriter sw = new StringWriter(); List <CodeTypeReference> implTypes = new List <CodeTypeReference>(); if (_property.ImplementationTypes != null) { var arr = new CodeTypeReference[_property.ImplementationTypes.Count]; _property.ImplementationTypes.CopyTo(arr, 0); _property.ImplementationTypes.Clear(); implTypes.AddRange(arr); } provider.GenerateCodeFromMember(_property, sw, opts); foreach (CodeTypeReference tr in implTypes) { _property.ImplementationTypes.Add(tr); } StringReader sr = new StringReader(sw.GetStringBuilder().ToString()); string line = sr.ReadLine(); while (string.IsNullOrEmpty(line) || line.StartsWith("'") || line.StartsWith("<")) { line = sr.ReadLine(); } StringBuilder sb = new StringBuilder(); sb.Append(line); if (InterfaceProperties != null) { sb.Append(" Implements "); foreach (CodeTypeReference tr in implTypes) { string prop; if (InterfaceProperties.TryGetValue(tr, out prop)) { sb.Append(provider.GetTypeOutput(tr)).Append(".").Append(prop).Append(", "); } } sb.Length -= 2; } Text = sw.GetStringBuilder().Replace(line, sb.ToString()).ToString(); } }
private void GenerateVB() { using (Microsoft.VisualBasic.VBCodeProvider provider = new Microsoft.VisualBasic.VBCodeProvider()) { CodeGeneratorOptions opts = new CodeGeneratorOptions(); StringWriter sw = new StringWriter(); List <CodeTypeReference> implTypes = new List <CodeTypeReference>(); if (_property.ImplementationTypes != null) { implTypes.AddRange(_property.ImplementationTypes.Cast <CodeTypeReference>().Distinct(new CodeTypeReferenceEqualityComparer())); _property.ImplementationTypes.Clear(); } provider.GenerateCodeFromMember(_property, sw, opts); foreach (CodeTypeReference tr in implTypes) { _property.ImplementationTypes.Add(tr); } StringReader sr = new StringReader(sw.GetStringBuilder().ToString()); string line = sr.ReadLine(); while (string.IsNullOrEmpty(line) || line.StartsWith("'") || line.StartsWith("<")) { line = sr.ReadLine(); } StringBuilder sb = new StringBuilder(); sb.Append(line); if (InterfaceProperties != null) { sb.Append(" Implements "); foreach (CodeTypeReference tr in implTypes) { foreach (var prop in InterfaceProperties.Where(it => it.Item1.IsEquals(tr))) { sb.Append(provider.GetTypeOutput(tr)).Append(".").Append(prop.Item2).Append(", "); } } sb.Length -= 2; } Text = sw.GetStringBuilder().Replace(line, sb.ToString()).ToString(); } }
private void GenerateVB() { using (Microsoft.VisualBasic.VBCodeProvider provider = new Microsoft.VisualBasic.VBCodeProvider()) { CodeGeneratorOptions opts = new CodeGeneratorOptions(); StringWriter sw = new StringWriter(); List<CodeTypeReference> implTypes = new List<CodeTypeReference>(); if (_property.ImplementationTypes != null) { var arr = new CodeTypeReference[_property.ImplementationTypes.Count]; _property.ImplementationTypes.CopyTo(arr, 0); _property.ImplementationTypes.Clear(); implTypes.AddRange(arr); } provider.GenerateCodeFromMember(_property, sw, opts); foreach (CodeTypeReference tr in implTypes) { _property.ImplementationTypes.Add(tr); } StringReader sr = new StringReader(sw.GetStringBuilder().ToString()); string line = sr.ReadLine(); while (string.IsNullOrEmpty(line) || line.StartsWith("'") || line.StartsWith("<")) line = sr.ReadLine(); StringBuilder sb = new StringBuilder(); sb.Append(line); if (InterfaceProperties != null) { sb.Append(" Implements "); foreach (CodeTypeReference tr in implTypes) { string prop; if (InterfaceProperties.TryGetValue(tr, out prop)) { sb.Append(provider.GetTypeOutput(tr)).Append(".").Append(prop).Append(", "); } } sb.Length -= 2; } Text = sw.GetStringBuilder().Replace(line, sb.ToString()).ToString(); } }