-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCsharpTemplate.php
More file actions
54 lines (45 loc) · 1.31 KB
/
CsharpTemplate.php
File metadata and controls
54 lines (45 loc) · 1.31 KB
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
<?php
/**
* This file is part of JsonClassified.
* @link https://github.com/akimsko/JsonClassified
*
* @copyright Copyright 2012 Bo Thinggaard
* @license http://www.apache.org/licenses/LICENSE-2.0
*/
require_once __DIR__ . '/ITemplate.php';
/**
* Template for C#
*
* @author bo@unpossiblesystems.dk
*/
class CsharpTemplate implements ITemplate {
private static $_types = array(
Builder::TYPE_STRING => 'string',
Builder::TYPE_INT => 'int',
Builder::TYPE_FLOAT => 'double',
Builder::TYPE_BOOL => 'bool',
Builder::TYPE_ARRAY => 'IList<{subtype}>',
Builder::TYPE_OBJECT => '{subtype}'
);
public function getClass() {
$snippet = "public sealed class {classname} {\n";
$snippet .= "{properties}";
$snippet .= "}";
return $snippet;
}
public function getPropertyMethods() {
return '';
}
public function getProperty() {
return "\tpublic {type} {name.uc} { get; set; }\n";
}
public function getType($typeIndex) {
return array_key_exists($typeIndex, self::$_types) ? self::$_types[$typeIndex] : self::$_types[Builder::TYPE_STRING];
}
public function getFileExtension() {
return ".cs";
}
public function getExtras($properties, $class) {
}
}
?>