Skip to content

Commit c8b80e6

Browse files
committed
Merge branch 'IconPack' of https://github.com/ButchersBoy/MaterialDesignInXamlToolkit into IconPack
2 parents 443391a + 45cf316 commit c8b80e6

File tree

4 files changed

+59
-5
lines changed

4 files changed

+59
-5
lines changed

mdresgen/IconThing.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public void Run()
2424

2525
// Console.WriteLine(nameDataPairs.Count);
2626

27-
UpdateEnum("IconType.template.cs");
27+
//UpdateEnum("PackIconType.template.cs");
28+
UpdateDataFactory("PackIconDataFactory.template.cs");
2829
}
2930

3031
private static string GetSourceData()
@@ -50,6 +51,39 @@ private static IEnumerable<Tuple<string, string>> GetNameDataPairs(string source
5051
t["data"].ToString()));
5152
}
5253

54+
private void UpdateDataFactory(string sourceFile)
55+
{
56+
var sourceText = SourceText.From(new FileStream(sourceFile, FileMode.Open));
57+
var syntaxTree = CSharpSyntaxTree.ParseText(sourceText);
58+
59+
var initializerExpressionSyntax =
60+
syntaxTree.GetRoot()
61+
.DescendantNodes()
62+
.OfType<InitializerExpressionSyntax>()
63+
.Single(s => s.Kind() == SyntaxKind.CollectionInitializerExpression);
64+
65+
66+
var modifiedInitializerExpressionSyntax = initializerExpressionSyntax.RemoveNodes(initializerExpressionSyntax.Expressions, SyntaxRemoveOptions.KeepNoTrivia);
67+
var newThings = "{ PackIconType.AutoGenerated, \"data in here\" }," + Environment.NewLine +
68+
"{ PackIconType.DoNotAmend, \"data in here\" }" + Environment.NewLine;
69+
70+
/*
71+
SeparatedSyntaxList<ExpressionSyntax>.
72+
SyntaxFactory.InitializerExpression(SyntaxKind.ComplexElementInitializerExpression, )
73+
SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,)
74+
*/
75+
/*
76+
var newTree =
77+
CSharpSyntaxTree.ParseText(newThings).GetRoot().ChildNodes().First().T;
78+
79+
modifiedInitializerExpressionSyntax.ReplaceSyntax()
80+
*/
81+
//SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,)
82+
83+
//modifiedInitializerExpressionSyntax.AddExpressions()
84+
85+
Console.WriteLine(modifiedInitializerExpressionSyntax.ToString());
86+
}
5387

5488
private void UpdateEnum(string sourceFile)
5589
{
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Collections.Generic;
2+
3+
namespace MaterialDesignThemes.Wpf
4+
{
5+
/// ******************************************
6+
/// This code is auto generated. Do not amend.
7+
/// ******************************************
8+
9+
internal static class PackIconDataFactory
10+
{
11+
internal static IReadOnlyDictionary<PackIconType, string> Create() => new Dictionary<PackIconType, string>
12+
{
13+
{ PackIconType.AutoGenerated, "data in here" },
14+
{ PackIconType.DoNotAmend, "data in here" }
15+
};
16+
}
17+
}

mdresgen/IconType.template.cs renamed to mdresgen/PackIconType.template.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ namespace MaterialDesignThemes.Wpf
55
/// ******************************************
66

77
/// <summary>
8-
/// List of available icons for use with <see cref="Icon"/>.
8+
/// List of available icons for use with <see cref="PackIcon" />.
99
/// </summary>
1010
/// <remarks>
1111
/// All icons sourced from Material Design Icons Font - <see cref="https://materialdesignicons.com/"/> - in accordance of
1212
/// <see cref="https://github.com/Templarian/MaterialDesign/blob/master/license.txt"/>.
1313
/// </remarks>
14-
public enum IconType
14+
public enum PackIconType
1515
{
1616
AutoGenerated,
1717
DoNotAmend
1818
}
1919
}
20+

mdresgen/mdresgen.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@
110110
<Reference Include="System.Xml" />
111111
</ItemGroup>
112112
<ItemGroup>
113+
<None Include="PackIconDataFactory.template.cs">
114+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
115+
</None>
113116
<Compile Include="IconThing.cs" />
114-
<None Include="IconType.template.cs">
117+
<None Include="PackIconType.template.cs">
115118
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
116119
</None>
117120
<Compile Include="Program.cs" />
@@ -129,7 +132,6 @@
129132
<ItemGroup>
130133
<None Include="RecommendedAccentTemplate.xaml">
131134
<Generator>MSBuild:Compile</Generator>
132-
<SubType>Designer</SubType>
133135
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
134136
</None>
135137
<None Include="RecommendedPrimaryTemplate.xaml">

0 commit comments

Comments
 (0)