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


C# GeneratorContext类代码示例

本文整理汇总了C#中GeneratorContext的典型用法代码示例。如果您正苦于以下问题:C# GeneratorContext类的具体用法?C# GeneratorContext怎么用?C# GeneratorContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GeneratorContext类属于命名空间,在下文中一共展示了GeneratorContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RecreateInterfaceProxy

		public object RecreateInterfaceProxy(SerializationInfo info, StreamingContext context)
		{
			object proxy = null;

			GeneratorContext genContext = new GeneratorContext();

			foreach(object mixin in _mixins)
			{
				genContext.AddMixinInstance(mixin);
			}

			InterfaceProxyGenerator gen = new InterfaceProxyGenerator( _scope, genContext );

			object target = info.GetValue("__target", typeof(object));

			if (_mixins.Length == 0)
			{
				Type proxy_type = gen.GenerateCode( _interfaces, target.GetType());

				proxy = Activator.CreateInstance( proxy_type, new object[] { _interceptor, target } );
			}
			else
			{
				Type proxy_type = gen.GenerateCode( _interfaces, target.GetType() );

				proxy = Activator.CreateInstance( proxy_type, new object[] { _interceptor, target, genContext.MixinsAsArray() } );
			}

			return proxy;
		}
开发者ID:atczyc,项目名称:castle,代码行数:30,代码来源:ProxyObjectReference.cs

