Skip to content

Commit d5ce454

Browse files
author
zzzprojects
committed
ZZZ Projects
ZZZ Projects
1 parent 2866f5c commit d5ce454

File tree

959 files changed

+40685
-113
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

959 files changed

+40685
-113
lines changed

Z.ExtensionMethods.sln

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lab", "lab", "{17901011-648
6969
EndProject
7070
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Z.ExtensionMethods.Lab", "lab\Z.ExtensionMethods.Lab\Z.ExtensionMethods.Lab.csproj", "{7C99DCC9-7623-402E-9C6A-80892C30CCA6}"
7171
EndProject
72+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src (VB.NET)", "src (VB.NET)", "{C69867BF-5530-439F-9CEE-A604BDA0942E}"
73+
EndProject
74+
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Z.ExtensionMethods.VB", "src (VB.NET)\Z.ExtensionMethods.VB\Z.ExtensionMethods.VB.vbproj", "{E915F78F-041F-4FE7-A84B-E5406481C92A}"
75+
EndProject
76+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Z.ExtensionMethods.Tool.FixGeneratedVbNet", "tool\Z.ExtensionMethods.Tool.FixGeneratedVbNet\Z.ExtensionMethods.Tool.FixGeneratedVbNet.csproj", "{AD7BC2C1-FBEC-4170-8A85-EBA206DD1781}"
77+
EndProject
7278
Global
7379
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7480
Debug|Any CPU = Debug|Any CPU
@@ -195,6 +201,14 @@ Global
195201
{7C99DCC9-7623-402E-9C6A-80892C30CCA6}.Debug|Any CPU.Build.0 = Debug|Any CPU
196202
{7C99DCC9-7623-402E-9C6A-80892C30CCA6}.Release|Any CPU.ActiveCfg = Release|Any CPU
197203
{7C99DCC9-7623-402E-9C6A-80892C30CCA6}.Release|Any CPU.Build.0 = Release|Any CPU
204+
{E915F78F-041F-4FE7-A84B-E5406481C92A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
205+
{E915F78F-041F-4FE7-A84B-E5406481C92A}.Debug|Any CPU.Build.0 = Debug|Any CPU
206+
{E915F78F-041F-4FE7-A84B-E5406481C92A}.Release|Any CPU.ActiveCfg = Release|Any CPU
207+
{E915F78F-041F-4FE7-A84B-E5406481C92A}.Release|Any CPU.Build.0 = Release|Any CPU
208+
{AD7BC2C1-FBEC-4170-8A85-EBA206DD1781}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
209+
{AD7BC2C1-FBEC-4170-8A85-EBA206DD1781}.Debug|Any CPU.Build.0 = Debug|Any CPU
210+
{AD7BC2C1-FBEC-4170-8A85-EBA206DD1781}.Release|Any CPU.ActiveCfg = Release|Any CPU
211+
{AD7BC2C1-FBEC-4170-8A85-EBA206DD1781}.Release|Any CPU.Build.0 = Release|Any CPU
198212
EndGlobalSection
199213
GlobalSection(SolutionProperties) = preSolution
200214
HideSolutionNode = FALSE
@@ -214,5 +228,7 @@ Global
214228
{9B61D149-575C-411A-A063-3D122B88CC63} = {9C296DC8-C7D0-4D87-8F49-BC811C7C7C0C}
215229
{DFC5ABB7-9F4C-4814-8703-46F3DA784990} = {4092578E-F121-4AC4-83D0-BF802CBAE5EE}
216230
{7C99DCC9-7623-402E-9C6A-80892C30CCA6} = {17901011-6488-4283-83F2-D40E8D891A91}
231+
{E915F78F-041F-4FE7-A84B-E5406481C92A} = {C69867BF-5530-439F-9CEE-A604BDA0942E}
232+
{AD7BC2C1-FBEC-4170-8A85-EBA206DD1781} = {4092578E-F121-4AC4-83D0-BF802CBAE5EE}
217233
EndGlobalSection
218234
EndGlobal

lab/Z.ExtensionMethods.Lab/Form1.cs

Lines changed: 201 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,79 +6,217 @@
66

77
using System;
88
using System.Collections.Generic;
9-
using System.IO;
109
using System.Linq;
11-
using System.Reflection;
10+
using System.Text;
1211
using System.Windows.Forms;
13-
using System.Xml.Linq;
14-
using System.Xml.Schema;
15-
using Z.Reflection.Documentation.Test;
1612

1713
namespace Z.ExtensionMethods.Lab
1814
{
15+
public static class LabExtension
16+
{
17+
public static IEnumerable<T> MergeInnerEnumerable<T>(this IEnumerable<IEnumerable<T>> @this)
18+
{
19+
List<IEnumerable<T>> listItem = @this.ToList();
20+
21+
var list = new List<T>();
22+
23+
foreach (var item in listItem)
24+
{
25+
list.AddRange(item);
26+
}
27+
28+
return list;
29+
}
30+
31+
public static IEnumerable<T> MergeDistinctInnerEnumerable<T>(this IEnumerable<IEnumerable<T>> @this)
32+
{
33+
List<IEnumerable<T>> listItem = @this.ToList();
34+
35+
var list = new List<T>();
36+
37+
foreach (var item in listItem)
38+
{
39+
list = list.Union(item).ToList();
40+
}
41+
42+
return list;
43+
}
44+
45+
public static string StripHtml(this string @this)
46+
{
47+
var path = new StringBuilder(@this);
48+
var sb = new StringBuilder();
49+
50+
int pos = 0;
51+
52+
while (pos < path.Length)
53+
{
54+
char ch = path[pos];
55+
pos++;
56+
57+
if (ch == '<')
58+
{
59+
// Loop until we close the tag
60+
while (pos < path.Length)
61+
{
62+
ch = path[pos];
63+
pos++;
64+
65+
if (ch == '>')
66+
{
67+
break;
68+
}
69+
70+
if (ch == '\'')
71+
{
72+
// Skip attribute starting with single quote
73+
pos = GetIndexAfterNextSingleQuote(path, pos);
74+
}
75+
else if (ch == '"')
76+
{
77+
// Skip attribute starting with double quote
78+
pos = GetIndexAfterNextDoubleQuote(path, pos);
79+
}
80+
}
81+
}
82+
else
83+
{
84+
sb.Append(ch);
85+
}
86+
}
87+
88+
return sb.ToString();
89+
}
90+
91+
public static string Substring(StringBuilder @this, int startIndex)
92+
{
93+
return @this.ToString(startIndex, @this.Length - startIndex);
94+
}
95+
96+
public static string Substring(StringBuilder @this, int startIndex, int length)
97+
{
98+
return @this.ToString(startIndex, length);
99+
}
100+
101+
102+
public static int StripHtml_EndTag(this StringBuilder path, int pos)
103+
{
104+
return pos;
105+
}
106+
public static int GetIndexAfterNextSingleQuote(StringBuilder path, int startIndex)
107+
{
108+
while (startIndex < path.Length)
109+
{
110+
char ch = path[startIndex];
111+
startIndex++;
112+
113+
char nextChar;
114+
if (ch == '\\' && startIndex < path.Length && ((nextChar = path[startIndex]) == '\\' || nextChar == '\''))
115+
{
116+
startIndex++; // Treat as escape character for \\ or \"
117+
}
118+
else if (ch == '\'')
119+
{
120+
return startIndex;
121+
}
122+
}
123+
124+
return startIndex;
125+
}
126+
127+
public static int GetIndexAfterNextDoubleQuote(StringBuilder path, int startIndex)
128+
{
129+
while (startIndex < path.Length)
130+
{
131+
char ch = path[startIndex];
132+
startIndex++;
133+
134+
char nextChar;
135+
if (ch == '\\' && startIndex < path.Length && ((nextChar = path[startIndex]) == '\\' || nextChar == '"'))
136+
{
137+
startIndex++; // Treat as escape character for \\ or \"
138+
}
139+
else if (ch == '"')
140+
{
141+
return startIndex;
142+
}
143+
}
144+
145+
return startIndex;
146+
}
147+
}
148+
19149
public partial class Form1 : Form
20150
{
21151
public Form1()
22152
{
23153
InitializeComponent();
24-
25-
//var entityMembers = typeof (Entity).GetMembers();
26-
// var list1 = entityMembers.Select(x => x.GetSignature()).ToList();
27-
// var list2 = entityMembers.Select(x => x.GetDeclaration()).ToList();
28-
// var list3 = entityMembers.Select(x => x.GetMemberName()).ToList();
29-
30-
// object a = null;
31-
// string b = "";
32-
// MethodBase mi = MethodBase.GetCurrentMethod();
33-
// MethodInfo serialize2 = typeof (MethodInfo).GetMethod("FormatNameAndSig", BindingFlags.NonPublic | BindingFlags.Instance, null, new[] {typeof (bool)}, null);
34-
// //MethodInfo serialize = typeof (MethodInfo).GetMethod("FormatNameAndSig", BindingFlags.NonPublic | BindingFlags.Instance);
35-
36-
// MethodInfo[] methods = typeof (Entity).GetMethods();
37-
// MethodInfo abc = methods[0];
38-
39-
// var serialize = serialize2.Invoke(abc, new[] {(object) true});
40-
// MethodInfo test1 = abc.GetRuntimeBaseDefinition();
41-
// string assemblyDirectory = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1";
42-
43-
// FileInfo dll = assemblyDirectory.ToDirectoryInfo().GetFiles("System.Core.dll")[0];
44-
// FileInfo xml = assemblyDirectory.ToDirectoryInfo().GetFiles("System.Core.xml")[0];
45-
46-
47-
// Assembly assembly = Assembly.UnsafeLoadFrom(dll.FullName);
48-
49-
// XDocument xDoc = XDocument.Load(xml.FullName);
50-
// IEnumerable<XElement> members = xDoc.Element("doc").Element("members").Elements("member");
51-
52-
// Dictionary<string, string> dict = members.Select(x => x.Attribute("name").Value).ToDictionary(x => x);
53-
54-
55-
// Type[] types = assembly.GetTypes();
56-
// List<string> memberNames = types.SelectMany(x => x.GetMembers()).Select(x => x.GetMemberName()).OrderBy(x => x).ToList();
57-
// List<string> typeNames = types.Select(x => x.GetMemberName()).ToList();
58-
59-
// typeNames.ForEach(x =>
60-
// {
61-
// if (dict.ContainsKey(x))
62-
// {
63-
// dict.Remove(x);
64-
// }
65-
// });
66-
// memberNames.ForEach(x =>
67-
// {
68-
// if (dict.ContainsKey(x))
69-
// {
70-
// dict.Remove(x);
71-
// }
72-
// });
73-
74-
// var missingTypes = dict.Where(x => x.Value.StartsWith("T:")).ToList();
75-
// var missingProperty = dict.Where(x => x.Value.StartsWith("P:") && !x.Value.Contains("#")).ToList();
76-
// var missingField = dict.Where(x => x.Value.StartsWith("F:")).ToList();
77-
// var missingEvent = dict.Where(x => x.Value.StartsWith("E:")).ToList();
78-
// var missingMethod = dict.Where(x => x.Value.StartsWith("M:")).ToList();
79-
// List<string> toVerify = memberNames.Where(x => x.StartsWith("P:System.Runtime.CompilerServices")).OrderBy(x => x).ToList();
80-
81-
154+
155+
StringBuilder sb = new StringBuilder("0123456789");
156+
var b4 = "abc".Substring(1, 4);
157+
char ch = '\'';
158+
char ch2 = '"';
159+
string tag = "a<b class='to>to'>c</b>d";
160+
string tag2 = tag.StripHtml();
161+
var a = new[] {"a", "b", "c"};
162+
var b = new[] {"c", "d"};
163+
164+
var c = new List<String[]> {a, b};
165+
IEnumerable<string> d = c.MergeInnerEnumerable();
166+
}
167+
168+
public void Misc()
169+
{
170+
// object a = null;
171+
// string b = "";
172+
// MethodBase mi = MethodBase.GetCurrentMethod();
173+
// MethodInfo serialize2 = typeof (MethodInfo).GetMethod("FormatNameAndSig", BindingFlags.NonPublic | BindingFlags.Instance, null, new[] {typeof (bool)}, null);
174+
// //MethodInfo serialize = typeof (MethodInfo).GetMethod("FormatNameAndSig", BindingFlags.NonPublic | BindingFlags.Instance);
175+
176+
// MethodInfo[] methods = typeof (Entity).GetMethods();
177+
// MethodInfo abc = methods[0];
178+
179+
// var serialize = serialize2.Invoke(abc, new[] {(object) true});
180+
// MethodInfo test1 = abc.GetRuntimeBaseDefinition();
181+
// string assemblyDirectory = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1";
182+
183+
// FileInfo dll = assemblyDirectory.ToDirectoryInfo().GetFiles("System.Core.dll")[0];
184+
// FileInfo xml = assemblyDirectory.ToDirectoryInfo().GetFiles("System.Core.xml")[0];
185+
186+
187+
// Assembly assembly = Assembly.UnsafeLoadFrom(dll.FullName);
188+
189+
// XDocument xDoc = XDocument.Load(xml.FullName);
190+
// IEnumerable<XElement> members = xDoc.Element("doc").Element("members").Elements("member");
191+
192+
// Dictionary<string, string> dict = members.Select(x => x.Attribute("name").Value).ToDictionary(x => x);
193+
194+
195+
// Type[] types = assembly.GetTypes();
196+
// List<string> memberNames = types.SelectMany(x => x.GetMembers()).Select(x => x.GetMemberName()).OrderBy(x => x).ToList();
197+
// List<string> typeNames = types.Select(x => x.GetMemberName()).ToList();
198+
199+
// typeNames.ForEach(x =>
200+
// {
201+
// if (dict.ContainsKey(x))
202+
// {
203+
// dict.Remove(x);
204+
// }
205+
// });
206+
// memberNames.ForEach(x =>
207+
// {
208+
// if (dict.ContainsKey(x))
209+
// {
210+
// dict.Remove(x);
211+
// }
212+
// });
213+
214+
// var missingTypes = dict.Where(x => x.Value.StartsWith("T:")).ToList();
215+
// var missingProperty = dict.Where(x => x.Value.StartsWith("P:") && !x.Value.Contains("#")).ToList();
216+
// var missingField = dict.Where(x => x.Value.StartsWith("F:")).ToList();
217+
// var missingEvent = dict.Where(x => x.Value.StartsWith("E:")).ToList();
218+
// var missingMethod = dict.Where(x => x.Value.StartsWith("M:")).ToList();
219+
// List<string> toVerify = memberNames.Where(x => x.StartsWith("P:System.Runtime.CompilerServices")).OrderBy(x => x).ToList();
82220
}
83221
}
84222
}

lab/Z.ExtensionMethods.Lab/Z.ExtensionMethods.Lab.csproj

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,9 @@
8383
</Compile>
8484
</ItemGroup>
8585
<ItemGroup>
86-
<ProjectReference Include="..\..\src\Z.Core\Z.Core.csproj">
87-
<Project>{02f009f8-720b-4cbd-98ff-f2c33f4441d5}</Project>
88-
<Name>Z.Core</Name>
89-
</ProjectReference>
90-
<ProjectReference Include="..\..\src\Z.IO\Z.IO.csproj">
91-
<Project>{981d1a7a-dc30-4f93-8247-f2ad6d09e4ec}</Project>
92-
<Name>Z.IO</Name>
93-
</ProjectReference>
94-
<ProjectReference Include="..\..\src\Z.Reflection\Z.Reflection.csproj">
95-
<Project>{c3eda334-3d94-4960-93b9-3026adc4cc12}</Project>
96-
<Name>Z.Reflection</Name>
86+
<ProjectReference Include="..\..\src %28VB.NET%29\Z.ExtensionMethods.VB\Z.ExtensionMethods.VB.vbproj">
87+
<Project>{e915f78f-041f-4fe7-a84b-e5406481c92a}</Project>
88+
<Name>Z.ExtensionMethods.VB</Name>
9789
</ProjectReference>
9890
</ItemGroup>
9991
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

0 commit comments

Comments
 (0)