public ObjectType(PyObject pyType, PyConverter converter) : base(pyType, typeof(T)) { this.Converter = converter; this.Properties = new List <ClrMemberInfo>(); // Get all attributes foreach (var property in this.ClrType.GetProperties()) { var attr = property.GetCustomAttributes(typeof(PyPropetryAttribute), true); if (attr.Length == 0) { continue; } var py_info = attr[0] as PyPropetryAttribute; this.Properties.Add(new ClrPropertyInfo(property, py_info, this.Converter)); } foreach (var field in this.ClrType.GetFields()) { var attr = field.GetCustomAttributes(typeof(PyPropetryAttribute), true); if (attr.Length == 0) { continue; } var py_info = attr[0] as PyPropetryAttribute; this.Properties.Add(new ClrFieldInfo(field, py_info, this.Converter)); } }
public void AddDictType <K, V>(PyConverter converter = null) { if (converter == null) { converter = this; } this.Add(new PyDictType <K, V>(converter)); }
public void AddListType <T>(PyConverter converter = null) { if (converter == null) { converter = this; } this.Add(new PyListType <T>(converter)); }
public void AddObjectType <T>(PyObject pyType, PyConverter converter = null) { if (converter == null) { converter = this; } this.Add(new ObjectType <T>(pyType, converter)); }
public ClrFieldInfo(FieldInfo info, PyPropetryAttribute py_info, PyConverter converter) { this.FieldInfo = info; this.ClrPropertyName = info.Name; this.ClrType = info.FieldType; this.PyPropertyName = py_info.Name; if (string.IsNullOrEmpty(this.PyPropertyName)) { this.PyPropertyName = info.Name; } //this.PythonType = converter.Get(); this.Converter = converter; }
public void AddListType(PyConverter converter = null) { this.AddListType <object>(converter); }
public PyDictType(PyConverter converter) : base("dict", typeof(Dictionary <K, V>)) { this.Converter = converter; }
public PyListType(PyConverter converter) : base("list", typeof(List <T>)) { this.Converter = converter; }