46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
|
import clr
|
||
|
clr.AddReference('System')
|
||
|
from System import Guid
|
||
|
|
||
|
class FieldType:
|
||
|
UNSPECIFIED = 0
|
||
|
TENNIS = 1
|
||
|
BASKETBALL = 2
|
||
|
BADMINTON = 3
|
||
|
|
||
|
|
||
|
class Field:
|
||
|
id = ""
|
||
|
name = ""
|
||
|
position = ""
|
||
|
open_time = ""
|
||
|
type = FieldType.UNSPECIFIED
|
||
|
|
||
|
def __init__(self, *args, **kwargs):
|
||
|
if len(args) == 0:
|
||
|
pass
|
||
|
elif len(args) == 1:
|
||
|
field = args[0]
|
||
|
self.id = field.Id.ToString()
|
||
|
self.name = field.Name
|
||
|
self.position = field.Position
|
||
|
self.open_time = field.OpenTime
|
||
|
self.type = field.Type
|
||
|
elif len(args) == 4:
|
||
|
self.id, self.name, self.position, self.type = args
|
||
|
else:
|
||
|
raise ValueError("Invalid arguments for Field initialization")
|
||
|
|
||
|
def __str__(self):
|
||
|
return f"Field: Id: {self.id}, Name: {self.name}, Position: {self.position}, Type: {self.type}"
|
||
|
|
||
|
def parse_to_csharp_object(self, empty_field):
|
||
|
empty_field.Id = Guid.Parse(self.id)
|
||
|
empty_field.Name = self.name
|
||
|
empty_field.Position = self.position
|
||
|
empty_field.OpenTime = self.open_time
|
||
|
print(FieldType.UNSPECIFIED)
|
||
|
print(self.type)
|
||
|
empty_field.Type = self.type
|
||
|
return empty_field
|