mirror of
https://github.com/ShrlAlgo/RevitGen.git
synced 2026-03-08 01:38:53 +00:00
优化生成器事务调用,项目结构
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace RevitGen.Generator
|
||||
{
|
||||
/// <summary>
|
||||
@@ -34,7 +34,7 @@ namespace RevitGen.Generator
|
||||
}
|
||||
|
||||
var attributeData = classSymbol.GetAttributes().First(ad => ad.AttributeClass?.ToDisplayString() == RevitCommandAttributeFullName);
|
||||
var transactionMode = GetAttributeProperty(attributeData, "TransactionMode", 1);
|
||||
var usingTransaction = GetAttributeProperty(attributeData, "UsingTransaction", true);
|
||||
|
||||
var source = new StringBuilder();
|
||||
source.AppendLine("// <auto-generated/>");
|
||||
@@ -46,7 +46,7 @@ namespace RevitGen.Generator
|
||||
source.AppendLine(" using System.ComponentModel;");
|
||||
source.AppendLine();
|
||||
|
||||
source.AppendLine($" [Transaction((TransactionMode){transactionMode})]");
|
||||
source.AppendLine($" [Transaction(TransactionMode.Manual)]");
|
||||
source.AppendLine($" public partial class {className} : IExternalCommand");
|
||||
source.AppendLine(" {");
|
||||
source.AppendLine(" private ExternalCommandData _commandData;");
|
||||
@@ -66,7 +66,7 @@ namespace RevitGen.Generator
|
||||
source.AppendLine();
|
||||
source.AppendLine(" try");
|
||||
source.AppendLine(" {");
|
||||
if (transactionMode == 1)
|
||||
if (usingTransaction)
|
||||
{
|
||||
source.AppendLine($" using (var trans = new Transaction(this.Document, \"{className}\"))");
|
||||
source.AppendLine(" {");
|
||||
@@ -170,7 +170,8 @@ namespace RevitGen.Generator
|
||||
|
||||
source.AppendLine();
|
||||
|
||||
var commandsWithData = commandClasses.Select(c => new {
|
||||
var commandsWithData = commandClasses.Select(c => new
|
||||
{
|
||||
Symbol = c,
|
||||
Attribute = c.GetAttributes().First(ad => ad.AttributeClass?.ToDisplayString() == RevitCommandAttributeFullName)
|
||||
}).ToList();
|
||||
|
||||
Reference in New Issue
Block a user