1
1
@ rem Creating RequestFactoryWithSpecified file which handles the elements having minoccurs=0 in XSD
2
2
@ rem It generates specified property for such element and sets them true if the required condition is met
3
3
@ ECHO OFF
4
- SET DEVKIT = C:\DevKit\bin
4
+ CALL " %~dp0 \validateCygwinBinaries.cmd"
5
+ IF " 1" == " %ERRORLEVEL% " (
6
+ @ ECHO Invalid or incomplete Cygwin installation. Install cygwin and its components viz.
7
+ @ ECHO grep sed perl cut touch wget sort
8
+ EXIT /b 1
9
+ )
10
+ SET CYGWIN_EXE = %CYGWIN_HOME% \bin
5
11
SET OUTDIR = %Temp%
6
12
SET SRCDIR = Authorize.NET\Api\Contracts\V1
7
13
SET OUTFILE = %SRCDIR% \RequestFactoryWithSpecified.generated.org
8
14
SET INFILE = %SRCDIR% \AnetApiSchema.generated.cs
9
15
SET BACKUPFILE = %OUTDIR% \RequestFactoryWithSpecified_Backup.generated.org
10
16
SET SPECIFIEDFILE = %OUTDIR% \splst.txt
11
17
12
- IF NOT EXIST " %DEVKIT % " (
13
- @ ECHO " %DEVKIT % " DOES NOT EXIST
18
+ IF NOT EXIST " %CYGWIN_EXE % " (
19
+ @ ECHO " %CYGWIN_EXE % " DOES NOT EXIST
14
20
EXIT /B 1
15
21
)
16
22
IF NOT EXIST " %SRCDIR% " (
@@ -19,7 +25,7 @@ IF NOT EXIST "%SRCDIR%" (
19
25
)
20
26
21
27
IF EXIST " %OUTFILE% " (
22
- " %DEVKIT % \rm.exe" %OUTFILE%
28
+ " %CYGWIN_EXE % \rm.exe" %OUTFILE%
23
29
)
24
30
25
31
@ ECHO ### Generating request factory specified
@@ -46,100 +52,100 @@ IF EXIST "%OUTFILE%" (
46
52
@ ECHO public static class RequestFactoryWithSpecified >> %OUTFILE%
47
53
@ ECHO {>> %OUTFILE%
48
54
49
- " %DEVKIT % \grep.exe" -i " class\|specified\|typeof\|type\|public" %INFILE% | " %DEVKIT % \grep.exe" -i -v " string\|event" >> %OUTFILE%
55
+ " %CYGWIN_EXE % \grep.exe" -i " class\|specified\|typeof\|type\|public" %INFILE% | " %CYGWIN_EXE % \grep.exe" -i -v " string\|event" >> %OUTFILE%
50
56
51
57
rem creating a back up file
52
- " %DEVKIT % \cp.exe" -f %OUTFILE% %BACKUPFILE%
58
+ " %CYGWIN_EXE % \cp.exe" -f %OUTFILE% %BACKUPFILE%
53
59
54
60
@ rem replacing public partial class with public static void
55
- " %DEVKIT % \perl.exe" -p -i -e 's/public partial class/ }\n }\n public static void/g' %OUTFILE%
61
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/public partial class/ }\n }\n public static void/g' %OUTFILE%
56
62
57
63
@ ECHO ### Deleting unwanted lines from file - may take sometime
58
64
@ rem remove everything after colon public partial class merchantAuthenticationType : object, System.ComponentModel.INotifyPropertyChanged {
59
- " %DEVKIT % \perl.exe" -p -i -e 's/:.*/\n {\n if(null != argument) \n {\n/g if /: object/' %OUTFILE%
65
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/:.*/\n {\n if(null != argument) \n {\n/g if /: object/' %OUTFILE%
60
66
61
67
@ rem remove everything after colon public partial class authenticateTestRequest : ANetApiRequest
62
- " %DEVKIT % \perl.exe" -p -i -e 's/:.*/\n {\n if(null != argument) \n {\n/g if /: ANetApi/' %OUTFILE%
68
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/:.*/\n {\n if(null != argument) \n {\n/g if /: ANetApi/' %OUTFILE%
63
69
64
70
@ rem remove "public enum bankAccountTypeEnum"
65
- " %DEVKIT % \perl.exe" -p -i -e 's/public enum.*//g' %OUTFILE%
71
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/public enum.*//g' %OUTFILE%
66
72
67
73
@ rem remove ["System.Xml.Serialization.XmlTypeAttribute(Namespace="AnetApi/xml/v1/schema/AnetApiSchema.xsd")]"
68
- " %DEVKIT % \perl.exe" -p -i -e 's/^ \[System.Xml.Serialization.XmlTypeAttribute.*$//g' %OUTFILE%
74
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ \[System.Xml.Serialization.XmlTypeAttribute.*$//g' %OUTFILE%
69
75
70
76
@ rem remove "[System.Xml.Serialization.XmlIncludeAttribute(typeof(creditCardType))]"
71
- " %DEVKIT % \perl.exe" -p -i -e 's/^ \[System.Xml.Serialization.XmlIncludeAttribute.*$//g' %OUTFILE%
77
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ \[System.Xml.Serialization.XmlIncludeAttribute.*$//g' %OUTFILE%
72
78
73
79
@ rem remove before 'typeof' word "[System.Xml.Serialization.XmlElementAttribute("bankAccount", typeof(bankAccountType))]"
74
- " %DEVKIT % \perl.exe" -p -i -e 's/^ \[System.Xml.Serialization.XmlElementAttribute.*typeof\(/ /g' %OUTFILE%
80
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ \[System.Xml.Serialization.XmlElementAttribute.*typeof\(/ /g' %OUTFILE%
75
81
76
82
@ rem remove replacing the last three characters ))] in above expression with "(argument)"
77
- " %DEVKIT % \perl.exe" -p -i -e 's/\)\)\]/ABCargumentXXX;/g' %OUTFILE%
83
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/\)\)\]/ABCargumentXXX;/g' %OUTFILE%
78
84
79
85
@ rem remove "[System.Xml.Serialization.XmlElementAttribute(DataType="date")]"
80
- " %DEVKIT % \perl.exe" -p -i -e 's/^ \[System.Xml.Serialization.XmlElementAttribute.*$//g' %OUTFILE%
86
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ \[System.Xml.Serialization.XmlElementAttribute.*$//g' %OUTFILE%
81
87
82
88
@ rem remove "[System.Xml.Serialization.XmlAttributeAttribute(DataType"
83
- " %DEVKIT % \perl.exe" -p -i -e 's/^ \[System.Xml.Serialization.XmlAttributeAttribute.*$//g' %OUTFILE%
89
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ \[System.Xml.Serialization.XmlAttributeAttribute.*$//g' %OUTFILE%
84
90
85
91
@ rem remove the line containing enum at the end of the word accountTypeEnum
86
- " %DEVKIT % \perl.exe" -p -i -e 's/([A-Za-z0-9]*.Enum.*)$//g if !/public static/' %OUTFILE%
92
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/([A-Za-z0-9]*.Enum.*)$//g if !/public static/' %OUTFILE%
87
93
88
94
@ rem remove the line containing enum at the end of the word ItemChoiceType
89
- " %DEVKIT % \perl.exe" -p -i -e 's/(ItemChoiceType.*)$//g' %OUTFILE%
95
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/(ItemChoiceType.*)$//g' %OUTFILE%
90
96
@ rem replace the curly braces "public partial class emailSettingsType : ArrayOfSetting {" with "public partial class emailSettingsType : ArrayOfSetting ABCargumentXXX"
91
- " %DEVKIT % \perl.exe" -p -i -e 's/{/ABCargumentXXX;/g if /:/' %OUTFILE%
97
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/{/ABCargumentXXX;/g if /:/' %OUTFILE%
92
98
93
99
@ rem replacing { in "public static void ABCargumentXX {" if (null != argument)
94
- " %DEVKIT % \perl.exe" -p -i -e 's/:/\n {\n if(null != argument) \n {\n /g' %OUTFILE%
100
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/:/\n {\n if(null != argument) \n {\n /g' %OUTFILE%
95
101
96
102
97
103
@ rem removing public object from "public object Item;"
98
- " %DEVKIT % \perl.exe" -p -i -e 's/^ *public object.*//g' %OUTFILE%
104
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ *public object.*//g' %OUTFILE%
99
105
100
106
@ rem removing all datatypes
101
- " %DEVKIT % \perl.exe" -p -i -e 's/^ *public bool//g' %OUTFILE%
102
- " %DEVKIT % \perl.exe" -p -i -e 's/^ *public int.*;//g' %OUTFILE%
103
- " %DEVKIT % \perl.exe" -p -i -e 's/^ *public decimal.*;//g' %OUTFILE%
104
- " %DEVKIT % \perl.exe" -p -i -e 's/^ *public short.*;//g' %OUTFILE%
105
- " %DEVKIT % \perl.exe" -p -i -e 's/^ *public System.DateTime.*;//g' %OUTFILE%
107
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ *public bool//g' %OUTFILE%
108
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ *public int.*;//g' %OUTFILE%
109
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ *public decimal.*;//g' %OUTFILE%
110
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ *public short.*;//g' %OUTFILE%
111
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ *public System.DateTime.*;//g' %OUTFILE%
106
112
107
113
@ rem removing public keyword anywhere in file except the lines containing "public static ..."
108
- " %DEVKIT % \perl.exe" -p -i -e 's/^ *public //g if ! /public static /' %OUTFILE%
114
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ *public //g if ! /public static /' %OUTFILE%
109
115
110
116
@ rem trying to tokenize "public messagesTypeMessage[] message;"
111
- " %DEVKIT % \perl.exe" -pi -w -e 's/^ *([A-Za-z0-9]*)\[\] *([A-Za-z0-9]*);/ if(null != argument.$2){ foreach( var value in argument.$2) { $1(value);} } /g' " %OUTFILE% "
117
+ " %CYGWIN_EXE % \perl.exe" -pi -w -e 's/^ *([A-Za-z0-9]*)\[\] *([A-Za-z0-9]*);/ if(null != argument.$2){ foreach( var value in argument.$2) { $1(value);} } /g' " %OUTFILE% "
112
118
113
119
@ rem grep all the lines having specified word
114
- " %DEVKIT % \grep.exe" -i " Specified" %OUTFILE% | " %DEVKIT % \grep.exe" -v " class" | " %DEVKIT % \sort.exe" -u > %SPECIFIEDFILE%
120
+ " %CYGWIN_EXE % \grep.exe" -i " Specified" %OUTFILE% | " %CYGWIN_EXE % \grep.exe" -v " class" | " %CYGWIN_EXE % \sort.exe" -u > %SPECIFIEDFILE%
115
121
@ rem removing specified word
116
- " %DEVKIT % \perl.exe" -p -i -e 's/Specified;*//g' %SPECIFIEDFILE%
122
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/Specified;*//g' %SPECIFIEDFILE%
117
123
118
124
@ ECHO ### Processing function name - Creating functions
119
125
@ rem replacing "public static void ARBGetSubscriptionListRequest" with "XYZ ARBGetSubscriptionListRequest ABC ARBGetSubscriptionListRequest argument XXX"
120
- " %DEVKIT % \perl.exe" -pi -w -e 's/^ *public *static *void *([A-Za-z0-9]*)/XYZ $1ABC$1 argumentXXX/g' %OUTFILE%
126
+ " %CYGWIN_EXE % \perl.exe" -pi -w -e 's/^ *public *static *void *([A-Za-z0-9]*)/XYZ $1ABC$1 argumentXXX/g' %OUTFILE%
121
127
122
128
@ ECHO ### Processing Specified List - Adding if block also may take time
123
129
FOR /f %%i IN ( %SPECIFIEDFILE% ) DO (
124
130
@ rem @ECHO %%i
125
- " %DEVKIT % \perl.exe" -p -i -e 's/ ^ *%%i ;//g if ! /specified/' %OUTFILE%
126
- " %DEVKIT % \perl.exe" -p -i -e 's/^ %%i Specified;/ ifABCargument.%%i XXX { argument.%%i Specified123=true;}/g if /%%i Specified/' %OUTFILE%
131
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/ ^ *%%i ;//g if ! /specified/' %OUTFILE%
132
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ %%i Specified;/ ifABCargument.%%i XXX { argument.%%i Specified123=true;}/g if /%%i Specified/' %OUTFILE%
127
133
)
128
134
129
135
@ rem replace xyz in "XYZ paymentMaskedType ABCpaymentMaskedType argumentXXX" with public static void
130
- " %DEVKIT % \perl.exe" -p -i -e 's/XYZ/ public static void/g' %OUTFILE%
136
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/XYZ/ public static void/g' %OUTFILE%
131
137
@ rem replace ABC with (
132
- " %DEVKIT % \perl.exe" -p -i -e 's/ABC/(/g' %OUTFILE%
138
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/ABC/(/g' %OUTFILE%
133
139
@ rem replace XXX with )
134
- " %DEVKIT % \perl.exe" -p -i -e 's/XXX/)/g' %OUTFILE%
140
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/XXX/)/g' %OUTFILE%
135
141
@ rem remove 123 from "argument.taxExemptSpecified123=true; "
136
- " %DEVKIT % \perl.exe" -p -i -e 's/123//g if /Specified/' %OUTFILE%
142
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/123//g if /Specified/' %OUTFILE%
137
143
138
144
@ rem replacing the string of type "customerPaymentProfileType paymentProfile;" to "customerPaymentProfileType(argument.paymentProfile);"
139
- " %DEVKIT % \perl.exe" -pi -w -e 's/^ ([A-Za-z0-9]*) ([A-Za-z0-9]*);/ $1(argument.$2);/g' " %OUTFILE% "
145
+ " %CYGWIN_EXE % \perl.exe" -pi -w -e 's/^ ([A-Za-z0-9]*) ([A-Za-z0-9]*);/ $1(argument.$2);/g' " %OUTFILE% "
140
146
141
147
@ rem removing string like this "validationModeEnum"
142
- " %DEVKIT % \perl.exe" -p -i -e 's/^ [a-zA-Z]*$//g' %OUTFILE%
148
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/^ [a-zA-Z]*$//g' %OUTFILE%
143
149
144
150
145
151
@ ECHO }>> %OUTFILE%
@@ -202,11 +208,11 @@ FOR /f %%i IN ( %SPECIFIEDFILE%) DO (
202
208
@ ECHO */ >> %OUTFILE%
203
209
204
210
@ rem command to remove blank lines in file
205
- " %DEVKIT % \perl.exe" -i -n -e " print if /\S/" %OUTFILE%
211
+ " %CYGWIN_EXE % \perl.exe" -i -n -e " print if /\S/" %OUTFILE%
206
212
@ rem command to replace WWWW to specified
207
- " %DEVKIT % \perl.exe" -p -i -e 's/WWWW/specified/g' %OUTFILE%
213
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/WWWW/specified/g' %OUTFILE%
208
214
@ rem command to replace HTHT### to using System;
209
- " %DEVKIT % \perl.exe" -p -i -e 's/HTHT###/using System;/g' %OUTFILE%
215
+ " %CYGWIN_EXE % \perl.exe" -p -i -e 's/HTHT###/using System;/g' %OUTFILE%
210
216
211
217
@ rem deleting the .bak file created by perl command
212
218
del /S /Q *.bak > NUL
0 commit comments