本文整理汇总了C#中Stetic.GetActions方法的典型用法代码示例。如果您正苦于以下问题:C# Stetic.GetActions方法的具体用法?C# Stetic.GetActions怎么用?C# Stetic.GetActions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stetic
的用法示例。
在下文中一共展示了Stetic.GetActions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateClass
static IType CreateClass (Project project, Stetic.ActionGroupComponent group, string name, string namspace, string folder)
{
string fullName = namspace.Length > 0 ? namspace + "." + name : name;
CodeRefactorer gen = new CodeRefactorer (project.ParentSolution);
CodeTypeDeclaration type = new CodeTypeDeclaration ();
type.Name = name;
type.IsClass = true;
type.BaseTypes.Add (new CodeTypeReference ("Gtk.ActionGroup"));
// Generate the constructor. It contains the call that builds the widget.
CodeConstructor ctor = new CodeConstructor ();
ctor.Attributes = MemberAttributes.Public | MemberAttributes.Final;
ctor.BaseConstructorArgs.Add (new CodePrimitiveExpression (fullName));
CodeMethodInvokeExpression call = new CodeMethodInvokeExpression (
new CodeMethodReferenceExpression (
new CodeTypeReferenceExpression ("Stetic.Gui"),
"Build"
),
new CodeThisReferenceExpression (),
new CodeTypeOfExpression (fullName)
);
ctor.Statements.Add (call);
type.Members.Add (ctor);
// Add signal handlers
foreach (Stetic.ActionComponent action in group.GetActions ()) {
foreach (Stetic.Signal signal in action.GetSignals ()) {
CodeMemberMethod met = new CodeMemberMethod ();
met.Name = signal.Handler;
met.Attributes = MemberAttributes.Family;
met.ReturnType = new CodeTypeReference (signal.SignalDescriptor.HandlerReturnTypeName);
foreach (Stetic.ParameterDescriptor pinfo in signal.SignalDescriptor.HandlerParameters)
met.Parameters.Add (new CodeParameterDeclarationExpression (pinfo.TypeName, pinfo.Name));
type.Members.Add (met);
}
}
// Create the class
IType cls = null;
cls = gen.CreateClass (project, ((DotNetProject)project).LanguageName, folder, namspace, type);
if (cls == null)
throw new UserException ("Could not create class " + fullName);
project.AddFile (cls.CompilationUnit.FileName, BuildAction.Compile);
IdeApp.ProjectOperations.Save (project);
// Make sure the database is up-to-date
ProjectDomService.Parse (project, cls.CompilationUnit.FileName);
return cls;
}
示例2: CreateClass
static IUnresolvedTypeDefinition CreateClass (Project project, Stetic.ActionGroupComponent group, string name, string namspace, string folder)
{
string fullName = namspace.Length > 0 ? namspace + "." + name : name;
var type = new CodeTypeDeclaration ();
type.Name = name;
type.IsClass = true;
type.BaseTypes.Add (new CodeTypeReference ("Gtk.ActionGroup"));
// Generate the constructor. It contains the call that builds the widget.
var ctor = new CodeConstructor ();
ctor.Attributes = MemberAttributes.Public | MemberAttributes.Final;
ctor.BaseConstructorArgs.Add (new CodePrimitiveExpression (fullName));
var call = new CodeMethodInvokeExpression (
new CodeMethodReferenceExpression (
new CodeTypeReferenceExpression ("Stetic.Gui"),
"Build"
),
new CodeThisReferenceExpression (),
new CodeTypeOfExpression (fullName)
);
ctor.Statements.Add (call);
type.Members.Add (ctor);
// Add signal handlers
foreach (Stetic.ActionComponent action in group.GetActions ()) {
foreach (Stetic.Signal signal in action.GetSignals ()) {
CodeMemberMethod met = new CodeMemberMethod ();
met.Name = signal.Handler;
met.Attributes = MemberAttributes.Family;
met.ReturnType = new CodeTypeReference (signal.SignalDescriptor.HandlerReturnTypeName);
foreach (Stetic.ParameterDescriptor pinfo in signal.SignalDescriptor.HandlerParameters)
met.Parameters.Add (new CodeParameterDeclarationExpression (pinfo.TypeName, pinfo.Name));
type.Members.Add (met);
}
}
// Create the class
return CodeGenerationService.AddType ((DotNetProject)project, folder, namspace, type);
}
示例3: CreateClass
static ITypeSymbol CreateClass (MonoDevelop.Projects.Project project, Stetic.ActionGroupComponent group, string name, string namspace, string folder)
{
string fullName = namspace.Length > 0 ? namspace + "." + name : name;
var type = SyntaxFactory.ClassDeclaration (name)
.AddBaseListTypes (SyntaxFactory.SimpleBaseType (SyntaxFactory.ParseTypeName ("Gtk.ActionGroup")));
// Generate the constructor. It contains the call that builds the widget.
var members = new SyntaxList<MemberDeclarationSyntax> ();
var ctor = SyntaxFactory.ConstructorDeclaration (
new SyntaxList<AttributeListSyntax> (),
SyntaxFactory.TokenList (SyntaxFactory.Token (SyntaxKind.PublicKeyword)),
SyntaxFactory.Identifier (name),
SyntaxFactory.ParameterList (),
SyntaxFactory.ConstructorInitializer (SyntaxKind.BaseKeyword, SyntaxFactory.ArgumentList (new SeparatedSyntaxList<ArgumentSyntax> { SyntaxFactory.Argument (SyntaxFactory.ParseExpression (fullName)) } )),
SyntaxFactory.Block (
SyntaxFactory.ExpressionStatement (
SyntaxFactory.InvocationExpression (
SyntaxFactory.ParseExpression ("Stetic.Gui.Build"),
SyntaxFactory.ArgumentList (
new SeparatedSyntaxList<ArgumentSyntax> {
SyntaxFactory.Argument (SyntaxFactory.ThisExpression ()),
SyntaxFactory.Argument (SyntaxFactory.ParseExpression (fullName))
}
)
)
)
)
);
type = type.AddMembers (ctor);
// Add signal handlers
foreach (Stetic.ActionComponent action in group.GetActions ()) {
foreach (Stetic.Signal signal in action.GetSignals ()) {
var parameters = new SeparatedSyntaxList<ParameterSyntax> ();
foreach (var p in signal.SignalDescriptor.HandlerParameters) {
parameters = parameters.Add (SyntaxFactory.Parameter (new SyntaxList<AttributeListSyntax> (), SyntaxFactory.TokenList (), SyntaxFactory.ParseTypeName (p.TypeName), SyntaxFactory.Identifier (p.Name), null));
}
var met = SyntaxFactory.MethodDeclaration (
new SyntaxList<AttributeListSyntax> (),
SyntaxFactory.TokenList (SyntaxFactory.Token (SyntaxKind.ProtectedKeyword)),
SyntaxFactory.ParseTypeName (signal.SignalDescriptor.HandlerReturnTypeName),
null,
SyntaxFactory.Identifier (signal.Handler),
null,
SyntaxFactory.ParameterList (parameters),
new SyntaxList<TypeParameterConstraintClauseSyntax> (),
SyntaxFactory.Block (),
null
);
type = type.AddMembers (met);
}
}
// Create the class
return CodeGenerationService.AddType ((DotNetProject)project, folder, namspace, type);
}