示例2: GeneratePropertySet

		protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
		{
			if (prop.Name == "Alpha" && Alpha == -1)
				return;
			else
				base.GeneratePropertySet (ctx, var, prop);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:ColorButton.cs

示例3: TwoMixins

		public void TwoMixins()
		{
			GeneratorContext context = new GeneratorContext();
			SimpleMixin mixin1 = new SimpleMixin();
			OtherMixin mixin2 = new OtherMixin();

			context.AddMixinInstance( mixin1 );
			context.AddMixinInstance( mixin2 );

			AssertInvocationInterceptor interceptor = new AssertInvocationInterceptor();

			object proxy = _generator.CreateCustomClassProxy( 
				typeof(SimpleClass), interceptor, context );
			
			Assert.IsFalse( interceptor.Invoked );

			Assert.IsNotNull(proxy);
			Assert.IsTrue( typeof(SimpleClass).IsAssignableFrom( proxy.GetType() ) );

			ISimpleMixin mixin = proxy as ISimpleMixin;
			Assert.IsNotNull(mixin);
			Assert.AreEqual(1, mixin.DoSomething());

			Assert.IsTrue( interceptor.Invoked );
			Assert.AreSame( proxy, interceptor.proxy );
			Assert.AreSame( mixin1, interceptor.mixin );

			IOtherMixin other = proxy as IOtherMixin;
			Assert.IsNotNull(other);
			Assert.AreEqual(3, other.Sum(1,2));
			Assert.IsTrue( interceptor.Invoked );
			Assert.AreSame( proxy, interceptor.proxy );
			Assert.AreSame( mixin2, interceptor.mixin );

		}
开发者ID:ralescano,项目名称:castle,代码行数:35,代码来源:MixinTestCase.cs

示例4: GenerateObjectCreation

		internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
		{
			return new CodeObjectCreateExpression (
				ClassDescriptor.WrappedTypeName.ToGlobalTypeRef (), 
				new CodePrimitiveExpression (null), 
				new CodePrimitiveExpression (null)
			);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:8,代码来源:ToolButton.cs

示例5: GenerateObjectCreation

		internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
		{
			if (textCombo) {
				return new CodeMethodInvokeExpression (
					new CodeTypeReferenceExpression (new CodeTypeReference ("Gtk.ComboBox", CodeTypeReferenceOptions.GlobalReference)),
					"NewText"
				);
			} else
				return base.GenerateObjectCreation (ctx);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:10,代码来源:ComboBox.cs

示例6: Run

        public void Run(ServiceDefinition definition)
        {
            var context = new GeneratorContext();
            context.Definition = definition;
            context.Root = definition.Root;

            this.WriteEverything(context);

            text.Flush();
        }
开发者ID:collinsauve,项目名称:LinkedInNET,代码行数:10,代码来源:CSharpGenerator.cs

示例7: GenerateObjectCreation

 protected internal override CodeExpression GenerateObjectCreation(GeneratorContext ctx)
 {
     if (IsTextCombo) {
         return new CodeMethodInvokeExpression (
             new CodeTypeReferenceExpression ("Gtk.ComboBoxEntry"),
             "NewText"
         );
     } else
         return base.GenerateObjectCreation (ctx);
 }
开发者ID:mono,项目名称:stetic,代码行数:10,代码来源:ComboBoxEntry.cs

示例8: CreateCustomProxy

        public void CreateCustomProxy()
        {
            GeneratorContext context = new GeneratorContext(
                new EnhanceTypeDelegate(EnhanceType),
                new ScreenInterfacesDelegate(ScreenInterfaces));

            object proxy = m_generator.CreateCustomProxy(
                typeof (IMyInterface),
                new StandardInvocationHandler(new MyInterfaceImpl()), context);

            Assert.IsTrue( m_enhanceInvoked );
            Assert.IsTrue( m_screenInvoked );
        }
开发者ID:BackupTheBerlios,项目名称:dpml-svn,代码行数:13,代码来源:CustomProxyGeneratorTestCase.cs

示例9: GeneratePropertySet

		protected override void GeneratePropertySet (GeneratorContext ctx, CodeExpression var, PropertyDescriptor prop)
		{
			if (prop.Name == "Group") {
				CodeExpression groupExp = GroupManager.GenerateGroupExpression (ctx, (Gtk.Widget) Wrapped);
				ctx.Statements.Add (
					new CodeAssignStatement (
						new CodePropertyReferenceExpression (var, "Group"),
						groupExp)
				);
			}
			else
				base.GeneratePropertySet (ctx, var, prop);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:13,代码来源:RadioToolButton.cs

示例10: GenerateBuildCode

        public void GenerateBuildCode(GeneratorContext ctx, CodeVariableReferenceExpression uiManager)
        {
            StringBuilder sb = new StringBuilder ();
            sb.Append ("<ui>");
            GenerateUiString (sb);
            sb.Append ("</ui>");

            CodeMethodInvokeExpression exp = new CodeMethodInvokeExpression (
                uiManager,
                "AddUiFromString",
                new CodePrimitiveExpression (sb.ToString ())
            );
            ctx.Statements.Add (exp);
        }
开发者ID:mono,项目名称:stetic,代码行数:14,代码来源:ActionTree.cs

示例11: Main

 public static void Main(string[] args)
 {
     try
     {
         List<object> instances = new List<object>();
         GeneratorContext context = new GeneratorContext();
         Generator generator = new Generator(instances, context);
         generator.Execute();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
开发者ID:st9200,项目名称:soal-oslo,代码行数:14,代码来源:Program.cs

示例12: GenerateChildBuildCode

		protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
		{
			if (wrapper.Wrapped == expander.LabelWidget) {
				CodeExpression var = ctx.GenerateNewInstanceCode (wrapper);
				CodeAssignStatement assign = new CodeAssignStatement (
					new CodePropertyReferenceExpression (
						parentVar,
						"LabelWidget"
					),
					var
				);
				ctx.Statements.Add (assign);
			} else
				base.GenerateChildBuildCode (ctx, parentVar, wrapper);
		}
开发者ID:Kalnor,项目名称:monodevelop,代码行数:15,代码来源:Expander.cs

示例13: Main

		static void Main(string[] args)
		{
			AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

			MainOptions opts = new MainOptions();
			opts.ProcessArgs(args);

			if (args.Length == 0 || args[0].StartsWith("-"))
			{
				ShowUsage();
			}

			Console.WriteLine("Processing {0} {1}", args[0], opts.verbose);

			IGenerator generator = null;

			if (args[0] == "controller")
			{
				generator = new NewController();
			}
			else if (args[0] == "project")
			{
				generator = new NewProject();
			}
			else
			{
				Console.Error.WriteLine("Not supported");
				return;
			}

			Configure(generator, args);

			string workingDir = AppDomain.CurrentDomain.BaseDirectory;
			string templateDir = @"C:\dev\DotNet\castle\svn\trunk\MonoRail\NewGenerator\GeneratorTemplates\";

			GeneratorContext context = new GeneratorContext(workingDir, templateDir);

			ITemplateEngine engine = new NVelocityTemplateEngine(templateDir);

			if (engine is ISupportInitialize)
			{
				((ISupportInitialize)engine).BeginInit();
			}

			generator.Generate(context, new DefaultGeneratorService(context, engine));
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:46,代码来源:Program.cs

示例14: GenerateChildBuildCode

		protected override void GenerateChildBuildCode (GeneratorContext ctx, CodeExpression parentVar, Widget wrapper)
		{
			if (!HasLabel) {
				// CheckButton generates a label by default. Remove it if it is not required.
				ctx.Statements.Add (
					new CodeMethodInvokeExpression (
						parentVar,
						"Remove",
						new CodePropertyReferenceExpression (
							parentVar,
							"Child"
						)
					)
				);
			}
			base.GenerateChildBuildCode (ctx, parentVar, wrapper);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:17,代码来源:CheckButton.cs

示例15: GenerateBuildCode

		internal protected override void GenerateBuildCode (GeneratorContext ctx, CodeExpression var)
		{
			if (Text.Length > 0) {
				ctx.Statements.Add (
					new CodeAssignStatement (
						new CodePropertyReferenceExpression (
							new CodePropertyReferenceExpression (
								var,
								"Buffer"
							),
							"Text"
						),
						new CodePrimitiveExpression (Text)
					)
				);
			}
			base.GenerateBuildCode (ctx, var);
		}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:18,代码来源:TextView.cs


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