2024-11-03 11:21:47 +08:00
|
|
|
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
|
2024-11-05 21:04:21 +08:00
|
|
|
self.open_time = field.Opentime
|
2024-11-03 11:21:47 +08:00
|
|
|
self.type = field.Type
|
2024-11-04 22:26:45 +08:00
|
|
|
elif len(args) == 5:
|
|
|
|
self.id, self.name, self.position, self.open_time, self.type = args
|
2024-11-03 11:21:47 +08:00
|
|
|
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):
|
2024-11-05 21:04:21 +08:00
|
|
|
print(self.id)
|
2024-11-03 11:21:47 +08:00
|
|
|
empty_field.Id = Guid.Parse(self.id)
|
|
|
|
empty_field.Name = self.name
|
|
|
|
empty_field.Position = self.position
|
2024-11-05 21:04:21 +08:00
|
|
|
empty_field.Opentime = self.open_time
|
2024-11-03 11:21:47 +08:00
|
|
|
print(FieldType.UNSPECIFIED)
|
|
|
|
print(self.type)
|
|
|
|
empty_field.Type = self.type
|
|
|
|
return empty_field
|