├── .gitignore
├── .nuget
└── packages.config
├── LICENSE
├── README.md
├── Sitecore.CodeGenerator.Sample.Glass
├── Data
│ ├── Unicorn
│ │ ├── Readme.txt
│ │ └── Sample templates
│ │ │ └── Templates
│ │ │ ├── Sitecore Code Generator Sample.yml
│ │ │ └── Sitecore Code Generator Sample
│ │ │ ├── Animal.yml
│ │ │ ├── Animal
│ │ │ ├── Animal.yml
│ │ │ └── Animal
│ │ │ │ └── Description.yml
│ │ │ ├── Dog.yml
│ │ │ ├── Dog
│ │ │ ├── Dog.yml
│ │ │ └── Dog
│ │ │ │ ├── Eats.yml
│ │ │ │ └── Friends.yml
│ │ │ ├── Food.yml
│ │ │ ├── Food
│ │ │ ├── Nutrition.yml
│ │ │ └── Nutrition
│ │ │ │ └── Calories.yml
│ │ │ ├── Nameable.yml
│ │ │ └── Nameable
│ │ │ ├── Name.yml
│ │ │ └── Name
│ │ │ └── Name.yml
│ └── serialization
│ │ ├── Readme.txt
│ │ └── master
│ │ └── sitecore
│ │ └── templates
│ │ ├── Sitecore Code Generator Sample.item
│ │ └── Sitecore Code Generator Sample
│ │ ├── Animal.item
│ │ ├── Animal
│ │ ├── Animal.item
│ │ └── Animal
│ │ │ └── Description.item
│ │ ├── Dog.item
│ │ ├── Dog
│ │ ├── Dog.item
│ │ └── Dog
│ │ │ ├── Eats.item
│ │ │ └── Friends.item
│ │ ├── Food.item
│ │ ├── Food
│ │ ├── Nutrition.item
│ │ └── Nutrition
│ │ │ └── Calories.item
│ │ ├── Nameable.item
│ │ └── Nameable
│ │ ├── Name.item
│ │ └── Name
│ │ └── Name.item
├── Models
│ ├── GlassGenerator.tt
│ ├── GlassMappedClassTemplate.tt
│ ├── IAnimal.gen.cs
│ ├── IDog.gen.cs
│ ├── IFood.gen.cs
│ ├── INameable.gen.cs
│ ├── SampleScriptTemplates.gen.txt
│ └── SampleScriptTemplates.tt
├── Properties
│ └── AssemblyInfo.cs
├── Sitecore.CodeGenerator.Sample.Glass.csproj
├── app.config
└── packages.config
├── Sitecore.CodeGenerator.Tests
├── Properties
│ └── AssemblyInfo.cs
├── Sitecore.CodeGenerator.Tests.csproj
├── TemplatesResolverRainbowTest.cs
├── TemplatesResolverTest.cs
└── packages.config
├── Sitecore.CodeGenerator.sln
├── Sitecore.CodeGenerator
├── Domain
│ ├── ItemBase.cs
│ ├── TemplateField.cs
│ ├── TemplateItem.cs
│ └── TemplateSection.cs
├── Properties
│ └── AssemblyInfo.cs
├── Serialization
│ ├── SerializedIdToPathResolver.cs
│ └── SerializedIdToPathSet.cs
├── Sitecore.CodeGenerator.csproj
├── TemplatesResolver.cs
├── TemplatesResolverBase.cs
├── TemplatesResolverRainbow.cs
└── packages.config
├── Sitecore.Codegenerator.Scripty.Sample.Glass
├── .gitignore
├── Data
│ └── Unicorn
│ │ ├── Readme.txt
│ │ └── Sample templates
│ │ └── Templates
│ │ ├── Sitecore Code Generator Sample.yml
│ │ └── Sitecore Code Generator Sample
│ │ ├── Animal.yml
│ │ ├── Animal
│ │ ├── Animal.yml
│ │ └── Animal
│ │ │ └── Description.yml
│ │ ├── Dog.yml
│ │ ├── Dog
│ │ ├── Dog.yml
│ │ └── Dog
│ │ │ ├── Eats.yml
│ │ │ └── Friends.yml
│ │ ├── Food.yml
│ │ ├── Food
│ │ ├── Nutrition.yml
│ │ └── Nutrition
│ │ │ └── Calories.yml
│ │ ├── Nameable.yml
│ │ └── Nameable
│ │ ├── Name.yml
│ │ └── Name
│ │ └── Name.yml
├── Models
│ └── GlassGenerator.csx
├── Properties
│ └── AssemblyInfo.cs
├── Sitecore.Codegenerator.Scripty.Sample.Glass.csproj
├── app.config
└── packages.config
└── Sitecore.Codegenerator.Scripty
├── CodeGenerationExtensions.cs
├── Properties
└── AssemblyInfo.cs
├── SerializedDataUtil.cs
├── Sitecore.Codegenerator.Scripty.csproj
├── app.config
└── packages.config
/.gitignore:
--------------------------------------------------------------------------------
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 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studo 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | *_i.c
42 | *_p.c
43 | *_i.h
44 | *.ilk
45 | *.meta
46 | *.obj
47 | *.pch
48 | *.pdb
49 | *.pgc
50 | *.pgd
51 | *.rsp
52 | *.sbr
53 | *.tlb
54 | *.tli
55 | *.tlh
56 | *.tmp
57 | *.tmp_proj
58 | *.log
59 | *.vspscc
60 | *.vssscc
61 | .builds
62 | *.pidb
63 | *.svclog
64 | *.scc
65 |
66 | # Chutzpah Test files
67 | _Chutzpah*
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 | *.cachefile
76 |
77 | # Visual Studio profiler
78 | *.psess
79 | *.vsp
80 | *.vspx
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 | # Guidance Automation Toolkit
86 | *.gpState
87 |
88 | # ReSharper is a .NET coding add-in
89 | _ReSharper*/
90 | *.[Rr]e[Ss]harper
91 | *.DotSettings.user
92 |
93 | # JustCode is a .NET coding addin-in
94 | .JustCode
95 |
96 | # TeamCity is a build add-in
97 | _TeamCity*
98 |
99 | # DotCover is a Code Coverage Tool
100 | *.dotCover
101 |
102 | # NCrunch
103 | _NCrunch_*
104 | .*crunch*.local.xml
105 |
106 | # MightyMoose
107 | *.mm.*
108 | AutoTest.Net/
109 |
110 | # Web workbench (sass)
111 | .sass-cache/
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.[Pp]ublish.xml
131 | *.azurePubxml
132 | # TODO: Comment the next line if you want to checkin your web deploy settings
133 | # but database connection strings (with potential passwords) will be unencrypted
134 | *.pubxml
135 | *.publishproj
136 |
137 | # NuGet Packages
138 | *.nupkg
139 | # The packages folder can be ignored because of Package Restore
140 | **/packages/*
141 | # except build/, which is used as an MSBuild target.
142 | !**/packages/build/
143 | # Uncomment if necessary however generally it will be regenerated when needed
144 | #!**/packages/repositories.config
145 |
146 | # Windows Azure Build Output
147 | csx/
148 | *.build.csdef
149 |
150 | # Windows Store app package directory
151 | AppPackages/
152 |
153 | # Others
154 | *.[Cc]ache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 | bower_components/
165 |
166 | # RIA/Silverlight projects
167 | Generated_Code/
168 |
169 | # Backup & report files from converting an old project file
170 | # to a newer Visual Studio version. Backup files are not needed,
171 | # because we have git ;-)
172 | _UpgradeReport_Files/
173 | Backup*/
174 | UpgradeLog*.XML
175 | UpgradeLog*.htm
176 |
177 | # SQL Server files
178 | *.mdf
179 | *.ldf
180 |
181 | # Business Intelligence projects
182 | *.rdl.data
183 | *.bim.layout
184 | *.bim_*.settings
185 |
186 | # Microsoft Fakes
187 | FakesAssemblies/
188 |
189 | # Node.js Tools for Visual Studio
190 | .ntvs_analysis.dat
191 |
192 | # Visual Studio 6 build log
193 | *.plg
194 |
195 | # Visual Studio 6 workspace options file
196 | *.opt
197 | Lib/
198 |
--------------------------------------------------------------------------------
/.nuget/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | {one line to give the program's name and a brief idea of what it does.}
635 | Copyright (C) {year} {name of author}
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | {project} Copyright (C) {year} {fullname}
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
676 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sitecore.CodeGenerator
2 |
3 | This project allows you to generate interfaces/classes based on your Sitecore template structure. It works with serialized data from Sitecore (incl. TDS/Unicorn) and uses T4 templates for generating the files. The [T4 Toolbox](http://www.olegsych.com/2012/12/t4-toolbox-for-visual-studio-2012/) is used to generate multiple files.
4 |
5 | By default, it supports generating interfaces that are decorated with [Glass Mapper](https://github.com/mikeedwards83/Glass.Mapper) attributes. But the Sitecore.CodeGenerator project only provides easy access to the serialized template information and can therefore easily be used to create T4 templates for other mapping/wrapping frameworks.
6 |
7 | ## How it works
8 | Sitecore.CodeGenerator reads serialized data from the filesystem. The T4 templates do the rest of the work.
9 | - **GlassGenerator.tt** - The central class that actually uses Sitecore.CodeGenerator.DLL to read the serialized data and then creates the individual generated files.
10 | - **GlassMappedClassTemplate.tt** - Individual template for what the generated files should look like. If you need to customize the code that needs to be generated, this is the first place to look.
11 | - **SampleScriptTemplates.tt** - You can make as many copies of this as you like, for different groups/folders of templates. The generated files will show up as children of this item in the Solution Explorer.
12 |
13 | ## Adding code generation to your project
14 |
15 | 1. Install the [T4 Toolbox](http://www.olegsych.com/2012/12/t4-toolbox-for-visual-studio-2012/) Visual Studio extension.
16 | 2. Compile Sitecore.CodeGenerator or download it [here](https://github.com/hermanussen/sitecore.codegenerator/archive/master.zip). Copy the DLL to a folder that is within reach from your project (no need to add a reference; a dependency within your project isn't needed).
17 | 3. Copy the .tt files and include them in your project. The files are GlassGenerator.tt, GlassMappedClassTemplate.tt and SampleScriptTemplates.tt.
18 | 4. For GlassGenerator.tt and GlassMappedClassTemplate.tt, empty the project property "Custom Tool". Also, change the file references at the top of these files to correctly reference the Sitecore.Kernel.DLL, Sitecore.CodeGenerator.DLL and Glass.Mapper.Sc.DLL files.
19 | 5. In GlassGenerator.tt, change the following code so the path references your serialized data:```Context.Host.ResolvePath(@"..\Data\serialization\")```. The path is relative to the location of the .tt files.
20 | 6. In SampleScriptTemplates.tt, change the following code to set the path(s) of the templates that you want to generate code for: ```new [] { "/sitecore/templates/Sitecore Code Generator Sample" }```.
21 | 7. Run the code generation either by right-clicking SampleScriptTemplates.tt and choosing "Run Custom Tool", or choosing "Build" > "Transform All T4 Templates".
22 |
23 | ## Using Unicorn's Rainbow format
24 |
25 | Since Unicorn has adopted a new serialization format from version 3, the code generation needs to be configured slightly different to be used with that.
26 |
27 | 1. Go to GlassGenerator.tt and locate the RunCore() method
28 | 2. Locate the following line within that method:
29 | `
30 | var resolver = new TemplatesResolver(
31 | `
32 | 3. Change that line to the following:
33 | `
34 | var resolver = new TemplatesResolverRainbow(
35 | `
36 | 4. Ensure that the path to the serialized data (as set in step 5 of the previous section) points to a valid Unicorn configuration that contains Sitecore templates in .yml files. Note that this is on the next line of code.
37 |
38 | ## Further configuration
39 |
40 | It can't always be determined exactly from the Sitecore data what the return types of properties need to be. E.g.: A multilist may be used to select a number of items of a certain type. But you need to define that type yourself.
41 |
42 | By default, the mapping of field types to C# types is done by GlassGenerator.tt in the ```GetFieldOptions(...)``` function. You can change it there.
43 |
44 | But for individual scenario's like the one described earlier (the multilist that maps to items of a certain type), you can use a specific technique in the file SampleScriptTemplates.tt. Simply put, you make exceptions for individual cases, by checking a field ID and then setting the field options. E.g.:
45 | ```
46 | // Add custom options, like setting the return type of a field property explicitly
47 |
48 | // Dog -> Food
49 | if("{1033D7C1-9C1A-4C65-8316-81B6D5E46EB5}".Equals(fieldId))
50 | {
51 | fieldOptions.GlassFieldTypeName = "IEnumerable";
52 | }
53 | ```
54 |
55 | ## License
56 | Copyright (C) 2015-2016 Robin Hermanussen
57 |
58 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
59 |
60 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
61 |
62 | You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
63 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Readme.txt:
--------------------------------------------------------------------------------
1 | - This is the folder where currently, the Rainbow (Unicorn) version of the data is serialized to
2 | - The serialized data is not currently included in the solution, so find this folder on the filesystem to see what's going on
3 | - You can change which folder to find serialized data in, by changing the path in the GlassGenerator.tt file
4 | - Please refer to the file ../serialization/Readme.txt for the default Sitecore serialization format data
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "84521828-eddc-47b3-bf39-781ee10a6a74"
3 | Parent: "3c1715fe-6a13-4fcf-845f-de308ba9741d"
4 | Template: "0437fee2-44c9-46a6-abe9-28858d9fee8c"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample
6 | DB: master
7 | SharedFields:
8 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
9 | Hint: __Sortorder
10 | Value: 600
11 | Languages:
12 | - Language: en
13 | Versions:
14 | - Version: 1
15 | Fields:
16 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
17 | Hint: __Created
18 | Value: 20150224T174247Z
19 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
20 | Hint: __Created by
21 | Value: sitecore\admin
22 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Animal.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "319eb0a2-ef28-4dae-b35c-551bd53317b2"
3 | Parent: "84521828-eddc-47b3-bf39-781ee10a6a74"
4 | Template: "ab86861a-6030-46c5-b394-e8f99e8b87db"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Animal
6 | DB: master
7 | SharedFields:
8 | - ID: "12c33f3f-86c5-43a5-aeb4-5598cec45116"
9 | Hint: __Base template
10 | Type: tree list
11 | Value: "{1930BBEB-7805-471A-A3BE-4858AC7CF696}"
12 | Languages:
13 | - Language: en
14 | Versions:
15 | - Version: 1
16 | Fields:
17 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
18 | Hint: __Created
19 | Value: 20150224T174342Z
20 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
21 | Hint: __Created by
22 | Value: sitecore\admin
23 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Animal/Animal.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "110d503b-2ea3-4602-aca0-d8508376e30d"
3 | Parent: "319eb0a2-ef28-4dae-b35c-551bd53317b2"
4 | Template: "e269fbb5-3750-427a-9149-7aa950b49301"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Animal/Animal
6 | DB: master
7 | Languages:
8 | - Language: en
9 | Versions:
10 | - Version: 1
11 | Fields:
12 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
13 | Hint: __Created
14 | Value: 20150224T175642Z
15 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
16 | Hint: __Created by
17 | Value: sitecore\admin
18 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Animal/Animal/Description.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "edfd61c6-bbef-45b6-8fd4-84ca215bab73"
3 | Parent: "110d503b-2ea3-4602-aca0-d8508376e30d"
4 | Template: "455a3e98-a627-4b40-8035-e683a0331ac7"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Animal/Animal/Description
6 | DB: master
7 | SharedFields:
8 | - ID: "ab162cc0-dc80-4abf-8871-998ee5d7ba32"
9 | Hint: Type
10 | Value: Rich Text
11 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
12 | Hint: __Sortorder
13 | Value: 200
14 | Languages:
15 | - Language: en
16 | Fields:
17 | - ID: "19a69332-a23e-4e70-8d16-b2640cb24cc8"
18 | Hint: Title
19 | Value: A short description of the animal
20 | Versions:
21 | - Version: 1
22 | Fields:
23 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
24 | Hint: __Created
25 | Value: 20150224T175642Z
26 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Dog.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "f4a0d5d5-49f9-488f-82aa-d4be1adcb662"
3 | Parent: "84521828-eddc-47b3-bf39-781ee10a6a74"
4 | Template: "ab86861a-6030-46c5-b394-e8f99e8b87db"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Dog
6 | DB: master
7 | SharedFields:
8 | - ID: "12c33f3f-86c5-43a5-aeb4-5598cec45116"
9 | Hint: __Base template
10 | Type: tree list
11 | Value: |
12 | {319EB0A2-EF28-4DAE-B35C-551BD53317B2}
13 | {2852DE45-BF36-44D8-9435-8A30EC6923C5}
14 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
15 | Hint: __Sortorder
16 | Value: 625
17 | Languages:
18 | - Language: en
19 | Versions:
20 | - Version: 1
21 | Fields:
22 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
23 | Hint: __Created
24 | Value: 20150224T174357Z
25 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
26 | Hint: __Created by
27 | Value: sitecore\admin
28 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Dog/Dog.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "61472a67-4c8e-410a-a07e-61d84afaed19"
3 | Parent: "f4a0d5d5-49f9-488f-82aa-d4be1adcb662"
4 | Template: "e269fbb5-3750-427a-9149-7aa950b49301"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Dog/Dog
6 | DB: master
7 | Languages:
8 | - Language: en
9 | Versions:
10 | - Version: 1
11 | Fields:
12 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
13 | Hint: __Created
14 | Value: 20150224T174605Z
15 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
16 | Hint: __Created by
17 | Value: sitecore\admin
18 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Dog/Dog/Eats.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "1033d7c1-9c1a-4c65-8316-81b6d5e46eb5"
3 | Parent: "61472a67-4c8e-410a-a07e-61d84afaed19"
4 | Template: "455a3e98-a627-4b40-8035-e683a0331ac7"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Dog/Dog/Eats
6 | DB: master
7 | SharedFields:
8 | - ID: "ab162cc0-dc80-4abf-8871-998ee5d7ba32"
9 | Hint: Type
10 | Value: Multilist with Search
11 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
12 | Hint: __Sortorder
13 | Value: 100
14 | - ID: "be351a73-fcb0-4213-93fa-c302d8ab4f51"
15 | Hint: Shared
16 | Type: Checkbox
17 | Value: 1
18 | Languages:
19 | - Language: en
20 | Fields:
21 | - ID: "19a69332-a23e-4e70-8d16-b2640cb24cc8"
22 | Hint: Title
23 | Value: "What food does the dog eat?"
24 | Versions:
25 | - Version: 1
26 | Fields:
27 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
28 | Hint: __Created
29 | Value: 20150224T174605Z
30 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Dog/Dog/Friends.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "20d7789d-bce0-473e-bb46-59b216ce2c10"
3 | Parent: "61472a67-4c8e-410a-a07e-61d84afaed19"
4 | Template: "455a3e98-a627-4b40-8035-e683a0331ac7"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Dog/Dog/Friends
6 | DB: master
7 | SharedFields:
8 | - ID: "ab162cc0-dc80-4abf-8871-998ee5d7ba32"
9 | Hint: Type
10 | Value: Multilist with Search
11 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
12 | Hint: __Sortorder
13 | Value: 200
14 | - ID: "be351a73-fcb0-4213-93fa-c302d8ab4f51"
15 | Hint: Shared
16 | Type: Checkbox
17 | Value: 1
18 | Languages:
19 | - Language: en
20 | Fields:
21 | - ID: "19a69332-a23e-4e70-8d16-b2640cb24cc8"
22 | Hint: Title
23 | Value: Other dogs that this dog likes
24 | Versions:
25 | - Version: 1
26 | Fields:
27 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
28 | Hint: __Created
29 | Value: 20150224T180103Z
30 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Food.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "7196e22c-0b26-4539-baee-959ed8c5bfe5"
3 | Parent: "84521828-eddc-47b3-bf39-781ee10a6a74"
4 | Template: "ab86861a-6030-46c5-b394-e8f99e8b87db"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Food
6 | DB: master
7 | SharedFields:
8 | - ID: "12c33f3f-86c5-43a5-aeb4-5598cec45116"
9 | Hint: __Base template
10 | Type: tree list
11 | Value: "{1930BBEB-7805-471A-A3BE-4858AC7CF696}"
12 | Languages:
13 | - Language: en
14 | Versions:
15 | - Version: 1
16 | Fields:
17 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
18 | Hint: __Created
19 | Value: 20150224T175843Z
20 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
21 | Hint: __Created by
22 | Value: sitecore\admin
23 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Food/Nutrition.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "e8479274-f80d-4c1b-b5eb-01df2b84f41f"
3 | Parent: "7196e22c-0b26-4539-baee-959ed8c5bfe5"
4 | Template: "e269fbb5-3750-427a-9149-7aa950b49301"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Food/Nutrition
6 | DB: master
7 | Languages:
8 | - Language: en
9 | Versions:
10 | - Version: 1
11 | Fields:
12 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
13 | Hint: __Created
14 | Value: 20150224T175820Z
15 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
16 | Hint: __Created by
17 | Value: sitecore\admin
18 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Food/Nutrition/Calories.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "3f57b9d2-50ec-4f87-8631-2334c837d5bf"
3 | Parent: "e8479274-f80d-4c1b-b5eb-01df2b84f41f"
4 | Template: "455a3e98-a627-4b40-8035-e683a0331ac7"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Food/Nutrition/Calories
6 | DB: master
7 | SharedFields:
8 | - ID: "ab162cc0-dc80-4abf-8871-998ee5d7ba32"
9 | Hint: Type
10 | Value: Number
11 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
12 | Hint: __Sortorder
13 | Value: 100
14 | - ID: "be351a73-fcb0-4213-93fa-c302d8ab4f51"
15 | Hint: Shared
16 | Type: Checkbox
17 | Value: 1
18 | Languages:
19 | - Language: en
20 | Fields:
21 | - ID: "19a69332-a23e-4e70-8d16-b2640cb24cc8"
22 | Hint: Title
23 | Value: "How many calories per serving?"
24 | Versions:
25 | - Version: 1
26 | Fields:
27 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
28 | Hint: __Created
29 | Value: 20150224T175820Z
30 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Nameable.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "2852de45-bf36-44d8-9435-8a30ec6923c5"
3 | Parent: "84521828-eddc-47b3-bf39-781ee10a6a74"
4 | Template: "ab86861a-6030-46c5-b394-e8f99e8b87db"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Nameable
6 | DB: master
7 | SharedFields:
8 | - ID: "12c33f3f-86c5-43a5-aeb4-5598cec45116"
9 | Hint: __Base template
10 | Type: tree list
11 | Value: "{1930BBEB-7805-471A-A3BE-4858AC7CF696}"
12 | Languages:
13 | - Language: en
14 | Versions:
15 | - Version: 1
16 | Fields:
17 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
18 | Hint: __Created
19 | Value: 20150224T174806Z
20 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
21 | Hint: __Created by
22 | Value: sitecore\admin
23 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Nameable/Name.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "b35a500e-1cd2-4a61-bd6f-887d7edc7718"
3 | Parent: "2852de45-bf36-44d8-9435-8a30ec6923c5"
4 | Template: "e269fbb5-3750-427a-9149-7aa950b49301"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Nameable/Name
6 | DB: master
7 | Languages:
8 | - Language: en
9 | Versions:
10 | - Version: 1
11 | Fields:
12 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
13 | Hint: __Created
14 | Value: 20150224T174821Z
15 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
16 | Hint: __Created by
17 | Value: sitecore\admin
18 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Nameable/Name/Name.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "7e4faa48-e6ce-46b7-888e-309b5fcc4107"
3 | Parent: "b35a500e-1cd2-4a61-bd6f-887d7edc7718"
4 | Template: "455a3e98-a627-4b40-8035-e683a0331ac7"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Nameable/Name/Name
6 | DB: master
7 | SharedFields:
8 | - ID: "ab162cc0-dc80-4abf-8871-998ee5d7ba32"
9 | Hint: Type
10 | Value: "Single-Line Text"
11 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
12 | Hint: __Sortorder
13 | Value: 100
14 | Languages:
15 | - Language: en
16 | Versions:
17 | - Version: 1
18 | Fields:
19 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
20 | Hint: __Created
21 | Value: 20150224T174821Z
22 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/Readme.txt:
--------------------------------------------------------------------------------
1 | - This is the folder where currently, the data is serialized to
2 | - The serialized data is not currently included in the solution, so find this folder on the filesystem to see what's going on
3 | - You can change which folder to find serialized data in, by changing the path in the GlassGenerator.tt file
4 | - Please refer to the file ../Unicorn/Readme.txt for the Rainbow (Unicorn) format data
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {84521828-EDDC-47B3-BF39-781EE10A6A74}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample
6 | parent: {3C1715FE-6A13-4FCF-845F-DE308BA9741D}
7 | name: Sitecore Code Generator Sample
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {0437FEE2-44C9-46A6-ABE9-28858D9FEE8C}
10 | templatekey: Template Folder
11 |
12 | ----field----
13 | field: {BA3F86A2-4A1C-4D78-B63D-91C2779C1B5E}
14 | name: __Sortorder
15 | key: __sortorder
16 | content-length: 3
17 |
18 | 600
19 | ----version----
20 | language: en
21 | version: 1
22 | revision: d987fe51-c40c-4648-83de-5a26ff7d7ee3
23 |
24 | ----field----
25 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
26 | name: __Created
27 | key: __created
28 | content-length: 16
29 |
30 | 20150224T174247Z
31 | ----field----
32 | field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}
33 | name: __Created by
34 | key: __created by
35 | content-length: 14
36 |
37 | sitecore\admin
38 | ----field----
39 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
40 | name: __Revision
41 | key: __revision
42 | content-length: 36
43 |
44 | d987fe51-c40c-4648-83de-5a26ff7d7ee3
45 | ----field----
46 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
47 | name: __Updated
48 | key: __updated
49 | content-length: 35
50 |
51 | 20150224T175705:635603974250354719Z
52 | ----field----
53 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
54 | name: __Updated by
55 | key: __updated by
56 | content-length: 14
57 |
58 | sitecore\admin
59 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Animal.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {319EB0A2-EF28-4DAE-B35C-551BD53317B2}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Animal
6 | parent: {84521828-EDDC-47B3-BF39-781EE10A6A74}
7 | name: Animal
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {AB86861A-6030-46C5-B394-E8F99E8B87DB}
10 | templatekey: Template
11 |
12 | ----field----
13 | field: {12C33F3F-86C5-43A5-AEB4-5598CEC45116}
14 | name: __Base template
15 | key: __base template
16 | content-length: 38
17 |
18 | {1930BBEB-7805-471A-A3BE-4858AC7CF696}
19 | ----version----
20 | language: en
21 | version: 1
22 | revision: 520ac439-70b7-4521-a7f9-6b8a2a168388
23 |
24 | ----field----
25 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
26 | name: __Created
27 | key: __created
28 | content-length: 16
29 |
30 | 20150224T174342Z
31 | ----field----
32 | field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}
33 | name: __Created by
34 | key: __created by
35 | content-length: 14
36 |
37 | sitecore\admin
38 | ----field----
39 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
40 | name: __Revision
41 | key: __revision
42 | content-length: 36
43 |
44 | 520ac439-70b7-4521-a7f9-6b8a2a168388
45 | ----field----
46 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
47 | name: __Updated
48 | key: __updated
49 | content-length: 35
50 |
51 | 20150224T175657:635603974176978002Z
52 | ----field----
53 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
54 | name: __Updated by
55 | key: __updated by
56 | content-length: 14
57 |
58 | sitecore\admin
59 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Animal/Animal.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {110D503B-2EA3-4602-ACA0-D8508376E30D}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Animal/Animal
6 | parent: {319EB0A2-EF28-4DAE-B35C-551BD53317B2}
7 | name: Animal
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {E269FBB5-3750-427A-9149-7AA950B49301}
10 | templatekey: Template section
11 |
12 | ----version----
13 | language: en
14 | version: 1
15 | revision: 9e74284e-3bc6-4d6f-a905-a88f9ae8970a
16 |
17 | ----field----
18 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
19 | name: __Created
20 | key: __created
21 | content-length: 16
22 |
23 | 20150224T175642Z
24 | ----field----
25 | field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}
26 | name: __Created by
27 | key: __created by
28 | content-length: 14
29 |
30 | sitecore\admin
31 | ----field----
32 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
33 | name: __Revision
34 | key: __revision
35 | content-length: 36
36 |
37 | 9e74284e-3bc6-4d6f-a905-a88f9ae8970a
38 | ----field----
39 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
40 | name: __Updated
41 | key: __updated
42 | content-length: 35
43 |
44 | 20150224T175642:635603974024181339Z
45 | ----field----
46 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
47 | name: __Updated by
48 | key: __updated by
49 | content-length: 14
50 |
51 | sitecore\admin
52 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Animal/Animal/Description.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {EDFD61C6-BBEF-45B6-8FD4-84CA215BAB73}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Animal/Animal/Description
6 | parent: {110D503B-2EA3-4602-ACA0-D8508376E30D}
7 | name: Description
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {455A3E98-A627-4B40-8035-E683A0331AC7}
10 | templatekey: Template field
11 |
12 | ----field----
13 | field: {AB162CC0-DC80-4ABF-8871-998EE5D7BA32}
14 | name: Type
15 | key: type
16 | content-length: 9
17 |
18 | Rich Text
19 | ----field----
20 | field: {BA3F86A2-4A1C-4D78-B63D-91C2779C1B5E}
21 | name: __Sortorder
22 | key: __sortorder
23 | content-length: 3
24 |
25 | 200
26 | ----version----
27 | language: en
28 | version: 1
29 | revision: 4b059ba9-ab57-4341-b9b3-6bd0a821c8ea
30 |
31 | ----field----
32 | field: {19A69332-A23E-4E70-8D16-B2640CB24CC8}
33 | name: Title
34 | key: title
35 | content-length: 33
36 |
37 | A short description of the animal
38 | ----field----
39 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
40 | name: __Created
41 | key: __created
42 | content-length: 16
43 |
44 | 20150224T175642Z
45 | ----field----
46 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
47 | name: __Revision
48 | key: __revision
49 | content-length: 36
50 |
51 | 4b059ba9-ab57-4341-b9b3-6bd0a821c8ea
52 | ----field----
53 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
54 | name: __Updated
55 | key: __updated
56 | content-length: 35
57 |
58 | 20150224T180735:635603980555517531Z
59 | ----field----
60 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
61 | name: __Updated by
62 | key: __updated by
63 | content-length: 14
64 |
65 | sitecore\admin
66 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Dog.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {F4A0D5D5-49F9-488F-82AA-D4BE1ADCB662}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Dog
6 | parent: {84521828-EDDC-47B3-BF39-781EE10A6A74}
7 | name: Dog
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {AB86861A-6030-46C5-B394-E8F99E8B87DB}
10 | templatekey: Template
11 |
12 | ----field----
13 | field: {12C33F3F-86C5-43A5-AEB4-5598CEC45116}
14 | name: __Base template
15 | key: __base template
16 | content-length: 77
17 |
18 | {319EB0A2-EF28-4DAE-B35C-551BD53317B2}|{2852DE45-BF36-44D8-9435-8A30EC6923C5}
19 | ----field----
20 | field: {BA3F86A2-4A1C-4D78-B63D-91C2779C1B5E}
21 | name: __Sortorder
22 | key: __sortorder
23 | content-length: 3
24 |
25 | 625
26 | ----version----
27 | language: en
28 | version: 1
29 | revision: 7eef417a-e225-4014-9167-339a80eba737
30 |
31 | ----field----
32 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
33 | name: __Created
34 | key: __created
35 | content-length: 16
36 |
37 | 20150224T174357Z
38 | ----field----
39 | field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}
40 | name: __Created by
41 | key: __created by
42 | content-length: 14
43 |
44 | sitecore\admin
45 | ----field----
46 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
47 | name: __Revision
48 | key: __revision
49 | content-length: 36
50 |
51 | 7eef417a-e225-4014-9167-339a80eba737
52 | ----field----
53 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
54 | name: __Updated
55 | key: __updated
56 | content-length: 35
57 |
58 | 20150224T180103:635603976632953853Z
59 | ----field----
60 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
61 | name: __Updated by
62 | key: __updated by
63 | content-length: 14
64 |
65 | sitecore\admin
66 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Dog/Dog.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {61472A67-4C8E-410A-A07E-61D84AFAED19}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Dog/Dog
6 | parent: {F4A0D5D5-49F9-488F-82AA-D4BE1ADCB662}
7 | name: Dog
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {E269FBB5-3750-427A-9149-7AA950B49301}
10 | templatekey: Template section
11 |
12 | ----version----
13 | language: en
14 | version: 1
15 | revision: 0955f6cf-89cb-4644-b02c-47f06555a419
16 |
17 | ----field----
18 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
19 | name: __Created
20 | key: __created
21 | content-length: 16
22 |
23 | 20150224T174605Z
24 | ----field----
25 | field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}
26 | name: __Created by
27 | key: __created by
28 | content-length: 14
29 |
30 | sitecore\admin
31 | ----field----
32 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
33 | name: __Revision
34 | key: __revision
35 | content-length: 36
36 |
37 | 0955f6cf-89cb-4644-b02c-47f06555a419
38 | ----field----
39 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
40 | name: __Updated
41 | key: __updated
42 | content-length: 35
43 |
44 | 20150224T180103:635603976630221949Z
45 | ----field----
46 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
47 | name: __Updated by
48 | key: __updated by
49 | content-length: 14
50 |
51 | sitecore\admin
52 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Dog/Dog/Eats.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {1033D7C1-9C1A-4C65-8316-81B6D5E46EB5}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Dog/Dog/Eats
6 | parent: {61472A67-4C8E-410A-A07E-61D84AFAED19}
7 | name: Eats
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {455A3E98-A627-4B40-8035-E683A0331AC7}
10 | templatekey: Template field
11 |
12 | ----field----
13 | field: {AB162CC0-DC80-4ABF-8871-998EE5D7BA32}
14 | name: Type
15 | key: type
16 | content-length: 21
17 |
18 | Multilist with Search
19 | ----field----
20 | field: {BE351A73-FCB0-4213-93FA-C302D8AB4F51}
21 | name: Shared
22 | key: shared
23 | content-length: 1
24 |
25 | 1
26 | ----field----
27 | field: {BA3F86A2-4A1C-4D78-B63D-91C2779C1B5E}
28 | name: __Sortorder
29 | key: __sortorder
30 | content-length: 3
31 |
32 | 100
33 | ----version----
34 | language: en
35 | version: 1
36 | revision: e62c4aa9-1ad9-4eab-9770-03f642eb7bff
37 |
38 | ----field----
39 | field: {19A69332-A23E-4E70-8D16-B2640CB24CC8}
40 | name: Title
41 | key: title
42 | content-length: 27
43 |
44 | What food does the dog eat?
45 | ----field----
46 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
47 | name: __Created
48 | key: __created
49 | content-length: 16
50 |
51 | 20150224T174605Z
52 | ----field----
53 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
54 | name: __Revision
55 | key: __revision
56 | content-length: 36
57 |
58 | e62c4aa9-1ad9-4eab-9770-03f642eb7bff
59 | ----field----
60 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
61 | name: __Updated
62 | key: __updated
63 | content-length: 35
64 |
65 | 20150224T180815:635603980953252539Z
66 | ----field----
67 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
68 | name: __Updated by
69 | key: __updated by
70 | content-length: 14
71 |
72 | sitecore\admin
73 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Dog/Dog/Friends.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {20D7789D-BCE0-473E-BB46-59B216CE2C10}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Dog/Dog/Friends
6 | parent: {61472A67-4C8E-410A-A07E-61D84AFAED19}
7 | name: Friends
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {455A3E98-A627-4B40-8035-E683A0331AC7}
10 | templatekey: Template field
11 |
12 | ----field----
13 | field: {AB162CC0-DC80-4ABF-8871-998EE5D7BA32}
14 | name: Type
15 | key: type
16 | content-length: 21
17 |
18 | Multilist with Search
19 | ----field----
20 | field: {BE351A73-FCB0-4213-93FA-C302D8AB4F51}
21 | name: Shared
22 | key: shared
23 | content-length: 1
24 |
25 | 1
26 | ----field----
27 | field: {BA3F86A2-4A1C-4D78-B63D-91C2779C1B5E}
28 | name: __Sortorder
29 | key: __sortorder
30 | content-length: 3
31 |
32 | 200
33 | ----version----
34 | language: en
35 | version: 1
36 | revision: d2117b77-d836-4e05-8c67-3317c562c766
37 |
38 | ----field----
39 | field: {19A69332-A23E-4E70-8D16-B2640CB24CC8}
40 | name: Title
41 | key: title
42 | content-length: 30
43 |
44 | Other dogs that this dog likes
45 | ----field----
46 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
47 | name: __Created
48 | key: __created
49 | content-length: 16
50 |
51 | 20150224T180103Z
52 | ----field----
53 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
54 | name: __Revision
55 | key: __revision
56 | content-length: 36
57 |
58 | d2117b77-d836-4e05-8c67-3317c562c766
59 | ----field----
60 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
61 | name: __Updated
62 | key: __updated
63 | content-length: 35
64 |
65 | 20150224T180829:635603981094949764Z
66 | ----field----
67 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
68 | name: __Updated by
69 | key: __updated by
70 | content-length: 14
71 |
72 | sitecore\admin
73 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Food.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {7196E22C-0B26-4539-BAEE-959ED8C5BFE5}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Food
6 | parent: {84521828-EDDC-47B3-BF39-781EE10A6A74}
7 | name: Food
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {AB86861A-6030-46C5-B394-E8F99E8B87DB}
10 | templatekey: Template
11 |
12 | ----field----
13 | field: {12C33F3F-86C5-43A5-AEB4-5598CEC45116}
14 | name: __Base template
15 | key: __base template
16 | content-length: 38
17 |
18 | {1930BBEB-7805-471A-A3BE-4858AC7CF696}
19 | ----version----
20 | language: en
21 | version: 1
22 | revision: c6454006-1dc4-4ce6-aede-5366dc70829b
23 |
24 | ----field----
25 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
26 | name: __Created
27 | key: __created
28 | content-length: 16
29 |
30 | 20150224T175843Z
31 | ----field----
32 | field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}
33 | name: __Created by
34 | key: __created by
35 | content-length: 14
36 |
37 | sitecore\admin
38 | ----field----
39 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
40 | name: __Revision
41 | key: __revision
42 | content-length: 36
43 |
44 | c6454006-1dc4-4ce6-aede-5366dc70829b
45 | ----field----
46 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
47 | name: __Updated
48 | key: __updated
49 | content-length: 35
50 |
51 | 20150224T175843:635603975238216973Z
52 | ----field----
53 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
54 | name: __Updated by
55 | key: __updated by
56 | content-length: 14
57 |
58 | sitecore\admin
59 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Food/Nutrition.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {E8479274-F80D-4C1B-B5EB-01DF2B84F41F}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Food/Nutrition
6 | parent: {7196E22C-0B26-4539-BAEE-959ED8C5BFE5}
7 | name: Nutrition
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {E269FBB5-3750-427A-9149-7AA950B49301}
10 | templatekey: Template section
11 |
12 | ----version----
13 | language: en
14 | version: 1
15 | revision: b65eaa76-e779-4f6b-aa33-a2baa7f89171
16 |
17 | ----field----
18 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
19 | name: __Created
20 | key: __created
21 | content-length: 16
22 |
23 | 20150224T175820Z
24 | ----field----
25 | field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}
26 | name: __Created by
27 | key: __created by
28 | content-length: 14
29 |
30 | sitecore\admin
31 | ----field----
32 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
33 | name: __Revision
34 | key: __revision
35 | content-length: 36
36 |
37 | b65eaa76-e779-4f6b-aa33-a2baa7f89171
38 | ----field----
39 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
40 | name: __Updated
41 | key: __updated
42 | content-length: 35
43 |
44 | 20150224T175933:635603975738522588Z
45 | ----field----
46 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
47 | name: __Updated by
48 | key: __updated by
49 | content-length: 14
50 |
51 | sitecore\admin
52 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Food/Nutrition/Calories.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {3F57B9D2-50EC-4F87-8631-2334C837D5BF}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Food/Nutrition/Calories
6 | parent: {E8479274-F80D-4C1B-B5EB-01DF2B84F41F}
7 | name: Calories
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {455A3E98-A627-4B40-8035-E683A0331AC7}
10 | templatekey: Template field
11 |
12 | ----field----
13 | field: {AB162CC0-DC80-4ABF-8871-998EE5D7BA32}
14 | name: Type
15 | key: type
16 | content-length: 6
17 |
18 | Number
19 | ----field----
20 | field: {BE351A73-FCB0-4213-93FA-C302D8AB4F51}
21 | name: Shared
22 | key: shared
23 | content-length: 1
24 |
25 | 1
26 | ----field----
27 | field: {BA3F86A2-4A1C-4D78-B63D-91C2779C1B5E}
28 | name: __Sortorder
29 | key: __sortorder
30 | content-length: 3
31 |
32 | 100
33 | ----version----
34 | language: en
35 | version: 1
36 | revision: f65defbe-3613-44e9-90e4-bd642f5a2cab
37 |
38 | ----field----
39 | field: {19A69332-A23E-4E70-8D16-B2640CB24CC8}
40 | name: Title
41 | key: title
42 | content-length: 30
43 |
44 | How many calories per serving?
45 | ----field----
46 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
47 | name: __Created
48 | key: __created
49 | content-length: 16
50 |
51 | 20150224T175820Z
52 | ----field----
53 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
54 | name: __Revision
55 | key: __revision
56 | content-length: 36
57 |
58 | f65defbe-3613-44e9-90e4-bd642f5a2cab
59 | ----field----
60 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
61 | name: __Updated
62 | key: __updated
63 | content-length: 35
64 |
65 | 20150224T180748:635603980688412603Z
66 | ----field----
67 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
68 | name: __Updated by
69 | key: __updated by
70 | content-length: 14
71 |
72 | sitecore\admin
73 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Nameable.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {2852DE45-BF36-44D8-9435-8A30EC6923C5}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Nameable
6 | parent: {84521828-EDDC-47B3-BF39-781EE10A6A74}
7 | name: Nameable
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {AB86861A-6030-46C5-B394-E8F99E8B87DB}
10 | templatekey: Template
11 |
12 | ----field----
13 | field: {12C33F3F-86C5-43A5-AEB4-5598CEC45116}
14 | name: __Base template
15 | key: __base template
16 | content-length: 38
17 |
18 | {1930BBEB-7805-471A-A3BE-4858AC7CF696}
19 | ----version----
20 | language: en
21 | version: 1
22 | revision: 1edeccc2-9c12-439d-b5e1-b97735c52a33
23 |
24 | ----field----
25 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
26 | name: __Created
27 | key: __created
28 | content-length: 16
29 |
30 | 20150224T174806Z
31 | ----field----
32 | field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}
33 | name: __Created by
34 | key: __created by
35 | content-length: 14
36 |
37 | sitecore\admin
38 | ----field----
39 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
40 | name: __Revision
41 | key: __revision
42 | content-length: 36
43 |
44 | 1edeccc2-9c12-439d-b5e1-b97735c52a33
45 | ----field----
46 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
47 | name: __Updated
48 | key: __updated
49 | content-length: 35
50 |
51 | 20150224T175743:635603974638186598Z
52 | ----field----
53 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
54 | name: __Updated by
55 | key: __updated by
56 | content-length: 14
57 |
58 | sitecore\admin
59 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Nameable/Name.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {B35A500E-1CD2-4A61-BD6F-887D7EDC7718}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Nameable/Name
6 | parent: {2852DE45-BF36-44D8-9435-8A30EC6923C5}
7 | name: Name
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {E269FBB5-3750-427A-9149-7AA950B49301}
10 | templatekey: Template section
11 |
12 | ----version----
13 | language: en
14 | version: 1
15 | revision: 43caafd7-4496-4e21-b3f0-d89a8ec834bc
16 |
17 | ----field----
18 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
19 | name: __Created
20 | key: __created
21 | content-length: 16
22 |
23 | 20150224T174821Z
24 | ----field----
25 | field: {5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}
26 | name: __Created by
27 | key: __created by
28 | content-length: 14
29 |
30 | sitecore\admin
31 | ----field----
32 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
33 | name: __Revision
34 | key: __revision
35 | content-length: 36
36 |
37 | 43caafd7-4496-4e21-b3f0-d89a8ec834bc
38 | ----field----
39 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
40 | name: __Updated
41 | key: __updated
42 | content-length: 35
43 |
44 | 20150224T174821:635603969014652483Z
45 | ----field----
46 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
47 | name: __Updated by
48 | key: __updated by
49 | content-length: 14
50 |
51 | sitecore\admin
52 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Data/serialization/master/sitecore/templates/Sitecore Code Generator Sample/Nameable/Name/Name.item:
--------------------------------------------------------------------------------
1 | ----item----
2 | version: 1
3 | id: {7E4FAA48-E6CE-46B7-888E-309B5FCC4107}
4 | database: master
5 | path: /sitecore/templates/Sitecore Code Generator Sample/Nameable/Name/Name
6 | parent: {B35A500E-1CD2-4A61-BD6F-887D7EDC7718}
7 | name: Name
8 | master: {00000000-0000-0000-0000-000000000000}
9 | template: {455A3E98-A627-4B40-8035-E683A0331AC7}
10 | templatekey: Template field
11 |
12 | ----field----
13 | field: {AB162CC0-DC80-4ABF-8871-998EE5D7BA32}
14 | name: Type
15 | key: type
16 | content-length: 16
17 |
18 | Single-Line Text
19 | ----field----
20 | field: {BA3F86A2-4A1C-4D78-B63D-91C2779C1B5E}
21 | name: __Sortorder
22 | key: __sortorder
23 | content-length: 3
24 |
25 | 100
26 | ----version----
27 | language: en
28 | version: 1
29 | revision: bfb01b9d-74d8-43ce-9438-3af2021d2e4e
30 |
31 | ----field----
32 | field: {25BED78C-4957-4165-998A-CA1B52F67497}
33 | name: __Created
34 | key: __created
35 | content-length: 16
36 |
37 | 20150224T174821Z
38 | ----field----
39 | field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
40 | name: __Revision
41 | key: __revision
42 | content-length: 36
43 |
44 | bfb01b9d-74d8-43ce-9438-3af2021d2e4e
45 | ----field----
46 | field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
47 | name: __Updated
48 | key: __updated
49 | content-length: 35
50 |
51 | 20150224T174821:635603969014892787Z
52 | ----field----
53 | field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
54 | name: __Updated by
55 | key: __updated by
56 | content-length: 14
57 |
58 | sitecore\admin
59 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Models/GlassGenerator.tt:
--------------------------------------------------------------------------------
1 | <#@ assembly name="$(SolutionDir)Sitecore.CodeGenerator\bin\Debug\Sitecore.CodeGenerator.dll" #>
2 | <#@ assembly name="$(SolutionDir)Lib\Sitecore.Kernel.DLL" #>
3 | <#@ assembly name="$(ProjectDir)bin\Debug\Glass.Mapper.Sc.DLL" #>
4 | <#@ import namespace="Sitecore.CodeGenerator" #>
5 | <#@ import namespace="System.Collections.Generic" #>
6 | <#@ import namespace="Glass.Mapper.Sc.Fields" #>
7 | <#@ include file="GlassMappedClassTemplate.tt" #>
8 | <#+
9 | //
10 | // Copyright © . All Rights Reserved.
11 | //
12 |
13 | public class FieldOptions
14 | {
15 | public string GlassFieldTypeName { get; set; }
16 | public string AttributeExtras { get; set; }
17 | }
18 |
19 | public class GlassGenerator : Generator
20 | {
21 | public GlassMappedClassTemplate GlassTemplate { get; private set; }
22 |
23 | private Action SetCustomOptionsFunction { get; set; }
24 |
25 | private string Database { get; set; }
26 | private string[] Paths { get; set; }
27 |
28 | public List GeneratedFiles { get; private set; }
29 |
30 | public GlassGenerator(string database, string[] paths, Action setCustomOptionsFunction)
31 | {
32 | SetCustomOptionsFunction = setCustomOptionsFunction;
33 | Database = database;
34 | Paths = paths;
35 | this.GeneratedFiles = new List();
36 | }
37 |
38 | protected override void RunCore()
39 | {
40 | // If you are using Rainbow serialization, you need to make some changes to the following lines
41 | // This is described on https://github.com/hermanussen/sitecore.codegenerator#using-unicorns-rainbow-format
42 | this.GlassTemplate = new GlassMappedClassTemplate();
43 | var resolver = new TemplatesResolver(
44 | Context.Host.ResolvePath(@"..\Data\serialization\"),
45 | Paths,
46 | Database);
47 | foreach(var template in resolver.Templates)
48 | {
49 | this.GlassTemplate.Template = template;
50 | this.GlassTemplate.GetFieldOptionsFunction = GetFieldOptions;
51 | string fileName = string.Concat("I", this.GlassTemplate.Identifier(template.SyncItem.Name), ".gen.cs");
52 | this.GlassTemplate.RenderToFile(fileName);
53 | this.GeneratedFiles.Add(fileName);
54 | }
55 | }
56 |
57 | public FieldOptions GetFieldOptions(string fieldType, string fieldId)
58 | {
59 | FieldOptions result = new FieldOptions();
60 | switch (fieldType)
61 | {
62 | case "Checkbox":
63 | result.GlassFieldTypeName = "bool";
64 | break;
65 | case "Integer":
66 | result.GlassFieldTypeName = "int";
67 | break;
68 | case "Number":
69 | result.GlassFieldTypeName = typeof(Decimal).Name;
70 | break;
71 | case "Date":
72 | case "Datetime":
73 | result.GlassFieldTypeName = typeof(DateTime).Name;
74 | break;
75 | case "File":
76 | case "File Drop Area":
77 | result.GlassFieldTypeName = typeof(File).Name;
78 | break;
79 | case "Name Value List":
80 | case "Name Lookup Value List":
81 | result.GlassFieldTypeName = typeof(System.Collections.Specialized.NameValueCollection).Name;
82 | break;
83 | // case "???": result.GlassFieldTypeName = typeof(HtmlEncodedString).Name; break;
84 | case "Image":
85 | result.GlassFieldTypeName = typeof(Image).Name;
86 | break;
87 | case "Droplink":
88 | case "Droptree":
89 | case "General Link":
90 | case "General Link with Search":
91 | case "Version Link":
92 | case "link":
93 | result.GlassFieldTypeName = typeof(Link).Name;
94 | break;
95 | // case "???": result.GlassFieldTypeName = typeof(LinkType).Name; break;
96 | case "Tristate":
97 | result.GlassFieldTypeName = typeof(TriState).Name;
98 | break;
99 | default:
100 | result.GlassFieldTypeName = "string";
101 | break;
102 | }
103 | SetCustomOptionsFunction(fieldId, result);
104 | return result;
105 | }
106 | }
107 | #>
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Models/GlassMappedClassTemplate.tt:
--------------------------------------------------------------------------------
1 | <#@ assembly name="System.Core" #>
2 | <#@ assembly name="$(SolutionDir)Lib\Sitecore.Kernel.DLL" #>
3 | <#@ import namespace="Sitecore.CodeGenerator.Domain" #>
4 | <#@ import namespace="System.Linq" #>
5 | <#+
6 | public class GlassMappedClassTemplate : CSharpTemplate
7 | {
8 | public TemplateItem Template { get; set; }
9 |
10 | public Func GetFieldOptionsFunction { get; set; }
11 |
12 | private string Extends { get; set; }
13 |
14 | public override string TransformText()
15 | {
16 | this.Extends = string.Empty;
17 | if(this.Template.BaseTemplates.Any())
18 | {
19 | this.Extends = string.Concat(" : ", string.Join(", ", this.Template.BaseTemplates.Select(b => string.Concat("I", Identifier(b.SyncItem.Name)))));
20 | }
21 | else
22 | {
23 | this.Extends = string.Empty; //" : IModelBase";
24 | }
25 |
26 | base.TransformText();
27 | #>
28 | namespace <#= DefaultNamespace #>
29 | {
30 | using System;
31 | using System.Collections.Generic;
32 | using System.Collections.Specialized;
33 | using global::Glass.Mapper.Sc.Configuration;
34 | using global::Glass.Mapper.Sc.Configuration.Attributes;
35 | using global::Glass.Mapper.Sc.Fields;
36 |
37 | ///
38 | /// Represents a mapped type for item <#= Template.SyncItem.ID #> in Sitecore.
39 | /// Path: <#= Template.SyncItem.ItemPath #>
40 | ///
41 | [SitecoreType(TemplateId = "<#= Template.SyncItem.ID #>")]
42 | public partial interface I<#=Identifier(Template.SyncItem.Name)#><#=Extends#>
43 | {
44 | <#+
45 | foreach(var section in Template.Sections)
46 | {
47 | #>
48 | #region <#=section.SyncItem.Name#>
49 |
50 | <#+
51 | foreach(var field in section.Fields)
52 | {
53 | var fieldOptions = GetFieldOptionsFunction(field.FieldTypeName, field.SyncItem.ID);
54 | if(! string.IsNullOrWhiteSpace(field.FieldTitle))
55 | {
56 | #>
57 | ///
58 | /// <#=field.FieldTitle#>
59 | ///
60 | <#+
61 | }
62 | #>
63 | [SitecoreField(FieldId = "<#=field.SyncItem.ID#>"<#=fieldOptions.AttributeExtras ?? string.Empty #>)]
64 | <#=fieldOptions.GlassFieldTypeName#> <#=Identifier(field.SyncItem.Name)#> { get; set; }
65 |
66 | <#+
67 | }
68 | #>
69 | #endregion
70 |
71 | <#+
72 | }
73 | #>
74 | }
75 | }
76 | <#+
77 | return this.GenerationEnvironment.ToString();
78 | }
79 | }
80 | #>
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Models/IAnimal.gen.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by T4 code generator SampleScriptTemplates.tt.
3 | // Any changes made to this file manually will be lost next time the file is regenerated.
4 | //
5 |
6 | namespace Sitecore.CodeGenerator.Sample.Glass.Models
7 | {
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Collections.Specialized;
11 | using global::Glass.Mapper.Sc.Configuration;
12 | using global::Glass.Mapper.Sc.Configuration.Attributes;
13 | using global::Glass.Mapper.Sc.Fields;
14 |
15 | ///
16 | /// Represents a mapped type for item {319EB0A2-EF28-4DAE-B35C-551BD53317B2} in Sitecore.
17 | /// Path: /sitecore/templates/Sitecore Code Generator Sample/Animal
18 | ///
19 | [SitecoreType(TemplateId = "{319EB0A2-EF28-4DAE-B35C-551BD53317B2}")]
20 | public partial interface IAnimal
21 | {
22 | #region Animal
23 |
24 | ///
25 | /// A short description of the animal
26 | ///
27 | [SitecoreField(FieldId = "{EDFD61C6-BBEF-45B6-8FD4-84CA215BAB73}")]
28 | string Description { get; set; }
29 |
30 | #endregion
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Models/IDog.gen.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by T4 code generator SampleScriptTemplates.tt.
3 | // Any changes made to this file manually will be lost next time the file is regenerated.
4 | //
5 |
6 | namespace Sitecore.CodeGenerator.Sample.Glass.Models
7 | {
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Collections.Specialized;
11 | using global::Glass.Mapper.Sc.Configuration;
12 | using global::Glass.Mapper.Sc.Configuration.Attributes;
13 | using global::Glass.Mapper.Sc.Fields;
14 |
15 | ///
16 | /// Represents a mapped type for item {F4A0D5D5-49F9-488F-82AA-D4BE1ADCB662} in Sitecore.
17 | /// Path: /sitecore/templates/Sitecore Code Generator Sample/Dog
18 | ///
19 | [SitecoreType(TemplateId = "{F4A0D5D5-49F9-488F-82AA-D4BE1ADCB662}")]
20 | public partial interface IDog : IAnimal, INameable
21 | {
22 | #region Dog
23 |
24 | ///
25 | /// What food does the dog eat?
26 | ///
27 | [SitecoreField(FieldId = "{1033D7C1-9C1A-4C65-8316-81B6D5E46EB5}")]
28 | IEnumerable Eats { get; set; }
29 |
30 | ///
31 | /// Other dogs that this dog likes
32 | ///
33 | [SitecoreField(FieldId = "{20D7789D-BCE0-473E-BB46-59B216CE2C10}", Setting = SitecoreFieldSettings.DontLoadLazily)]
34 | IEnumerable Friends { get; set; }
35 |
36 | #endregion
37 |
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Models/IFood.gen.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by T4 code generator SampleScriptTemplates.tt.
3 | // Any changes made to this file manually will be lost next time the file is regenerated.
4 | //
5 |
6 | namespace Sitecore.CodeGenerator.Sample.Glass.Models
7 | {
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Collections.Specialized;
11 | using global::Glass.Mapper.Sc.Configuration;
12 | using global::Glass.Mapper.Sc.Configuration.Attributes;
13 | using global::Glass.Mapper.Sc.Fields;
14 |
15 | ///
16 | /// Represents a mapped type for item {7196E22C-0B26-4539-BAEE-959ED8C5BFE5} in Sitecore.
17 | /// Path: /sitecore/templates/Sitecore Code Generator Sample/Food
18 | ///
19 | [SitecoreType(TemplateId = "{7196E22C-0B26-4539-BAEE-959ED8C5BFE5}")]
20 | public partial interface IFood
21 | {
22 | #region Nutrition
23 |
24 | ///
25 | /// How many calories per serving?
26 | ///
27 | [SitecoreField(FieldId = "{3F57B9D2-50EC-4F87-8631-2334C837D5BF}")]
28 | Decimal Calories { get; set; }
29 |
30 | #endregion
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Models/INameable.gen.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This file was generated by T4 code generator SampleScriptTemplates.tt.
3 | // Any changes made to this file manually will be lost next time the file is regenerated.
4 | //
5 |
6 | namespace Sitecore.CodeGenerator.Sample.Glass.Models
7 | {
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Collections.Specialized;
11 | using global::Glass.Mapper.Sc.Configuration;
12 | using global::Glass.Mapper.Sc.Configuration.Attributes;
13 | using global::Glass.Mapper.Sc.Fields;
14 |
15 | ///
16 | /// Represents a mapped type for item {2852DE45-BF36-44D8-9435-8A30EC6923C5} in Sitecore.
17 | /// Path: /sitecore/templates/Sitecore Code Generator Sample/Nameable
18 | ///
19 | [SitecoreType(TemplateId = "{2852DE45-BF36-44D8-9435-8A30EC6923C5}")]
20 | public partial interface INameable
21 | {
22 | #region Name
23 |
24 | [SitecoreField(FieldId = "{7E4FAA48-E6CE-46B7-888E-309B5FCC4107}")]
25 | string Name { get; set; }
26 |
27 | #endregion
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Models/SampleScriptTemplates.gen.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | These files were generated:
4 | - IAnimal.gen.cs
5 | - IDog.gen.cs
6 | - IFood.gen.cs
7 | - INameable.gen.cs
8 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Models/SampleScriptTemplates.tt:
--------------------------------------------------------------------------------
1 | <#@ template language="C#" debug="True" #>
2 | <#@ output extension="gen.txt" #>
3 | <#@ include file="T4Toolbox.tt" #>
4 | <#@ include file="GlassGenerator.tt" #>
5 | <#
6 | GlassGenerator generator = new GlassGenerator(
7 | "master",
8 | new [] { "/sitecore/templates/Sitecore Code Generator Sample" },
9 | (fieldId, fieldOptions) =>
10 | {
11 | // Add custom options, like setting the return type of a field property explicitly
12 |
13 | // Dog -> Food
14 | if("{1033D7C1-9C1A-4C65-8316-81B6D5E46EB5}".Equals(fieldId))
15 | {
16 | fieldOptions.GlassFieldTypeName = "IEnumerable";
17 | }
18 |
19 | // Dog -> Dog's friends
20 | if("{20D7789D-BCE0-473E-BB46-59B216CE2C10}".Equals(fieldId))
21 | {
22 | fieldOptions.GlassFieldTypeName = "IEnumerable";
23 | fieldOptions.AttributeExtras = ", Setting = SitecoreFieldSettings.DontLoadLazily";
24 | }
25 | });
26 | generator.Run();
27 |
28 | WriteLine("These files were generated:");
29 | foreach(var file in generator.GeneratedFiles)
30 | {
31 | WriteLine(string.Concat("- ", file));
32 | }
33 | #>
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2017 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System.Reflection;
18 | using System.Runtime.CompilerServices;
19 | using System.Runtime.InteropServices;
20 |
21 | // General Information about an assembly is controlled through the following
22 | // set of attributes. Change these attribute values to modify the information
23 | // associated with an assembly.
24 | [assembly: AssemblyTitle("Sitecore.CodeGenerator.Sample.Glass")]
25 | [assembly: AssemblyDescription("")]
26 | [assembly: AssemblyConfiguration("")]
27 | [assembly: AssemblyCompany("")]
28 | [assembly: AssemblyProduct("Sitecore.CodeGenerator.Sample.Glass")]
29 | [assembly: AssemblyCopyright("Copyright © 2015")]
30 | [assembly: AssemblyTrademark("")]
31 | [assembly: AssemblyCulture("")]
32 |
33 | // Setting ComVisible to false makes the types in this assembly not visible
34 | // to COM components. If you need to access a type in this assembly from
35 | // COM, set the ComVisible attribute to true on that type.
36 | [assembly: ComVisible(false)]
37 |
38 | // The following GUID is for the ID of the typelib if this project is exposed to COM
39 | [assembly: Guid("a3cf114a-c056-4838-afc4-a59c31ece210")]
40 |
41 | // Version information for an assembly consists of the following four values:
42 | //
43 | // Major Version
44 | // Minor Version
45 | // Build Number
46 | // Revision
47 | //
48 | // You can specify all the values or you can default the Build and Revision Numbers
49 | // by using the '*' as shown below:
50 | // [assembly: AssemblyVersion("1.0.*")]
51 | [assembly: AssemblyVersion("1.2.0.0")]
52 | [assembly: AssemblyFileVersion("1.2.0.0")]
53 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/Sitecore.CodeGenerator.Sample.Glass.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {192E52C3-52AB-4072-8B73-626B57ECC2C8}
8 | Library
9 | Properties
10 | Sitecore.CodeGenerator.Sample.Glass
11 | Sitecore.CodeGenerator.Sample.Glass
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\packages\Castle.Core.1.1.0\lib\Castle.Core.dll
35 |
36 |
37 | ..\packages\BoC.Glass.Mapper.1.0.3\lib\net45\Glass.Mapper.dll
38 |
39 |
40 | ..\packages\BoC.Glass.Mapper.Sc.1.0.3\lib\net45\Glass.Mapper.Sc.dll
41 |
42 |
43 | ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | SampleScriptTemplates.tt
56 |
57 |
58 | SampleScriptTemplates.tt
59 |
60 |
61 | SampleScriptTemplates.tt
62 |
63 |
64 | SampleScriptTemplates.tt
65 |
66 |
67 |
68 |
69 |
70 |
71 | TextTemplatingFileGenerator
72 | SampleScriptTemplates.gen.txt
73 |
74 | .\IAnimal.gen.cs
75 | .\IDog.gen.cs
76 | .\IFood.gen.cs
77 | .\INameable.gen.cs
78 | .\SampleScriptTemplates.gen.txt
79 |
80 |
81 |
82 | GlassGenerator.cs
83 |
84 |
85 | GlassMappedClassTemplate.cs
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | True
97 | True
98 | SampleScriptTemplates.tt
99 |
100 |
101 |
102 |
109 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Sample.Glass/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Tests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2015 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System.Reflection;
18 | using System.Runtime.CompilerServices;
19 | using System.Runtime.InteropServices;
20 |
21 | // General Information about an assembly is controlled through the following
22 | // set of attributes. Change these attribute values to modify the information
23 | // associated with an assembly.
24 | [assembly: AssemblyTitle("Sitecore.CodeGenerator.Tests")]
25 | [assembly: AssemblyDescription("")]
26 | [assembly: AssemblyConfiguration("")]
27 | [assembly: AssemblyCompany("")]
28 | [assembly: AssemblyProduct("Sitecore.CodeGenerator.Tests")]
29 | [assembly: AssemblyCopyright("Copyright © Robin Hermanussen 2015")]
30 | [assembly: AssemblyTrademark("")]
31 | [assembly: AssemblyCulture("")]
32 |
33 | // Setting ComVisible to false makes the types in this assembly not visible
34 | // to COM components. If you need to access a type in this assembly from
35 | // COM, set the ComVisible attribute to true on that type.
36 | [assembly: ComVisible(false)]
37 |
38 | // The following GUID is for the ID of the typelib if this project is exposed to COM
39 | [assembly: Guid("9a5648e9-6b43-4888-b336-f79773a6d241")]
40 |
41 | // Version information for an assembly consists of the following four values:
42 | //
43 | // Major Version
44 | // Minor Version
45 | // Build Number
46 | // Revision
47 | //
48 | // You can specify all the values or you can default the Build and Revision Numbers
49 | // by using the '*' as shown below:
50 | // [assembly: AssemblyVersion("1.0.*")]
51 | [assembly: AssemblyVersion("1.2.0.0")]
52 | [assembly: AssemblyFileVersion("1.2.0.0")]
53 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Tests/Sitecore.CodeGenerator.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {06BBCA34-A007-4651-80B7-6A65636C3D25}
8 | Library
9 | Properties
10 | Sitecore.CodeGenerator.Tests
11 | Sitecore.CodeGenerator.Tests
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\packages\FluentAssertions.3.3.0\lib\net45\FluentAssertions.dll
35 |
36 |
37 | ..\packages\FluentAssertions.3.3.0\lib\net45\FluentAssertions.Core.dll
38 |
39 |
40 | ..\packages\NUnit.2.6.4\lib\nunit.framework.dll
41 |
42 |
43 | ..\Lib\Sitecore.Kernel.dll
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | {97696946-cfed-49db-ab8d-53431e48e3da}
64 | Sitecore.CodeGenerator
65 |
66 |
67 |
68 |
75 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Tests/TemplatesResolverRainbowTest.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2016 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System.Linq;
18 | using FluentAssertions;
19 | using NUnit.Framework;
20 | using Sitecore.CodeGenerator.Domain;
21 |
22 | namespace Sitecore.CodeGenerator.Tests
23 | {
24 | using System.IO;
25 |
26 | public class TemplatesResolverRainbowTest
27 | {
28 | [Test]
29 | public void ShouldResolveTemplates()
30 | {
31 | var resolver = new TemplatesResolverRainbow(
32 | @"..\..\..\Sitecore.CodeGenerator.Sample.Glass\Data\Unicorn", new[] { "/sitecore/templates" });
33 | AssertTemplates(resolver);
34 | }
35 |
36 | [Test]
37 | public void ShouldResolveTemplatesFromProject()
38 | {
39 | DirectoryInfo serializationFolder = new DirectoryInfo(@"..\..\..\Sitecore.CodeGenerator.Scripty.Sample.Glass\Data\Unicorn");
40 | serializationFolder.Exists.Should().BeTrue();
41 | var files = serializationFolder.GetFiles("*.yml", SearchOption.AllDirectories);
42 | files.Length.ShouldBeEquivalentTo(14);
43 | var resolver = new TemplatesResolverRainbow(files.Select(f => f.FullName).ToList());
44 | AssertTemplates(resolver);
45 | }
46 |
47 | private static void AssertTemplates(TemplatesResolverRainbow resolver)
48 | {
49 | resolver.Templates.Select(t => t.SyncItem.Name).ShouldAllBeEquivalentTo(new[]
50 | {
51 | "Animal",
52 | "Dog",
53 | "Food",
54 | "Nameable"
55 | });
56 |
57 | TemplateItem dogTemplate = resolver.Templates.FirstOrDefault(t => t.SyncItem.Name == "Dog");
58 | dogTemplate.Should().NotBeNull();
59 | dogTemplate.BaseTemplates.Select(b => b.SyncItem.Name).ShouldAllBeEquivalentTo(new[]
60 | {
61 | "Animal",
62 | "Nameable"
63 | });
64 |
65 | TemplateSection dogSection = dogTemplate.Sections.FirstOrDefault(s => s.SyncItem.Name == "Dog");
66 | dogSection.Should().NotBeNull();
67 |
68 | dogSection.Fields.Select(f => f.SyncItem.Name).ShouldAllBeEquivalentTo(new[]
69 | {
70 | "Eats",
71 | "Friends"
72 | });
73 | TemplateField eatsField = dogSection.Fields.FirstOrDefault(f => f.SyncItem.Name == "Eats");
74 | eatsField.Should().NotBeNull();
75 | eatsField.FieldTitle.Should().BeEquivalentTo("What food does the dog eat?");
76 | eatsField.FieldTypeName.Should().BeEquivalentTo("Multilist with Search");
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Tests/TemplatesResolverTest.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2015 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System.Linq;
18 | using FluentAssertions;
19 | using NUnit.Framework;
20 | using Sitecore.CodeGenerator.Domain;
21 |
22 | namespace Sitecore.CodeGenerator.Tests
23 | {
24 | public class TemplatesResolverTest
25 | {
26 | [Test]
27 | public void ShouldResolveTemplates()
28 | {
29 | var resolver = new TemplatesResolver(
30 | @"..\..\..\Sitecore.CodeGenerator.Sample.Glass\Data\Serialization", new [] { "/sitecore/templates" });
31 | resolver.Templates.Select(t => t.SyncItem.Name).ShouldAllBeEquivalentTo(new []
32 | {
33 | "Animal",
34 | "Dog",
35 | "Food",
36 | "Nameable"
37 | });
38 |
39 | TemplateItem dogTemplate = resolver.Templates.FirstOrDefault(t => t.SyncItem.Name == "Dog");
40 | dogTemplate.Should().NotBeNull();
41 | dogTemplate.BaseTemplates.Select(b => b.SyncItem.Name).ShouldAllBeEquivalentTo(new []
42 | {
43 | "Animal",
44 | "Nameable"
45 | });
46 |
47 | TemplateSection dogSection = dogTemplate.Sections.FirstOrDefault(s => s.SyncItem.Name == "Dog");
48 | dogSection.Should().NotBeNull();
49 |
50 | dogSection.Fields.Select(f => f.SyncItem.Name).ShouldAllBeEquivalentTo(new []
51 | {
52 | "Eats",
53 | "Friends"
54 | });
55 | TemplateField eatsField = dogSection.Fields.FirstOrDefault(f => f.SyncItem.Name == "Eats");
56 | eatsField.Should().NotBeNull();
57 | eatsField.FieldTitle.Should().BeEquivalentTo("What food does the dog eat?");
58 | eatsField.FieldTypeName.Should().BeEquivalentTo("Multilist with Search");
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26403.3
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitecore.CodeGenerator", "Sitecore.CodeGenerator\Sitecore.CodeGenerator.csproj", "{97696946-CFED-49DB-AB8D-53431E48E3DA}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitecore.CodeGenerator.Sample.Glass", "Sitecore.CodeGenerator.Sample.Glass\Sitecore.CodeGenerator.Sample.Glass.csproj", "{192E52C3-52AB-4072-8B73-626B57ECC2C8}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitecore.CodeGenerator.Tests", "Sitecore.CodeGenerator.Tests\Sitecore.CodeGenerator.Tests.csproj", "{06BBCA34-A007-4651-80B7-6A65636C3D25}"
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D1325D99-CB4B-4612-B57E-26FDDAC6C445}"
13 | ProjectSection(SolutionItems) = preProject
14 | .nuget\packages.config = .nuget\packages.config
15 | EndProjectSection
16 | EndProject
17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitecore.Codegenerator.Scripty.Sample.Glass", "Sitecore.Codegenerator.Scripty.Sample.Glass\Sitecore.Codegenerator.Scripty.Sample.Glass.csproj", "{235EB204-526E-4941-8EC0-04FDAB755FFE}"
18 | EndProject
19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitecore.Codegenerator.Scripty", "Sitecore.Codegenerator.Scripty\Sitecore.Codegenerator.Scripty.csproj", "{35439BDB-2B65-4F12-B6EB-83FE8FD99BD8}"
20 | EndProject
21 | Global
22 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
23 | Debug|Any CPU = Debug|Any CPU
24 | Release|Any CPU = Release|Any CPU
25 | EndGlobalSection
26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
27 | {97696946-CFED-49DB-AB8D-53431E48E3DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28 | {97696946-CFED-49DB-AB8D-53431E48E3DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
29 | {97696946-CFED-49DB-AB8D-53431E48E3DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {97696946-CFED-49DB-AB8D-53431E48E3DA}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {192E52C3-52AB-4072-8B73-626B57ECC2C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32 | {192E52C3-52AB-4072-8B73-626B57ECC2C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
33 | {192E52C3-52AB-4072-8B73-626B57ECC2C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {192E52C3-52AB-4072-8B73-626B57ECC2C8}.Release|Any CPU.Build.0 = Release|Any CPU
35 | {06BBCA34-A007-4651-80B7-6A65636C3D25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36 | {06BBCA34-A007-4651-80B7-6A65636C3D25}.Debug|Any CPU.Build.0 = Debug|Any CPU
37 | {06BBCA34-A007-4651-80B7-6A65636C3D25}.Release|Any CPU.ActiveCfg = Release|Any CPU
38 | {06BBCA34-A007-4651-80B7-6A65636C3D25}.Release|Any CPU.Build.0 = Release|Any CPU
39 | {235EB204-526E-4941-8EC0-04FDAB755FFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40 | {235EB204-526E-4941-8EC0-04FDAB755FFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
41 | {235EB204-526E-4941-8EC0-04FDAB755FFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
42 | {235EB204-526E-4941-8EC0-04FDAB755FFE}.Release|Any CPU.Build.0 = Release|Any CPU
43 | {35439BDB-2B65-4F12-B6EB-83FE8FD99BD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
44 | {35439BDB-2B65-4F12-B6EB-83FE8FD99BD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
45 | {35439BDB-2B65-4F12-B6EB-83FE8FD99BD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
46 | {35439BDB-2B65-4F12-B6EB-83FE8FD99BD8}.Release|Any CPU.Build.0 = Release|Any CPU
47 | EndGlobalSection
48 | GlobalSection(SolutionProperties) = preSolution
49 | HideSolutionNode = FALSE
50 | EndGlobalSection
51 | EndGlobal
52 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/Domain/ItemBase.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2015 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System.Linq;
18 | using Sitecore.Data.Serialization.ObjectModel;
19 |
20 | namespace Sitecore.CodeGenerator.Domain
21 | {
22 | ///
23 | /// Represents a deserialized item.
24 | /// Exposes the SyncItem, which can be used to get the contents of the items.
25 | ///
26 | public abstract class ItemBase
27 | {
28 | public ItemBase(SyncItem syncItem)
29 | {
30 | SyncItem = syncItem;
31 | }
32 |
33 | ///
34 | /// The Sitecore SyncItem, which contains all info from the .item file.
35 | ///
36 | public SyncItem SyncItem { get; private set; }
37 |
38 | ///
39 | /// Returns the shared field value, based on the field name.
40 | ///
41 | /// Name of the field
42 | /// If provided, will fallback to this value if no field value is available
43 | /// The field value
44 | public string GetSharedFieldValue(string name, string defaultValue = null)
45 | {
46 | SyncField typeField = SyncItem.SharedFields
47 | .FirstOrDefault(f => name.Equals(f.FieldName));
48 | return typeField != null && ! string.IsNullOrWhiteSpace(typeField.FieldValue)
49 | ? typeField.FieldValue
50 | : defaultValue;
51 | }
52 |
53 | ///
54 | /// Returns the field value in the first version it can find, based on the field name.
55 | ///
56 | /// Name of the field
57 | /// If provided, will fallback to this value if no field value is available
58 | /// The field value
59 | public string GetFieldValue(string name, string defaultValue = null)
60 | {
61 | SyncField typeField = SyncItem.Versions.SelectMany(v => v.Fields)
62 | .FirstOrDefault(f => name.Equals(f.FieldName));
63 | return typeField != null && !string.IsNullOrWhiteSpace(typeField.FieldValue)
64 | ? typeField.FieldValue
65 | : defaultValue;
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/Domain/TemplateField.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2015 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System;
18 | using System.Collections.Generic;
19 | using System.Linq;
20 | using System.Text;
21 | using System.Threading.Tasks;
22 | using Sitecore.Data;
23 | using Sitecore.Data.Serialization.ObjectModel;
24 |
25 | namespace Sitecore.CodeGenerator.Domain
26 | {
27 | ///
28 | /// Represents a deserialized template field.
29 | ///
30 | public class TemplateField : ItemBase
31 | {
32 | ///
33 | /// Field type as selected for the template field.
34 | ///
35 | public string FieldTypeName { get; private set; }
36 |
37 | ///
38 | /// Title information for the field, which might be used for rendering comments.
39 | ///
40 | public string FieldTitle { get; private set; }
41 |
42 | public TemplateField(SyncItem fieldItem)
43 | : base(fieldItem)
44 | {
45 | FieldTypeName = GetSharedFieldValue("Type", "(unknown)");
46 | FieldTitle = GetFieldValue("Title");
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/Domain/TemplateItem.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2015 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using Sitecore.Data.Serialization.ObjectModel;
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Text;
22 | using System.Threading.Tasks;
23 |
24 | namespace Sitecore.CodeGenerator.Domain
25 | {
26 | ///
27 | /// Represents a deserialized template item.
28 | ///
29 | public class TemplateItem : ItemBase
30 | {
31 | ///
32 | /// All sections within the template, excluding inherited ones.
33 | ///
34 | public List Sections { get; private set; }
35 |
36 | ///
37 | /// Direct base templates for the current template.
38 | ///
39 | public List BaseTemplates { get; private set; }
40 |
41 | public TemplateItem(SyncItem templateItem, List syncItems)
42 | : base(templateItem)
43 | {
44 | BaseTemplates = new List();
45 | Sections = syncItems
46 | .Where(s => s.TemplateID == TemplateIDs.TemplateSection.ToString() && s.ParentID == templateItem.ID)
47 | .Select(s => new TemplateSection(s, syncItems))
48 | .ToList();
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/Domain/TemplateSection.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2015 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System;
18 | using System.Collections.Generic;
19 | using System.Linq;
20 | using System.Text;
21 | using System.Threading.Tasks;
22 | using Sitecore.Data.Serialization.ObjectModel;
23 |
24 | namespace Sitecore.CodeGenerator.Domain
25 | {
26 | ///
27 | /// Represents a deserialized template section.
28 | ///
29 | public class TemplateSection : ItemBase
30 | {
31 | ///
32 | /// The fields within this template section.
33 | ///
34 | public List Fields { get; private set; }
35 |
36 | public TemplateSection(SyncItem sectionItem, List syncItems)
37 | : base(sectionItem)
38 | {
39 | Fields = syncItems
40 | .Where(s => s.TemplateID == TemplateIDs.TemplateField.ToString() && s.ParentID == sectionItem.ID)
41 | .Select(s => new TemplateField(s))
42 | .ToList();
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2015 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System.Reflection;
18 | using System.Runtime.CompilerServices;
19 | using System.Runtime.InteropServices;
20 |
21 | // General Information about an assembly is controlled through the following
22 | // set of attributes. Change these attribute values to modify the information
23 | // associated with an assembly.
24 | [assembly: AssemblyTitle("Sitecore.CodeGenerator")]
25 | [assembly: AssemblyDescription("")]
26 | [assembly: AssemblyConfiguration("")]
27 | [assembly: AssemblyCompany("")]
28 | [assembly: AssemblyProduct("Sitecore.CodeGenerator")]
29 | [assembly: AssemblyCopyright("Copyright © Robin Hermanussen 2015")]
30 | [assembly: AssemblyTrademark("")]
31 | [assembly: AssemblyCulture("")]
32 |
33 | // Setting ComVisible to false makes the types in this assembly not visible
34 | // to COM components. If you need to access a type in this assembly from
35 | // COM, set the ComVisible attribute to true on that type.
36 | [assembly: ComVisible(false)]
37 |
38 | // The following GUID is for the ID of the typelib if this project is exposed to COM
39 | [assembly: Guid("a56702f3-16b0-47d5-8b81-d1af0304e52e")]
40 |
41 | // Version information for an assembly consists of the following four values:
42 | //
43 | // Major Version
44 | // Minor Version
45 | // Build Number
46 | // Revision
47 | //
48 | // You can specify all the values or you can default the Build and Revision Numbers
49 | // by using the '*' as shown below:
50 | // [assembly: AssemblyVersion("1.0.*")]
51 | [assembly: AssemblyVersion("1.2.0.0")]
52 | [assembly: AssemblyFileVersion("1.2.0.0")]
53 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/Serialization/SerializedIdToPathResolver.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2015 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System;
18 | using System.Collections.Generic;
19 | using System.IO;
20 | using System.Linq;
21 | using System.Text;
22 | using System.Threading.Tasks;
23 | using Sitecore.Data;
24 |
25 | namespace Sitecore.CodeGenerator.Serialization
26 | {
27 | ///
28 | /// Find items by ID within serialized data using this class.
29 | /// It caches results, so as to make it perform well.
30 | ///
31 | public static class SerializedIdToPathResolver
32 | {
33 | private static readonly Dictionary _pathSets
34 | = new Dictionary();
35 | public static string FindFilePath(this ID id, DirectoryInfo serializationFolder)
36 | {
37 | lock (_pathSets)
38 | {
39 | // find or create the set of paths for the serialization folder
40 | SerializedIdToPathSet pathSet;
41 | if (_pathSets.ContainsKey(serializationFolder.FullName))
42 | {
43 | pathSet = _pathSets[serializationFolder.FullName];
44 | }
45 | else
46 | {
47 | pathSet = new SerializedIdToPathSet();
48 | pathSet.FilePaths.Push(serializationFolder.FullName);
49 | _pathSets.Add(serializationFolder.FullName, pathSet);
50 | }
51 | // get the individual item if already found
52 | if (pathSet.Paths.ContainsKey(id))
53 | {
54 | return pathSet.Paths[id];
55 | }
56 | while (pathSet.FilePaths.Any())
57 | {
58 | string filePath = pathSet.FilePaths.Pop();
59 | foreach (string subdirectory in Directory.GetDirectories(filePath))
60 | {
61 | pathSet.FilePaths.Push(subdirectory);
62 | }
63 | string foundFile = null;
64 | foreach (string file in Directory.GetFiles(filePath, "*.item"))
65 | {
66 | using (StreamReader sr = new StreamReader(file))
67 | {
68 | sr.ReadLine();
69 | sr.ReadLine();
70 | string itemIdStr = sr.ReadLine().Substring(4);
71 | if (ID.IsID(itemIdStr))
72 | {
73 | ID itemId = ID.Parse(itemIdStr);
74 | if (!pathSet.Paths.ContainsKey(itemId))
75 | {
76 | pathSet.Paths.Add(itemId, file);
77 | if (itemId == id)
78 | {
79 | foundFile = file;
80 | }
81 | }
82 | }
83 | }
84 | }
85 | if (foundFile != null)
86 | {
87 | return foundFile;
88 | }
89 | }
90 | return null;
91 | }
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/Serialization/SerializedIdToPathSet.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2015 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System;
18 | using System.Collections.Generic;
19 | using System.Linq;
20 | using System.Text;
21 | using System.Threading.Tasks;
22 | using Sitecore.Data;
23 |
24 | namespace Sitecore.CodeGenerator.Serialization
25 | {
26 | ///
27 | /// Holds data for found items within a serialization folder.
28 | ///
29 | internal class SerializedIdToPathSet
30 | {
31 | internal Dictionary Paths { get; set; }
32 | internal Stack FilePaths { get; set; }
33 | internal SerializedIdToPathSet()
34 | {
35 | Paths = new Dictionary();
36 | FilePaths = new Stack();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/Sitecore.CodeGenerator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {97696946-CFED-49DB-AB8D-53431E48E3DA}
8 | Library
9 | Properties
10 | Sitecore.CodeGenerator
11 | Sitecore.CodeGenerator
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 | ..\packages\Rainbow.Core.1.3.1\lib\net45\Rainbow.dll
35 | True
36 |
37 |
38 | ..\packages\Rainbow.Storage.Yaml.1.3.1\lib\net45\Rainbow.Storage.Yaml.dll
39 | True
40 |
41 |
42 | ..\Lib\Sitecore.Kernel.dll
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
75 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/TemplatesResolver.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2015 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | namespace Sitecore.CodeGenerator
18 | {
19 | using Sitecore.Data.Serialization.ObjectModel;
20 | using System;
21 | using System.Collections.Generic;
22 | using System.IO;
23 | using System.Linq;
24 | using Rainbow.Model;
25 |
26 | public class TemplatesResolver : TemplatesResolverBase
27 | {
28 | public TemplatesResolver(
29 | string serializationPath,
30 | string[] includePaths,
31 | string db = "master") : base(serializationPath, includePaths, db)
32 | {
33 | }
34 |
35 | protected override List GetAllItems(DirectoryInfo folder, string db, string[] includePaths)
36 | {
37 | List result = new List();
38 | foreach (FileInfo itemFile in folder.GetFiles("*.item", SearchOption.AllDirectories))
39 | {
40 | using (StreamReader sr = new StreamReader(itemFile.FullName))
41 | {
42 | sr.ReadLine();
43 | sr.ReadLine();
44 | sr.ReadLine();
45 | string dbStr = sr.ReadLine().Substring(10);
46 | if (dbStr != db)
47 | {
48 | continue;
49 | }
50 | string pathStr = sr.ReadLine().Substring(6);
51 | if (! includePaths.Any(p => pathStr.StartsWith(p)))
52 | {
53 | continue;
54 | }
55 | }
56 | try
57 | {
58 | result.Add(this.GetItem(itemFile, null));
59 | }
60 | catch (Exception ex)
61 | {
62 | throw new Exception(string.Format("Unable to deserialize '{0}'", itemFile.FullName), ex);
63 | }
64 | }
65 | return result;
66 | }
67 |
68 | protected override SyncItem GetItem(FileInfo itemFile, Func mustMatch)
69 | {
70 | return SyncItem.ReadItem(new Tokenizer(itemFile.OpenText()));
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/TemplatesResolverBase.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This program is distributed in the hope that it will be useful,
3 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
4 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 | // GNU General Public License for more details.
6 | //
7 | // You should have received a copy of the GNU General Public License
8 | // along with this program. If not, see http://www.gnu.org/licenses/.
9 | // */
10 | namespace Sitecore.CodeGenerator
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 | using System.IO;
15 | using System.Linq;
16 | using Data;
17 | using Data.Serialization.ObjectModel;
18 | using Diagnostics;
19 | using Domain;
20 | using Rainbow.Model;
21 | using Rainbow.Storage.Yaml;
22 | using Serialization;
23 |
24 | public abstract class TemplatesResolverBase
25 | {
26 | public List Templates { get; private set; }
27 |
28 | public TemplatesResolverBase(
29 | string serializationPath,
30 | string[] includePaths,
31 | string db = "master")
32 | {
33 | Assert.ArgumentNotNullOrEmpty(serializationPath, "serializationPath");
34 | DirectoryInfo serializationFolder = new DirectoryInfo(serializationPath);
35 | Assert.IsTrue(serializationFolder.Exists, string.Format("Path '{0}' does not exist", serializationPath));
36 |
37 | List syncItems = GetAllItems(serializationFolder, db, includePaths);
38 |
39 | this.InitializeTemplates(syncItems, serializationFolder);
40 | }
41 |
42 | public TemplatesResolverBase(List serializationPaths)
43 | {
44 | List syncItems = serializationPaths
45 | .Select(s => new FileInfo(s))
46 | .Where(s => s.Exists)
47 | .Select(s => GetItem(s, null))
48 | .ToList();
49 |
50 | this.InitializeTemplates(syncItems, null);
51 | }
52 |
53 | protected abstract List GetAllItems(DirectoryInfo folder, string db, string[] includePaths);
54 |
55 | protected abstract SyncItem GetItem(FileInfo itemFile, Func mustMatch);
56 |
57 | private void InitializeTemplates(List syncItems, DirectoryInfo serializationFolder)
58 | {
59 | this.Templates = syncItems
60 | .Where(s => s.TemplateID == TemplateIDs.Template.ToString())
61 | .Select(t => new TemplateItem(t, syncItems))
62 | .ToList();
63 |
64 | Dictionary templateLookup = this.Templates.ToDictionary(t => t.SyncItem.ID, t => t);
65 |
66 | // resolve inheritance hierarchy
67 | foreach (TemplateItem templateItem in this.Templates)
68 | {
69 | SyncField baseTemplates = templateItem.SyncItem.SharedFields
70 | .FirstOrDefault(f => f.FieldID == FieldIDs.BaseTemplate.ToString());
71 | if (baseTemplates != null && !string.IsNullOrWhiteSpace(baseTemplates.FieldValue))
72 | {
73 | ID[] baseTemplateIds = baseTemplates.FieldValue
74 | .Split(new[] { '|', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
75 | .Where(ID.IsID)
76 | .Select(ID.Parse)
77 | .ToArray();
78 | var baseTemplateIdsInCurrentSet = baseTemplateIds
79 | .Where(b => templateLookup.Keys.Contains(b.ToString()));
80 | templateItem.BaseTemplates.AddRange(baseTemplateIdsInCurrentSet
81 | .Select(b => templateLookup[b.ToString()]));
82 |
83 | // resolve base templates outside of resolving set
84 | if (serializationFolder != null)
85 | {
86 | foreach (ID baseTemplateId in baseTemplateIds
87 | .Where(b => !templateItem.BaseTemplates.Any(bt => bt.SyncItem.ID == b.ToString())))
88 | {
89 | string baseTemplateFilePath = baseTemplateId.FindFilePath(serializationFolder);
90 | if (string.IsNullOrWhiteSpace(baseTemplateFilePath))
91 | {
92 | continue;
93 | }
94 | FileInfo baseTemplateFile = new FileInfo(baseTemplateFilePath);
95 | if (!baseTemplateFile.Exists)
96 | {
97 | continue;
98 | }
99 | SyncItem baseTemplateSyncItem =
100 | SyncItem.ReadItem(new Tokenizer(baseTemplateFile.OpenText()));
101 | if (baseTemplateSyncItem == null)
102 | {
103 | continue;
104 | }
105 | if (!templateItem.BaseTemplates.Any(b => b.SyncItem.ID == baseTemplateSyncItem.ID))
106 | {
107 | templateItem.BaseTemplates.Add(new TemplateItem(baseTemplateSyncItem,
108 | new List()));
109 | }
110 | }
111 | }
112 | }
113 | }
114 | }
115 | }
116 | }
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/TemplatesResolverRainbow.cs:
--------------------------------------------------------------------------------
1 | //
2 | // This program is distributed in the hope that it will be useful,
3 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
4 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 | // GNU General Public License for more details.
6 | //
7 | // You should have received a copy of the GNU General Public License
8 | // along with this program. If not, see http://www.gnu.org/licenses/.
9 | // */
10 | namespace Sitecore.CodeGenerator
11 | {
12 | using System;
13 | using System.Collections.Generic;
14 | using System.IO;
15 | using System.Linq;
16 | using Data;
17 | using Data.Serialization.ObjectModel;
18 | using Rainbow.Model;
19 | using Rainbow.Storage.Yaml;
20 |
21 | public class TemplatesResolverRainbow : TemplatesResolverBase
22 | {
23 | public TemplatesResolverRainbow(string serializationPath, string[] includePaths, string db = "master")
24 | : base(serializationPath, includePaths, db)
25 | {
26 | }
27 |
28 | public TemplatesResolverRainbow(List serializationPaths) : base(serializationPaths)
29 | {
30 | }
31 |
32 | protected override List GetAllItems(DirectoryInfo folder, string db, string[] includePaths)
33 | {
34 | List result = new List();
35 | foreach (FileInfo itemFile in folder.GetFiles("*.yml", SearchOption.AllDirectories))
36 | {
37 | var syncItem = this.GetItem(itemFile, i => includePaths.Any(p => i.Path.StartsWith(p)));
38 |
39 | if (syncItem != null)
40 | {
41 | result.Add(syncItem);
42 | }
43 | }
44 | return result;
45 | }
46 |
47 | protected override SyncItem GetItem(FileInfo itemFile, Func mustMatch)
48 | {
49 | var formatter = new YamlSerializationFormatter(null, null);
50 |
51 | SyncItem syncItem = null;
52 | using (StreamReader sr = new StreamReader(itemFile.FullName))
53 | {
54 | try
55 | {
56 | IItemData item = formatter.ReadSerializedItem(sr.BaseStream, itemFile.Name);
57 | if (item == null || (mustMatch != null && !mustMatch(item)))
58 | {
59 | return null;
60 | }
61 |
62 | syncItem = new SyncItem()
63 | {
64 | Name = item.Name,
65 | BranchId = new ID(item.BranchId).ToString(),
66 | DatabaseName = item.DatabaseName,
67 | ID = new ID(item.Id).ToString(),
68 | ItemPath = item.Path,
69 | TemplateID = new ID(item.TemplateId).ToString(),
70 | ParentID = new ID(item.ParentId).ToString()
71 | };
72 | foreach (var version in item.Versions)
73 | {
74 | var syncVersion = syncItem.AddVersion(version.Language.Name, version.VersionNumber.ToString(),
75 | version.VersionNumber.ToString());
76 | foreach (var field in version.Fields)
77 | {
78 | syncVersion.AddField(new ID(field.FieldId).ToString(), field.NameHint, field.NameHint, field.Value, true);
79 | }
80 | }
81 |
82 | foreach (var sharedField in item.SharedFields)
83 | {
84 | syncItem.AddSharedField(new ID(sharedField.FieldId).ToString(), sharedField.NameHint,
85 | sharedField.NameHint, sharedField.Value, true);
86 | }
87 |
88 | foreach (var unversionedField in item.UnversionedFields)
89 | {
90 | foreach (var version in syncItem.Versions.Where(v => v.Language == unversionedField.Language.Name))
91 | {
92 | foreach (var itemFieldValue in unversionedField.Fields)
93 | {
94 | version.AddField(new ID(itemFieldValue.FieldId).ToString(), itemFieldValue.NameHint,
95 | itemFieldValue.NameHint, itemFieldValue.Value, true);
96 | }
97 | }
98 | }
99 | }
100 | catch (Exception ex)
101 | {
102 | throw new Exception(string.Format("Unable to deserialize '{0}'", itemFile.FullName), ex);
103 | }
104 | }
105 | return syncItem;
106 | }
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/Sitecore.CodeGenerator/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/.gitignore:
--------------------------------------------------------------------------------
1 | *.gen.cs
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Readme.txt:
--------------------------------------------------------------------------------
1 | - This is the folder where currently, the Rainbow (Unicorn) data is serialized to
2 | - The serialized data is included in the solution, but not visible, so find this folder on the filesystem to see what's going on
3 | - You can change which folder to find serialized data in, by changing the AdditionalFiles in the project file
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "84521828-eddc-47b3-bf39-781ee10a6a74"
3 | Parent: "3c1715fe-6a13-4fcf-845f-de308ba9741d"
4 | Template: "0437fee2-44c9-46a6-abe9-28858d9fee8c"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample
6 | DB: master
7 | SharedFields:
8 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
9 | Hint: __Sortorder
10 | Value: 600
11 | Languages:
12 | - Language: en
13 | Versions:
14 | - Version: 1
15 | Fields:
16 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
17 | Hint: __Created
18 | Value: 20150224T174247Z
19 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
20 | Hint: __Created by
21 | Value: sitecore\admin
22 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Animal.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "319eb0a2-ef28-4dae-b35c-551bd53317b2"
3 | Parent: "84521828-eddc-47b3-bf39-781ee10a6a74"
4 | Template: "ab86861a-6030-46c5-b394-e8f99e8b87db"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Animal
6 | DB: master
7 | SharedFields:
8 | - ID: "12c33f3f-86c5-43a5-aeb4-5598cec45116"
9 | Hint: __Base template
10 | Type: tree list
11 | Value: "{1930BBEB-7805-471A-A3BE-4858AC7CF696}"
12 | Languages:
13 | - Language: en
14 | Versions:
15 | - Version: 1
16 | Fields:
17 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
18 | Hint: __Created
19 | Value: 20150224T174342Z
20 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
21 | Hint: __Created by
22 | Value: sitecore\admin
23 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Animal/Animal.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "110d503b-2ea3-4602-aca0-d8508376e30d"
3 | Parent: "319eb0a2-ef28-4dae-b35c-551bd53317b2"
4 | Template: "e269fbb5-3750-427a-9149-7aa950b49301"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Animal/Animal
6 | DB: master
7 | Languages:
8 | - Language: en
9 | Versions:
10 | - Version: 1
11 | Fields:
12 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
13 | Hint: __Created
14 | Value: 20150224T175642Z
15 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
16 | Hint: __Created by
17 | Value: sitecore\admin
18 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Animal/Animal/Description.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "edfd61c6-bbef-45b6-8fd4-84ca215bab73"
3 | Parent: "110d503b-2ea3-4602-aca0-d8508376e30d"
4 | Template: "455a3e98-a627-4b40-8035-e683a0331ac7"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Animal/Animal/Description
6 | DB: master
7 | SharedFields:
8 | - ID: "ab162cc0-dc80-4abf-8871-998ee5d7ba32"
9 | Hint: Type
10 | Value: Rich Text
11 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
12 | Hint: __Sortorder
13 | Value: 200
14 | Languages:
15 | - Language: en
16 | Fields:
17 | - ID: "19a69332-a23e-4e70-8d16-b2640cb24cc8"
18 | Hint: Title
19 | Value: A short description of the animal
20 | Versions:
21 | - Version: 1
22 | Fields:
23 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
24 | Hint: __Created
25 | Value: 20150224T175642Z
26 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Dog.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "f4a0d5d5-49f9-488f-82aa-d4be1adcb662"
3 | Parent: "84521828-eddc-47b3-bf39-781ee10a6a74"
4 | Template: "ab86861a-6030-46c5-b394-e8f99e8b87db"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Dog
6 | DB: master
7 | SharedFields:
8 | - ID: "12c33f3f-86c5-43a5-aeb4-5598cec45116"
9 | Hint: __Base template
10 | Type: tree list
11 | Value: |
12 | {319EB0A2-EF28-4DAE-B35C-551BD53317B2}
13 | {2852DE45-BF36-44D8-9435-8A30EC6923C5}
14 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
15 | Hint: __Sortorder
16 | Value: 625
17 | Languages:
18 | - Language: en
19 | Versions:
20 | - Version: 1
21 | Fields:
22 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
23 | Hint: __Created
24 | Value: 20150224T174357Z
25 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
26 | Hint: __Created by
27 | Value: sitecore\admin
28 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Dog/Dog.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "61472a67-4c8e-410a-a07e-61d84afaed19"
3 | Parent: "f4a0d5d5-49f9-488f-82aa-d4be1adcb662"
4 | Template: "e269fbb5-3750-427a-9149-7aa950b49301"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Dog/Dog
6 | DB: master
7 | Languages:
8 | - Language: en
9 | Versions:
10 | - Version: 1
11 | Fields:
12 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
13 | Hint: __Created
14 | Value: 20150224T174605Z
15 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
16 | Hint: __Created by
17 | Value: sitecore\admin
18 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Dog/Dog/Eats.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "1033d7c1-9c1a-4c65-8316-81b6d5e46eb5"
3 | Parent: "61472a67-4c8e-410a-a07e-61d84afaed19"
4 | Template: "455a3e98-a627-4b40-8035-e683a0331ac7"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Dog/Dog/Eats
6 | DB: master
7 | SharedFields:
8 | - ID: "ab162cc0-dc80-4abf-8871-998ee5d7ba32"
9 | Hint: Type
10 | Value: Multilist with Search
11 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
12 | Hint: __Sortorder
13 | Value: 100
14 | - ID: "be351a73-fcb0-4213-93fa-c302d8ab4f51"
15 | Hint: Shared
16 | Type: Checkbox
17 | Value: 1
18 | Languages:
19 | - Language: en
20 | Fields:
21 | - ID: "19a69332-a23e-4e70-8d16-b2640cb24cc8"
22 | Hint: Title
23 | Value: "What food does the dog eat?"
24 | Versions:
25 | - Version: 1
26 | Fields:
27 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
28 | Hint: __Created
29 | Value: 20150224T174605Z
30 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Dog/Dog/Friends.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "20d7789d-bce0-473e-bb46-59b216ce2c10"
3 | Parent: "61472a67-4c8e-410a-a07e-61d84afaed19"
4 | Template: "455a3e98-a627-4b40-8035-e683a0331ac7"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Dog/Dog/Friends
6 | DB: master
7 | SharedFields:
8 | - ID: "ab162cc0-dc80-4abf-8871-998ee5d7ba32"
9 | Hint: Type
10 | Value: Multilist with Search
11 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
12 | Hint: __Sortorder
13 | Value: 200
14 | - ID: "be351a73-fcb0-4213-93fa-c302d8ab4f51"
15 | Hint: Shared
16 | Type: Checkbox
17 | Value: 1
18 | Languages:
19 | - Language: en
20 | Fields:
21 | - ID: "19a69332-a23e-4e70-8d16-b2640cb24cc8"
22 | Hint: Title
23 | Value: Other dogs that this dog likes
24 | Versions:
25 | - Version: 1
26 | Fields:
27 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
28 | Hint: __Created
29 | Value: 20150224T180103Z
30 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Food.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "7196e22c-0b26-4539-baee-959ed8c5bfe5"
3 | Parent: "84521828-eddc-47b3-bf39-781ee10a6a74"
4 | Template: "ab86861a-6030-46c5-b394-e8f99e8b87db"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Food
6 | DB: master
7 | SharedFields:
8 | - ID: "12c33f3f-86c5-43a5-aeb4-5598cec45116"
9 | Hint: __Base template
10 | Type: tree list
11 | Value: "{1930BBEB-7805-471A-A3BE-4858AC7CF696}"
12 | Languages:
13 | - Language: en
14 | Versions:
15 | - Version: 1
16 | Fields:
17 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
18 | Hint: __Created
19 | Value: 20150224T175843Z
20 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
21 | Hint: __Created by
22 | Value: sitecore\admin
23 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Food/Nutrition.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "e8479274-f80d-4c1b-b5eb-01df2b84f41f"
3 | Parent: "7196e22c-0b26-4539-baee-959ed8c5bfe5"
4 | Template: "e269fbb5-3750-427a-9149-7aa950b49301"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Food/Nutrition
6 | DB: master
7 | Languages:
8 | - Language: en
9 | Versions:
10 | - Version: 1
11 | Fields:
12 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
13 | Hint: __Created
14 | Value: 20150224T175820Z
15 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
16 | Hint: __Created by
17 | Value: sitecore\admin
18 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Food/Nutrition/Calories.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "3f57b9d2-50ec-4f87-8631-2334c837d5bf"
3 | Parent: "e8479274-f80d-4c1b-b5eb-01df2b84f41f"
4 | Template: "455a3e98-a627-4b40-8035-e683a0331ac7"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Food/Nutrition/Calories
6 | DB: master
7 | SharedFields:
8 | - ID: "ab162cc0-dc80-4abf-8871-998ee5d7ba32"
9 | Hint: Type
10 | Value: Number
11 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
12 | Hint: __Sortorder
13 | Value: 100
14 | - ID: "be351a73-fcb0-4213-93fa-c302d8ab4f51"
15 | Hint: Shared
16 | Type: Checkbox
17 | Value: 1
18 | Languages:
19 | - Language: en
20 | Fields:
21 | - ID: "19a69332-a23e-4e70-8d16-b2640cb24cc8"
22 | Hint: Title
23 | Value: "How many calories per serving?"
24 | Versions:
25 | - Version: 1
26 | Fields:
27 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
28 | Hint: __Created
29 | Value: 20150224T175820Z
30 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Nameable.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "2852de45-bf36-44d8-9435-8a30ec6923c5"
3 | Parent: "84521828-eddc-47b3-bf39-781ee10a6a74"
4 | Template: "ab86861a-6030-46c5-b394-e8f99e8b87db"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Nameable
6 | DB: master
7 | SharedFields:
8 | - ID: "12c33f3f-86c5-43a5-aeb4-5598cec45116"
9 | Hint: __Base template
10 | Type: tree list
11 | Value: "{1930BBEB-7805-471A-A3BE-4858AC7CF696}"
12 | Languages:
13 | - Language: en
14 | Versions:
15 | - Version: 1
16 | Fields:
17 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
18 | Hint: __Created
19 | Value: 20150224T174806Z
20 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
21 | Hint: __Created by
22 | Value: sitecore\admin
23 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Nameable/Name.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "b35a500e-1cd2-4a61-bd6f-887d7edc7718"
3 | Parent: "2852de45-bf36-44d8-9435-8a30ec6923c5"
4 | Template: "e269fbb5-3750-427a-9149-7aa950b49301"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Nameable/Name
6 | DB: master
7 | Languages:
8 | - Language: en
9 | Versions:
10 | - Version: 1
11 | Fields:
12 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
13 | Hint: __Created
14 | Value: 20150224T174821Z
15 | - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
16 | Hint: __Created by
17 | Value: sitecore\admin
18 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Data/Unicorn/Sample templates/Templates/Sitecore Code Generator Sample/Nameable/Name/Name.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ID: "7e4faa48-e6ce-46b7-888e-309b5fcc4107"
3 | Parent: "b35a500e-1cd2-4a61-bd6f-887d7edc7718"
4 | Template: "455a3e98-a627-4b40-8035-e683a0331ac7"
5 | Path: /sitecore/templates/Sitecore Code Generator Sample/Nameable/Name/Name
6 | DB: master
7 | SharedFields:
8 | - ID: "ab162cc0-dc80-4abf-8871-998ee5d7ba32"
9 | Hint: Type
10 | Value: "Single-Line Text"
11 | - ID: "ba3f86a2-4a1c-4d78-b63d-91c2779c1b5e"
12 | Hint: __Sortorder
13 | Value: 100
14 | Languages:
15 | - Language: en
16 | Versions:
17 | - Version: 1
18 | Fields:
19 | - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
20 | Hint: __Created
21 | Value: 20150224T174821Z
22 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Models/GlassGenerator.csx:
--------------------------------------------------------------------------------
1 | #r "..\\..\\Sitecore.CodeGenerator.Scripty\\bin\\Debug\\Sitecore.Codegenerator.Scripty.dll"
2 | #r "..\\..\\Lib\\Sitecore.Kernel.DLL"
3 | #r "..\\..\\packages\\BoC.Glass.Mapper.Sc.1.0.3\\lib\\net45\\Glass.Mapper.Sc.dll"
4 | using Microsoft.CodeAnalysis;
5 | using Microsoft.CodeAnalysis.Editing;
6 | using Sitecore.Codegenerator.Scripty;
7 | using static Sitecore.Codegenerator.Scripty.CodeGenerationExtensions;
8 | using System.Linq;
9 | using global::Glass.Mapper.Sc.Fields;
10 |
11 | var templates = SerializedDataUtil.GetTemplates(Project);
12 | foreach (var template in templates)
13 | {
14 | string extends;
15 | if (template.BaseTemplates.Any())
16 | {
17 | extends = string.Concat(" : ", string.Join(", ", template.BaseTemplates.Select(b => string.Concat("I", b.SyncItem.Name.Identifier()))));
18 | }
19 | else
20 | {
21 | extends = string.Empty; //" : IModelBase";
22 | }
23 |
24 | var templateFile = Output[string.Concat("I", template.SyncItem.Name.Identifier(), ".gen.cs")];
25 |
26 | templateFile.WriteLine("// ");
27 | templateFile.WriteLine("// This file was generated by Sitecore.CodeGenerator.Scripty");
28 | templateFile.WriteLine("// Any changes made to this file manually will be lost next time the file is regenerated.");
29 | templateFile.WriteLine("// Please ensure that this file is not checked in to your source control system, as it should be regenerated during a build and we want to avoid merge issues.");
30 | templateFile.WriteLine("// ");
31 |
32 | templateFile.WriteLine($"namespace {Project.Analysis.AssemblyName}.Models");
33 | templateFile.WriteLine("{");
34 | templateFile.WriteLine(" using System;");
35 | templateFile.WriteLine(" using System.Collections.Generic;");
36 | templateFile.WriteLine(" using System.Collections.Specialized;");
37 | templateFile.WriteLine(" using global::Glass.Mapper.Sc.Configuration;");
38 | templateFile.WriteLine(" using global::Glass.Mapper.Sc.Configuration.Attributes;");
39 | templateFile.WriteLine(" using global::Glass.Mapper.Sc.Fields;");
40 | templateFile.WriteLine("");
41 | templateFile.WriteLine(" /// ");
42 | templateFile.WriteLine($" /// Represents a mapped type for item {template.SyncItem.ID} in Sitecore.");
43 | templateFile.WriteLine($" /// Path: {template.SyncItem.ItemPath}");
44 | templateFile.WriteLine(" /// ");
45 | templateFile.WriteLine($" [SitecoreType(TemplateId = \"{template.SyncItem.ID}\")]");
46 | templateFile.WriteLine($" public partial interface I{template.SyncItem.Name.Identifier()}{extends}");
47 | templateFile.WriteLine(" {");
48 |
49 | foreach (var section in template.Sections)
50 | {
51 | templateFile.WriteLine($" #region {section.SyncItem.Name}");
52 | templateFile.WriteLine("");
53 | foreach (var field in section.Fields)
54 | {
55 | var fieldId = field.SyncItem.ID;
56 | var fieldOptions = GetFieldOptions(field.FieldTypeName, fieldId);
57 |
58 | // Add custom options, like setting the return type of a field property explicitly
59 |
60 | // Dog -> Food
61 | if ("{1033D7C1-9C1A-4C65-8316-81B6D5E46EB5}".Equals(fieldId))
62 | {
63 | fieldOptions.GlassFieldTypeName = "IEnumerable";
64 | }
65 |
66 | // Dog -> Dog's friends
67 | if ("{20D7789D-BCE0-473E-BB46-59B216CE2C10}".Equals(fieldId))
68 | {
69 | fieldOptions.GlassFieldTypeName = "IEnumerable";
70 | fieldOptions.AttributeExtras = ", Setting = SitecoreFieldSettings.DontLoadLazily";
71 | }
72 |
73 | if (!string.IsNullOrWhiteSpace(field.FieldTitle))
74 | {
75 | templateFile.WriteLine(" /// ");
76 | templateFile.WriteLine($" /// {field.FieldTitle}");
77 | templateFile.WriteLine(" /// ");
78 | }
79 |
80 | templateFile.WriteLine($" [SitecoreField(FieldId = \"{field.SyncItem.ID}\"{fieldOptions.AttributeExtras ?? string.Empty })]");
81 | templateFile.WriteLine($" {fieldOptions.GlassFieldTypeName} {field.SyncItem.Name.Identifier()} {{ get; set; }}");
82 | }
83 |
84 | templateFile.WriteLine("");
85 | templateFile.WriteLine(" #endregion");
86 | templateFile.WriteLine("");
87 | }
88 |
89 | templateFile.WriteLine(" }");
90 | templateFile.WriteLine("}");
91 | }
92 |
93 | public class FieldOptions
94 | {
95 | public string GlassFieldTypeName { get; set; }
96 | public string AttributeExtras { get; set; }
97 | }
98 |
99 | public FieldOptions GetFieldOptions(string fieldType, string fieldId)
100 | {
101 | FieldOptions result = new FieldOptions();
102 | switch (fieldType)
103 | {
104 | case "Checkbox":
105 | result.GlassFieldTypeName = "bool";
106 | break;
107 | case "Integer":
108 | result.GlassFieldTypeName = "int";
109 | break;
110 | case "Number":
111 | result.GlassFieldTypeName = typeof(Decimal).Name;
112 | break;
113 | case "Date":
114 | case "Datetime":
115 | result.GlassFieldTypeName = typeof(DateTime).Name;
116 | break;
117 | case "File":
118 | case "File Drop Area":
119 | result.GlassFieldTypeName = typeof(File).Name;
120 | break;
121 | case "Name Value List":
122 | case "Name Lookup Value List":
123 | result.GlassFieldTypeName = typeof(System.Collections.Specialized.NameValueCollection).Name;
124 | break;
125 | // case "???": result.GlassFieldTypeName = typeof(HtmlEncodedString).Name; break;
126 | case "Image":
127 | result.GlassFieldTypeName = typeof(Image).Name;
128 | break;
129 | case "Droplink":
130 | case "Droptree":
131 | case "General Link":
132 | case "General Link with Search":
133 | case "Version Link":
134 | case "link":
135 | result.GlassFieldTypeName = typeof(Link).Name;
136 | break;
137 | // case "???": result.GlassFieldTypeName = typeof(LinkType).Name; break;
138 | case "Tristate":
139 | result.GlassFieldTypeName = typeof(TriState).Name;
140 | break;
141 | default:
142 | result.GlassFieldTypeName = "string";
143 | break;
144 | }
145 |
146 | return result;
147 | }
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2015 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System.Reflection;
18 | using System.Runtime.CompilerServices;
19 | using System.Runtime.InteropServices;
20 |
21 | // General Information about an assembly is controlled through the following
22 | // set of attributes. Change these attribute values to modify the information
23 | // associated with an assembly.
24 | [assembly: AssemblyTitle("Sitecore.Codegenerator.Scripty.Sample.Glass")]
25 | [assembly: AssemblyDescription("")]
26 | [assembly: AssemblyConfiguration("")]
27 | [assembly: AssemblyCompany("")]
28 | [assembly: AssemblyProduct("Sitecore.Codegenerator.Scripty.Sample.Glass")]
29 | [assembly: AssemblyCopyright("Copyright © Robin Hermanussen 2017")]
30 | [assembly: AssemblyTrademark("")]
31 | [assembly: AssemblyCulture("")]
32 |
33 | // Setting ComVisible to false makes the types in this assembly not visible
34 | // to COM components. If you need to access a type in this assembly from
35 | // COM, set the ComVisible attribute to true on that type.
36 | [assembly: ComVisible(false)]
37 |
38 | // The following GUID is for the ID of the typelib if this project is exposed to COM
39 | [assembly: Guid("235eb204-526e-4941-8ec0-04fdab755ffe")]
40 |
41 | // Version information for an assembly consists of the following four values:
42 | //
43 | // Major Version
44 | // Minor Version
45 | // Build Number
46 | // Revision
47 | //
48 | // You can specify all the values or you can default the Build and Revision Numbers
49 | // by using the '*' as shown below:
50 | // [assembly: AssemblyVersion("1.0.*")]
51 | [assembly: AssemblyVersion("2.0.0.0")]
52 | [assembly: AssemblyFileVersion("2.0.0.0")]
53 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/Sitecore.Codegenerator.Scripty.Sample.Glass.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {235EB204-526E-4941-8EC0-04FDAB755FFE}
8 | Library
9 | Properties
10 | Sitecore.Codegenerator.Scripty.Sample.Glass
11 | Sitecore.Codegenerator.Scripty.Sample.Glass
12 | v4.6.1
13 | 512
14 |
15 |
16 |
17 |
18 |
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 | ..\packages\Castle.Core.1.1.0\lib\Castle.Core.dll
38 |
39 |
40 | ..\packages\BoC.Glass.Mapper.1.0.3\lib\net45\Glass.Mapper.dll
41 |
42 |
43 | ..\packages\BoC.Glass.Mapper.Sc.1.0.3\lib\net45\Glass.Mapper.Sc.dll
44 |
45 |
46 | ..\packages\log4net.1.2.10\lib\2.0\log4net.dll
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | false
71 |
72 |
73 |
74 |
75 |
76 |
77 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty.Sample.Glass/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty/CodeGenerationExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Globalization;
5 |
6 | namespace Sitecore.Codegenerator.Scripty
7 | {
8 | ///
9 | /// Code copied and slightly changed from https://github.com/olegsych/T4Toolbox/blob/master/src/T4Toolbox/CSharpTemplate.cs
10 | /// This needs some improvement, as Roslyn is able to verify keywords and check if identifiers are valid.
11 | ///
12 | public static class CodeGenerationExtensions
13 | {
14 | ///
15 | /// Contains C# reserved keywords defined in MSDN documentation at .
16 | ///
17 | private static readonly HashSet ReservedKeywords = new HashSet
18 | {
19 | "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char",
20 | "checked", "class", "const", "continue", "decimal", "default", "delegate", "do",
21 | "double", "else", "enum", "event", "explicit", "extern", "false", "finally",
22 | "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int",
23 | "interface", "internal", "is", "lock", "long", "namespace", "new", "null",
24 | "object", "operator", "out", "override", "params", "private", "protected",
25 | "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof",
26 | "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true",
27 | "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using",
28 | "virtual", "volatile", "void", "while"
29 | };
30 |
31 | ///
32 | /// Converts a given string to a valid C# field name using camelCase notation.
33 | ///
34 | ///
35 | /// This method converts the first letter of the given string to lower case and calls the method to ensure that it's valid.
36 | /// You can override this method in your template to replace the default implementation.
37 | ///
38 | public static string FieldName(this string name)
39 | {
40 | if (name == null)
41 | {
42 | throw new ArgumentNullException("name");
43 | }
44 |
45 | name = name.Trim();
46 | name = char.ToLowerInvariant(name[0]) + name.Substring(1);
47 | return name.Identifier();
48 | }
49 |
50 | ///
51 | /// Converts a given string into a valid C# identifier.
52 | ///
53 | ///
54 | /// This method is based on rules defined in C# language specification.
55 | /// It removes white space characters and concatenates words using camelCase notation. If the resulting string is
56 | /// a C# keyword, the the method prepends it with the @ symbol to change it into a literal C# identifier. You can override this method
57 | /// in your template to replace the default implementation.
58 | ///
59 | public static string Identifier(this string name)
60 | {
61 | if (name == null)
62 | {
63 | throw new ArgumentNullException("name");
64 | }
65 |
66 | var builder = new StringBuilder();
67 |
68 | char c = '\x0000'; // current character within name
69 | int i = 0; // current index within name
70 |
71 | // Skip invalid characters from the beginning of the name
72 | while (i < name.Length)
73 | {
74 | c = name[i++];
75 |
76 | // First character must be a letter or _
77 | if (char.IsLetter(c) || c == '_')
78 | {
79 | break;
80 | }
81 | }
82 |
83 | if (i <= name.Length)
84 | {
85 | builder.Append(c);
86 | }
87 |
88 | bool capitalizeNext = false;
89 |
90 | // Strip invalid characters from the remainder of the name and convert it to camelCase
91 | while (i < name.Length)
92 | {
93 | c = name[i++];
94 |
95 | // Subsequent character can be a letter, a digit, combining, connecting or formatting character
96 | UnicodeCategory category = char.GetUnicodeCategory(c);
97 | if (!char.IsLetterOrDigit(c) &&
98 | category != UnicodeCategory.SpacingCombiningMark &&
99 | category != UnicodeCategory.ConnectorPunctuation &&
100 | category != UnicodeCategory.Format)
101 | {
102 | capitalizeNext = true;
103 | continue;
104 | }
105 |
106 | if (capitalizeNext)
107 | {
108 | c = char.ToUpperInvariant(c);
109 | capitalizeNext = false;
110 | }
111 |
112 | builder.Append(c);
113 | }
114 |
115 | string identifier = builder.ToString();
116 |
117 | // If identifier is a reserved C# keyword
118 | if (ReservedKeywords.Contains(identifier))
119 | {
120 | // Convert it to literal identifer
121 | return "@" + identifier;
122 | }
123 |
124 | return identifier;
125 | }
126 |
127 | ///
128 | /// Converts a given string to a valid C# property name using PascalCase notation.
129 | ///
130 | ///
131 | /// This method converts the first letter of the given string to upper case and calls the method to ensure that it's valid.
132 | /// You can override this method in your template to replace the default implementation.
133 | ///
134 | public static string PropertyName(this string name)
135 | {
136 | if (name == null)
137 | {
138 | throw new ArgumentNullException("name");
139 | }
140 |
141 | name = name.Trim();
142 | name = char.ToUpperInvariant(name[0]) + name.Substring(1);
143 | return name.Identifier();
144 | }
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // /*
2 | // Copyright (C) 2017 Robin Hermanussen
3 | //
4 | // This program is free software: you can redistribute it and/or modify
5 | // it under the terms of the GNU General Public License as published by
6 | // the Free Software Foundation, either version 3 of the License, or
7 | // (at your option) any later version.
8 | //
9 | // This program is distributed in the hope that it will be useful,
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | // GNU General Public License for more details.
13 | //
14 | // You should have received a copy of the GNU General Public License
15 | // along with this program. If not, see http://www.gnu.org/licenses/.
16 | // */
17 | using System.Reflection;
18 | using System.Runtime.CompilerServices;
19 | using System.Runtime.InteropServices;
20 |
21 | // General Information about an assembly is controlled through the following
22 | // set of attributes. Change these attribute values to modify the information
23 | // associated with an assembly.
24 | [assembly: AssemblyTitle("Sitecore.Codegenerator.Scripty")]
25 | [assembly: AssemblyDescription("")]
26 | [assembly: AssemblyConfiguration("")]
27 | [assembly: AssemblyCompany("")]
28 | [assembly: AssemblyProduct("Sitecore.Codegenerator.Scripty")]
29 | [assembly: AssemblyCopyright("Copyright © 2017")]
30 | [assembly: AssemblyTrademark("")]
31 | [assembly: AssemblyCulture("")]
32 |
33 | // Setting ComVisible to false makes the types in this assembly not visible
34 | // to COM components. If you need to access a type in this assembly from
35 | // COM, set the ComVisible attribute to true on that type.
36 | [assembly: ComVisible(false)]
37 |
38 | // The following GUID is for the ID of the typelib if this project is exposed to COM
39 | [assembly: Guid("35439bdb-2b65-4f12-b6eb-83fe8fd99bd8")]
40 |
41 | // Version information for an assembly consists of the following four values:
42 | //
43 | // Major Version
44 | // Minor Version
45 | // Build Number
46 | // Revision
47 | //
48 | // You can specify all the values or you can default the Build and Revision Numbers
49 | // by using the '*' as shown below:
50 | // [assembly: AssemblyVersion("1.0.*")]
51 | [assembly: AssemblyVersion("1.0.0.0")]
52 | [assembly: AssemblyFileVersion("1.0.0.0")]
53 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty/SerializedDataUtil.cs:
--------------------------------------------------------------------------------
1 | namespace Sitecore.Codegenerator.Scripty
2 | {
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using CodeGenerator;
6 | using CodeGenerator.Domain;
7 | using Microsoft.CodeAnalysis;
8 | using global::Scripty.Core.ProjectTree;
9 |
10 | public static class SerializedDataUtil
11 | {
12 | public static List GetTemplates(ProjectRoot project)
13 | {
14 | var resolver = new TemplatesResolverRainbow(project.Analysis.AdditionalDocuments.Select(d => d.FilePath).ToList());
15 | return resolver.Templates;
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty/Sitecore.Codegenerator.Scripty.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {35439BDB-2B65-4F12-B6EB-83FE8FD99BD8}
8 | Library
9 | Properties
10 | Sitecore.Codegenerator.Scripty
11 | Sitecore.Codegenerator.Scripty
12 | v4.6.1
13 | 512
14 |
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | ..\packages\ManagedEsent.1.9.4\lib\net40\Esent.Interop.dll
36 |
37 |
38 | ..\packages\Microsoft.Build.15.1.548\lib\net46\Microsoft.Build.dll
39 | True
40 |
41 |
42 | ..\packages\Microsoft.Build.Framework.15.1.548\lib\net46\Microsoft.Build.Framework.dll
43 | True
44 |
45 |
46 | ..\packages\Microsoft.CodeAnalysis.Common.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll
47 |
48 |
49 | ..\packages\Microsoft.CodeAnalysis.CSharp.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll
50 |
51 |
52 | ..\packages\Microsoft.CodeAnalysis.CSharp.Scripting.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Scripting.dll
53 |
54 |
55 | ..\packages\Microsoft.CodeAnalysis.CSharp.Workspaces.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Workspaces.dll
56 |
57 |
58 | ..\packages\Microsoft.CodeAnalysis.Elfie.0.10.6\lib\net46\Microsoft.CodeAnalysis.Elfie.dll
59 |
60 |
61 | ..\packages\Microsoft.CodeAnalysis.Scripting.Common.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.Scripting.dll
62 |
63 |
64 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.dll
65 |
66 |
67 | ..\packages\Microsoft.CodeAnalysis.VisualBasic.Workspaces.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll
68 |
69 |
70 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.0.0\lib\net46\Microsoft.CodeAnalysis.Workspaces.dll
71 |
72 |
73 | ..\packages\Microsoft.CodeAnalysis.Workspaces.Common.2.0.0\lib\net46\Microsoft.CodeAnalysis.Workspaces.Desktop.dll
74 |
75 |
76 | ..\packages\Scripty.Core.0.7.4\lib\net46\Scripty.Core.dll
77 |
78 |
79 |
80 | ..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll
81 |
82 |
83 | ..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll
84 | True
85 |
86 |
87 |
88 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll
89 |
90 |
91 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll
92 |
93 |
94 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll
95 |
96 |
97 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll
98 |
99 |
100 | ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll
101 |
102 |
103 | ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll
104 |
105 |
106 |
107 | ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll
108 |
109 |
110 | ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll
111 |
112 |
113 | ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll
114 |
115 |
116 | ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll
117 |
118 |
119 | ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll
120 |
121 |
122 |
123 | ..\packages\System.Reflection.Metadata.1.4.2\lib\portable-net45+win8\System.Reflection.Metadata.dll
124 |
125 |
126 | ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll
127 |
128 |
129 | ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll
130 |
131 |
132 | ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll
133 |
134 |
135 | ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll
136 |
137 |
138 | ..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll
139 |
140 |
141 | ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll
142 |
143 |
144 | ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 | ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll
154 |
155 |
156 | ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll
157 |
158 |
159 | ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll
160 |
161 |
162 | ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 | {97696946-cfed-49db-ab8d-53431e48e3da}
181 | Sitecore.CodeGenerator
182 |
183 |
184 |
185 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/Sitecore.Codegenerator.Scripty/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------