/// <summary> /// Initializes a variable to a TypeGo /// </summary> public static TVariable InitializeVariable <TVariable>(BaseTypeGoInfo typeGoInfo, ITypeOptions options) where TVariable : BaseVariable, new() { TVariable variable = new TVariable(); variable.InitializeBase(typeGoInfo, options); return(variable); }
/// <summary> /// property info of a type /// </summary> public PropertyGoInfo(PropertyInfo property, ITypeOptions options) { //coming from change structure if (property == null) { if (options.TryGetValueOfTypeGo(typeof(TPropertyType), out object typeGoInfoProperty)) { TypeGoInfo = (TypeGoInfo<TPropertyType>)typeGoInfoProperty; } else { TypeGoInfo = BaseTypeGoInfo.Generate<TPropertyType>(options); } GetValue = (ref TObject obj) => default; SetValue = (TObject obj, TPropertyType value) => { }; } //coming from normal binary Go else { if (options.TryGetValueOfTypeGo(property.PropertyType, out object typeGoInfoProperty)) { TypeGoInfo = (TypeGoInfo<TPropertyType>)typeGoInfoProperty; } else { TypeGoInfo = BaseTypeGoInfo.Generate<TPropertyType>(options); } PropertyCallerInfo<TObject, TPropertyType> propertyCaller; try { propertyCaller = ReflectionHelper.GetDelegateInstance<TObject, TPropertyType>(property); } catch (Exception ex) { throw new Exception($"Cannot create delegate for property {property.Name} in type {TypeGoInfo.Type.FullName}", ex); } GetValue = propertyCaller.GetValueAction; SetValue = propertyCaller.SetValueAction; } Type = typeof(TPropertyType); }