public void GenerateBuildCode(GeneratorContext ctx) { string varName = ctx.NewId (); CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement (typeof(Gtk.IconFactory), varName); varDec.InitExpression = new CodeObjectCreateExpression (typeof(Gtk.IconFactory)); ctx.Statements.Add (varDec); CodeVariableReferenceExpression var = new CodeVariableReferenceExpression (varName); foreach (ProjectIconSet icon in icons) { CodeExpression exp = new CodeMethodInvokeExpression ( var, "Add", new CodePrimitiveExpression (icon.Name), icon.GenerateObjectBuild (ctx) ); ctx.Statements.Add (exp); } CodeExpression addd = new CodeMethodInvokeExpression ( var, "AddDefault" ); ctx.Statements.Add (addd); }
public void GenerateBuildCode(GeneratorContext ctx) { string varName = ctx.NewId(); CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement(typeof(Gtk.IconFactory), varName); varDec.InitExpression = new CodeObjectCreateExpression(typeof(Gtk.IconFactory)); ctx.Statements.Add(varDec); CodeVariableReferenceExpression var = new CodeVariableReferenceExpression(varName); foreach (ProjectIconSet icon in icons) { CodeExpression exp = new CodeMethodInvokeExpression( var, "Add", new CodePrimitiveExpression(icon.Name), icon.GenerateObjectBuild(ctx) ); ctx.Statements.Add(exp); } CodeExpression addd = new CodeMethodInvokeExpression( var, "AddDefault" ); ctx.Statements.Add(addd); }
internal CodeExpression GenerateObjectBuild(GeneratorContext ctx) { string varName = ctx.NewId(); CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement(typeof(Gtk.IconSet), varName); ctx.Statements.Add(varDec); CodeVariableReferenceExpression var = new CodeVariableReferenceExpression(varName); if (sources.Count == 1 && sources[0].AllWildcarded) { varDec.InitExpression = new CodeObjectCreateExpression( typeof(Gtk.IconSet), sources[0].Image.ToCodeExpression(ctx) ); } else { varDec.InitExpression = new CodeObjectCreateExpression(typeof(Gtk.IconSet)); foreach (ProjectIconSource src in sources) { CodeExpression exp = new CodeMethodInvokeExpression( var, "AddSource", src.GenerateObjectBuild(ctx) ); ctx.Statements.Add(exp); } } return(var); }
internal CodeExpression GenerateObjectBuild(GeneratorContext ctx) { string varName = ctx.NewId (); CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement (typeof(Gtk.IconSource), varName); varDec.InitExpression = new CodeObjectCreateExpression (typeof(Gtk.IconSource)); ctx.Statements.Add (varDec); CodeVariableReferenceExpression var = new CodeVariableReferenceExpression (varName); ctx.Statements.Add (new CodeAssignStatement ( new CodePropertyReferenceExpression (var, "Pixbuf"), imageInfo.ToCodeExpression (ctx) )); if (!SizeWildcarded) { ctx.Statements.Add (new CodeAssignStatement ( new CodePropertyReferenceExpression (var, "SizeWildcarded"), new CodePrimitiveExpression (false) )); ctx.Statements.Add (new CodeAssignStatement ( new CodePropertyReferenceExpression (var, "Size"), new CodeFieldReferenceExpression ( new CodeTypeReferenceExpression ("Gtk.IconSize"), Size.ToString () ) )); } if (!StateWildcarded) { ctx.Statements.Add (new CodeAssignStatement ( new CodePropertyReferenceExpression (var, "StateWildcarded"), new CodePrimitiveExpression (false) )); ctx.Statements.Add (new CodeAssignStatement ( new CodePropertyReferenceExpression (var, "State"), new CodeFieldReferenceExpression ( new CodeTypeReferenceExpression ("Gtk.StateType"), State.ToString () ) )); } if (!DirectionWildcarded) { ctx.Statements.Add (new CodeAssignStatement ( new CodePropertyReferenceExpression (var, "DirectionWildcarded"), new CodePrimitiveExpression (false) )); ctx.Statements.Add (new CodeAssignStatement ( new CodePropertyReferenceExpression (var, "Direction"), new CodeFieldReferenceExpression ( new CodeTypeReferenceExpression ("Gtk.TextDirection"), Direction.ToString () ) )); } return var; }
internal CodeExpression GenerateObjectBuild(GeneratorContext ctx) { string varName = ctx.NewId (); CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement (typeof(Gtk.IconSet), varName); ctx.Statements.Add (varDec); CodeVariableReferenceExpression var = new CodeVariableReferenceExpression (varName); if (sources.Count == 1 && sources[0].AllWildcarded) { varDec.InitExpression = new CodeObjectCreateExpression ( typeof(Gtk.IconSet), sources[0].Image.ToCodeExpression (ctx) ); } else { varDec.InitExpression = new CodeObjectCreateExpression (typeof(Gtk.IconSet)); foreach (ProjectIconSource src in sources) { CodeExpression exp = new CodeMethodInvokeExpression ( var, "AddSource", src.GenerateObjectBuild (ctx) ); ctx.Statements.Add (exp); } } return var; }
internal CodeExpression GenerateObjectBuild(GeneratorContext ctx) { string varName = ctx.NewId(); CodeVariableDeclarationStatement varDec = new CodeVariableDeclarationStatement(typeof(Gtk.IconSource), varName); varDec.InitExpression = new CodeObjectCreateExpression(typeof(Gtk.IconSource)); ctx.Statements.Add(varDec); CodeVariableReferenceExpression var = new CodeVariableReferenceExpression(varName); ctx.Statements.Add(new CodeAssignStatement( new CodePropertyReferenceExpression(var, "Pixbuf"), imageInfo.ToCodeExpression(ctx) )); if (!SizeWildcarded) { ctx.Statements.Add(new CodeAssignStatement( new CodePropertyReferenceExpression(var, "SizeWildcarded"), new CodePrimitiveExpression(false) )); ctx.Statements.Add(new CodeAssignStatement( new CodePropertyReferenceExpression(var, "Size"), new CodeFieldReferenceExpression( new CodeTypeReferenceExpression("Gtk.IconSize"), Size.ToString() ) )); } if (!StateWildcarded) { ctx.Statements.Add(new CodeAssignStatement( new CodePropertyReferenceExpression(var, "StateWildcarded"), new CodePrimitiveExpression(false) )); ctx.Statements.Add(new CodeAssignStatement( new CodePropertyReferenceExpression(var, "State"), new CodeFieldReferenceExpression( new CodeTypeReferenceExpression("Gtk.StateType"), State.ToString() ) )); } if (!DirectionWildcarded) { ctx.Statements.Add(new CodeAssignStatement( new CodePropertyReferenceExpression(var, "DirectionWildcarded"), new CodePrimitiveExpression(false) )); ctx.Statements.Add(new CodeAssignStatement( new CodePropertyReferenceExpression(var, "Direction"), new CodeFieldReferenceExpression( new CodeTypeReferenceExpression("Gtk.TextDirection"), Direction.ToString() ) )); } return(var); }