当前位置: 首页>>代码示例>>C#>>正文


C# Stetic.GetActions方法代码示例

本文整理汇总了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;
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:58,代码来源:ActionGroupDisplayBinding.cs

示例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);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:44,代码来源:ActionGroupDisplayBinding.cs

示例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);
		}
开发者ID:sushihangover,项目名称:monodevelop,代码行数:63,代码来源:ActionGroupDisplayBinding.cs


注:本文中的Stetic.GetActions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。