Skip to content

Commit 6a32e74

Browse files
author
Michael Ganss
committed
initial commit
0 parents  commit 6a32e74

File tree

119 files changed

+88949
-0
lines changed

Some content is hidden

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

119 files changed

+88949
-0
lines changed

.gitignore

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.sln.docstates
8+
9+
# Build results
10+
11+
[Dd]ebug/
12+
[Rr]elease/
13+
x64/
14+
build/
15+
[Bb]in/
16+
[Oo]bj/
17+
18+
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
19+
!packages/*/build/
20+
21+
# MSTest test Results
22+
[Tt]est[Rr]esult*/
23+
[Bb]uild[Ll]og.*
24+
25+
*_i.c
26+
*_p.c
27+
*.ilk
28+
*.meta
29+
*.obj
30+
*.pch
31+
*.pdb
32+
*.pgc
33+
*.pgd
34+
*.rsp
35+
*.sbr
36+
*.tlb
37+
*.tli
38+
*.tlh
39+
*.tmp
40+
*.tmp_proj
41+
*.log
42+
*.vspscc
43+
*.vssscc
44+
.builds
45+
*.pidb
46+
*.log
47+
*.scc
48+
49+
# Visual C++ cache files
50+
ipch/
51+
*.aps
52+
*.ncb
53+
*.opensdf
54+
*.sdf
55+
*.cachefile
56+
57+
# Visual Studio profiler
58+
*.psess
59+
*.vsp
60+
*.vspx
61+
62+
# Guidance Automation Toolkit
63+
*.gpState
64+
65+
# ReSharper is a .NET coding add-in
66+
_ReSharper*/
67+
*.[Rr]e[Ss]harper
68+
69+
# TeamCity is a build add-in
70+
_TeamCity*
71+
72+
# DotCover is a Code Coverage Tool
73+
*.dotCover
74+
75+
# NCrunch
76+
*.ncrunch*
77+
.*crunch*.local.xml
78+
79+
# Installshield output folder
80+
[Ee]xpress/
81+
82+
# DocProject is a documentation generator add-in
83+
DocProject/buildhelp/
84+
DocProject/Help/*.HxT
85+
DocProject/Help/*.HxC
86+
DocProject/Help/*.hhc
87+
DocProject/Help/*.hhk
88+
DocProject/Help/*.hhp
89+
DocProject/Help/Html2
90+
DocProject/Help/html
91+
92+
# Click-Once directory
93+
publish/
94+
95+
# Publish Web Output
96+
*.Publish.xml
97+
*.pubxml
98+
99+
# NuGet Packages Directory
100+
packages/
101+
102+
# Windows Azure Build Output
103+
csx
104+
*.build.csdef
105+
106+
# Windows Store app package directory
107+
AppPackages/
108+
109+
# Others
110+
sql/
111+
*.Cache
112+
ClientBin/
113+
[Ss]tyle[Cc]op.*
114+
~$*
115+
*~
116+
*.dbmdl
117+
*.[Pp]ublish.xml
118+
*.pfx
119+
*.publishsettings
120+
121+
# RIA/Silverlight projects
122+
Generated_Code/
123+
124+
# Backup & report files from converting an old project file to a newer
125+
# Visual Studio version. Backup files are not needed, because we have git ;-)
126+
_UpgradeReport_Files/
127+
Backup*/
128+
UpgradeLog*.XML
129+
UpgradeLog*.htm
130+
131+
# SQL Server files
132+
App_Data/*.mdf
133+
App_Data/*.ldf
134+
135+
# =========================
136+
# Windows detritus
137+
# =========================
138+
139+
# Windows image file caches
140+
Thumbs.db
141+
ehthumbs.db
142+
143+
# Folder config file
144+
Desktop.ini
145+
146+
# Recycle Bin used on file shares
147+
$RECYCLE.BIN/
148+
149+
# Mac crap
150+
.DS_Store
151+
152+
*.nupkg

XmlSampleGenerator/EULA.rtf

Lines changed: 140 additions & 0 deletions
Large diffs are not rendered by default.

XmlSampleGenerator/Facets.cs

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
namespace Microsoft.Xml.XMLGen {
2+
using System;
3+
using System.Collections;
4+
using System.IO;
5+
using System.Text;
6+
using System.Xml.Schema;
7+
using System.Reflection;
8+
9+
internal enum XmlSchemaWhiteSpace {
10+
Preserve,
11+
Replace,
12+
Collapse,
13+
}
14+
15+
internal enum RestrictionFlags {
16+
Length = 0x0001,
17+
MinLength = 0x0002,
18+
MaxLength = 0x0004,
19+
Pattern = 0x0008,
20+
Enumeration = 0x0010,
21+
WhiteSpace = 0x0020,
22+
MaxInclusive = 0x0040,
23+
MaxExclusive = 0x0080,
24+
MinInclusive = 0x0100,
25+
MinExclusive = 0x0200,
26+
TotalDigits = 0x0400,
27+
FractionDigits = 0x0800,
28+
}
29+
30+
internal class CompiledFacets {
31+
32+
static FieldInfo lengthInfo;
33+
static FieldInfo minLengthInfo;
34+
static FieldInfo maxLengthInfo;
35+
static FieldInfo patternsInfo;
36+
static FieldInfo enumerationInfo;
37+
static FieldInfo whitespaceInfo;
38+
39+
static FieldInfo maxInclusiveInfo;
40+
static FieldInfo maxExclusiveInfo;
41+
static FieldInfo minInclusiveInfo;
42+
static FieldInfo minExclusiveInfo;
43+
static FieldInfo totalDigitsInfo;
44+
static FieldInfo fractionDigitsInfo;
45+
46+
static FieldInfo restrictionFlagsInfo;
47+
static FieldInfo restrictionFixedFlagsInfo;
48+
49+
public static Type XsdSimpleValueType;
50+
public static Type XmlSchemaDatatypeType;
51+
52+
object compiledRestriction;
53+
54+
static CompiledFacets() {
55+
Assembly systemXmlAsm = typeof(XmlSchema).Assembly;
56+
57+
Type RestrictionFacetsType = systemXmlAsm.GetType("System.Xml.Schema.RestrictionFacets", true);
58+
XsdSimpleValueType = systemXmlAsm.GetType("System.Xml.Schema.XsdSimpleValue", true);
59+
XmlSchemaDatatypeType = typeof(XmlSchemaDatatype);
60+
61+
lengthInfo = RestrictionFacetsType.GetField("Length", BindingFlags.Instance | BindingFlags.NonPublic);
62+
minLengthInfo = RestrictionFacetsType.GetField("MinLength", BindingFlags.Instance | BindingFlags.NonPublic);
63+
maxLengthInfo = RestrictionFacetsType.GetField("MaxLength", BindingFlags.Instance | BindingFlags.NonPublic);
64+
patternsInfo = RestrictionFacetsType.GetField("Patterns", BindingFlags.Instance | BindingFlags.NonPublic);
65+
enumerationInfo = RestrictionFacetsType.GetField("Enumeration", BindingFlags.Instance | BindingFlags.NonPublic);
66+
whitespaceInfo = RestrictionFacetsType.GetField("WhiteSpace", BindingFlags.Instance | BindingFlags.NonPublic);
67+
68+
maxInclusiveInfo = RestrictionFacetsType.GetField("MaxInclusive", BindingFlags.Instance | BindingFlags.NonPublic);
69+
maxExclusiveInfo = RestrictionFacetsType.GetField("MaxExclusive", BindingFlags.Instance | BindingFlags.NonPublic);
70+
minInclusiveInfo = RestrictionFacetsType.GetField("MinInclusive", BindingFlags.Instance | BindingFlags.NonPublic);
71+
minExclusiveInfo = RestrictionFacetsType.GetField("MinExclusive", BindingFlags.Instance | BindingFlags.NonPublic);
72+
73+
totalDigitsInfo = RestrictionFacetsType.GetField("TotalDigits", BindingFlags.Instance | BindingFlags.NonPublic);
74+
fractionDigitsInfo = RestrictionFacetsType.GetField("FractionDigits", BindingFlags.Instance | BindingFlags.NonPublic);
75+
76+
restrictionFlagsInfo = RestrictionFacetsType.GetField("Flags", BindingFlags.Instance | BindingFlags.NonPublic);
77+
restrictionFixedFlagsInfo = RestrictionFacetsType.GetField("FixedFlags", BindingFlags.Instance | BindingFlags.NonPublic);
78+
}
79+
80+
public CompiledFacets(object restriction) {
81+
this.compiledRestriction = restriction;
82+
}
83+
84+
public int Length {
85+
get {
86+
if (compiledRestriction == null) {
87+
return 0;
88+
}
89+
return (int)lengthInfo.GetValue(compiledRestriction);
90+
}
91+
}
92+
93+
public int MinLength {
94+
get {
95+
if (compiledRestriction == null) {
96+
return 0;
97+
}
98+
return (int)minLengthInfo.GetValue(compiledRestriction);
99+
}
100+
}
101+
102+
public int MaxLength {
103+
get {
104+
if (compiledRestriction == null) {
105+
return 0;
106+
}
107+
return (int)maxLengthInfo.GetValue(compiledRestriction);
108+
}
109+
}
110+
111+
public ArrayList Patterns {
112+
get {
113+
if (compiledRestriction == null) {
114+
return null;
115+
}
116+
return (ArrayList)patternsInfo.GetValue(compiledRestriction);
117+
}
118+
}
119+
120+
public ArrayList Enumeration {
121+
get {
122+
if (compiledRestriction == null) {
123+
return null;
124+
}
125+
return (ArrayList)enumerationInfo.GetValue(compiledRestriction);
126+
}
127+
}
128+
public XmlSchemaWhiteSpace WhiteSpace {
129+
get {
130+
if (compiledRestriction == null) {
131+
return XmlSchemaWhiteSpace.Preserve;
132+
}
133+
return (XmlSchemaWhiteSpace)whitespaceInfo.GetValue(compiledRestriction);
134+
}
135+
}
136+
137+
public object MaxInclusive {
138+
get {
139+
if (compiledRestriction == null) {
140+
return null;
141+
}
142+
return maxInclusiveInfo.GetValue(compiledRestriction);
143+
}
144+
}
145+
public object MaxExclusive {
146+
get {
147+
if (compiledRestriction == null) {
148+
return null;
149+
}
150+
return maxExclusiveInfo.GetValue(compiledRestriction);
151+
}
152+
}
153+
public object MinInclusive {
154+
get {
155+
if (compiledRestriction == null) {
156+
return null;
157+
}
158+
return minInclusiveInfo.GetValue(compiledRestriction);
159+
}
160+
}
161+
public object MinExclusive {
162+
get {
163+
if (compiledRestriction == null) {
164+
return null;
165+
}
166+
return minExclusiveInfo.GetValue(compiledRestriction);
167+
}
168+
}
169+
170+
public int TotalDigits {
171+
get {
172+
if (compiledRestriction == null) {
173+
return 0;
174+
}
175+
return (int)totalDigitsInfo.GetValue(compiledRestriction);
176+
}
177+
}
178+
public int FractionDigits {
179+
get {
180+
if (compiledRestriction == null) {
181+
return 0;
182+
}
183+
return (int)fractionDigitsInfo.GetValue(compiledRestriction);
184+
}
185+
}
186+
public RestrictionFlags Flags {
187+
get {
188+
if (compiledRestriction == null) {
189+
return 0;
190+
}
191+
return (RestrictionFlags)restrictionFlagsInfo.GetValue(compiledRestriction);
192+
}
193+
}
194+
public RestrictionFlags FixedFlags {
195+
get {
196+
if (compiledRestriction == null) {
197+
return 0;
198+
}
199+
return (RestrictionFlags)restrictionFixedFlagsInfo.GetValue(compiledRestriction);
200+
}
201+
}
202+
}
203+
}

0 commit comments

Comments
 (0)