本文整理汇总了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;
}
示例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);
}
示例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 );
}
示例4: GenerateObjectCreation
internal protected override CodeExpression GenerateObjectCreation (GeneratorContext ctx)
{
return new CodeObjectCreateExpression (
ClassDescriptor.WrappedTypeName.ToGlobalTypeRef (),
new CodePrimitiveExpression (null),
new CodePrimitiveExpression (null)
);
}
示例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);
}
示例6: Run
public void Run(ServiceDefinition definition)
{
var context = new GeneratorContext();
context.Definition = definition;
context.Root = definition.Root;
this.WriteEverything(context);
text.Flush();
}
示例7: GenerateObjectCreation
protected internal override CodeExpression GenerateObjectCreation(GeneratorContext ctx)
{
if (IsTextCombo) {
return new CodeMethodInvokeExpression (
new CodeTypeReferenceExpression ("Gtk.ComboBoxEntry"),
"NewText"
);
} else
return base.GenerateObjectCreation (ctx);
}
示例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 );
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}