Skip to content

Commit

Permalink
Adding namespace and stub for CSharpUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Rapp committed Nov 24, 2017
1 parent 4fdfbc6 commit a28aaa6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
20 changes: 20 additions & 0 deletions CSharpUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace Rappen.XTB.LCG
{
internal class CSharpUtils
{
internal static void GenerateClasses(List<EntityMetadataProxy> entities, string ns)
{
foreach (var entity in entities.Where(e => e.Selected))
{
foreach (var attribute in entity.Attributes.Where(a => a.Selected))
{

}
}
}
}
}
23 changes: 11 additions & 12 deletions LCG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void attributeFilter_Changed(object sender, EventArgs e)

private void btnGenerate_Click(object sender, EventArgs e)
{
GenerateClasses();
CSharpUtils.GenerateClasses(entities, txtNamespace.Text);
}

private void btnLoadEntities_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -104,6 +104,7 @@ private void chkAllRows_CheckedChanged(object sender, EventArgs e)
private void entityFilter_Changed(object sender, EventArgs e)
{
FilterEntities();
SetNamespace();
}

private void grid_CellClick(object sender, DataGridViewCellEventArgs e)
Expand Down Expand Up @@ -293,17 +294,6 @@ private void FilterEntities()
UpdateEntitiesStatus();
}

private void GenerateClasses()
{
var ent = string.Join("\n", entities
.Where(e => e.IsSelected)
.Select(e => e.ToString() + "\n" +
string.Join("\n", e.Attributes
.Where(a => a.IsSelected)
.Select(a => " " + a.ToString()))));
MessageBox.Show(ent);
}

private EntityMetadataProxy GetSelectedEntity()
{
if (gridEntities.SelectedRows.Count == 1)
Expand Down Expand Up @@ -502,6 +492,14 @@ private void LoadSolutions()
});
}

private void SetNamespace()
{
if (cmbSolution.SelectedItem is SolutionProxy solution && string.IsNullOrWhiteSpace(txtNamespace.Text))
{
txtNamespace.Text = solution.UniqueName;
}
}

private void SettingsLoad(string connectionname)
{
if (SettingsManager.Instance.TryLoad(GetType(), out Settings settings, connectionname))
Expand Down Expand Up @@ -592,6 +590,7 @@ private void UpdateAttributesStatus()
private void UpdateEntitiesStatus()
{
chkEntAll.Visible = gridEntities.Rows.Count > 0;
btnGenerate.Enabled = (bool)entities?.Any(e => e.IsSelected);
if (gridEntities.DataSource != null && entities != null)
{
statusEntitiesShowing.Text = $"Showing {gridEntities.Rows.Count} of {entities.Count} entities.";
Expand Down
23 changes: 23 additions & 0 deletions LCG.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions LateboundConstantGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AttributeMetadataProxy.cs" />
<Compile Include="CSharpUtils.cs" />
<Compile Include="EntityMetadataProxy.cs" />
<Compile Include="LCGDescription.cs" />
<Compile Include="LCG.cs">
Expand Down

0 comments on commit a28aaa6

Please sign in to comment.