public DartProperty(string name, DartType type, FieldInfo fieldInfo) { Name = name; DartName = DartSupport.GetDartPropertyName(name); Type = type; IsDeclared = fieldInfo.IsDeclared(); }
public DartEvent(ICollection <Type> customTypes, EventInfo eventInfo, DartType eventArgs, string package) { _eventInfo = eventInfo; Name = DartSupport.GetDartMethodName(_eventInfo.Name); EventArgs = eventArgs; //Params = ParamObj.Members.ToList(); /* * foreach (ParameterInfo paramInfo in _methodInfo.GetParameters()) * { * * string paramName = paramInfo.Name; * DartType paramType = new DartType(customTypes, paramInfo.ParameterType, package); * * DartProperty dartProp = new DartProperty(paramName, paramType); * * Params.Add(dartProp); * * } */ Imports = eventArgs.Imports.ToList(); }
public DartMethod(ICollection <Type> customTypes, MethodInfo methodInfo, DartType @return, DartType @param, string package, Func <MethodInfo, string> getMethodId) { _methodInfo = methodInfo; MethodId = getMethodId(methodInfo); Name = DartSupport.GetDartMethodName(_methodInfo.Name); ReturnObj = @return; ParamObj = @param; // Return type for the method ReturnType = new DartReturnType(customTypes, _methodInfo.ReturnType, package); //Params = ParamObj.Members.ToList(); /* * foreach (ParameterInfo paramInfo in _methodInfo.GetParameters()) * { * * string paramName = paramInfo.Name; * DartType paramType = new DartType(customTypes, paramInfo.ParameterType, package); * * DartProperty dartProp = new DartProperty(paramName, paramType); * * Params.Add(dartProp); * * } */ List <string> imports = new List <string>(); // Return types of the method imports.AddRange(ReturnObj.Members.SelectMany(m => m.Type.Imports)); // Param types of the method imports.AddRange(ParamObj.Members.SelectMany(m => m.Type.Imports)); // Fake classes that wrap the method imports.AddRange(@return.Imports.Concat(@param.Imports)); // All method imports Imports = imports.Distinct().ToList(); }
internal static string GetUnsupportedDartTypeErrorMessage(Type t) { string typeName = DartSupport.GetTypeName(t); return($"The type {typeName} has no mapping to dart type. Unsupported!!"); }
public DartType(ICollection <Type> customTypes, Type type, string package) { _customTypes = customTypes; DotNetType = type; Package = package; // Init all the information for the DART type Namespace = DartSupport.GetDartNamespace(type); Name = DartSupport.GetDartTypeName(customTypes, type); FileName = DartSupport.GetDartFilename(type); PartialFileName = DartSupport.GetDartPartialFilename(type); Imports = DartSupport.GetDartImports(customTypes, type, package); IsNullable = DartSupport.IsNullable(type); Category = DartSupport.GetDartCategory(customTypes, type); DartId = DartSupport.GetDartUniqueId(type); // Custom json converter for serializing the type ConverterType = DartSupport.GetConverterType(customTypes, type); // Base dart type Type baseType = DartSupport.GetBaseType(customTypes, type); BaseDartType = (baseType == null) ? null : new DartType(customTypes, baseType, package); // Extract all the properties for the dart type List <PropertyInfo> properties = customTypes.Contains(type) ? DartSupport.GetReferencedProperty(type).ToList() : new List <PropertyInfo>(0); foreach (PropertyInfo prop in properties) { string propName = prop.Name; // Check if the object have reference to his same types (like a graph) DartType propType = null; if (prop.PropertyType != this.DotNetType) { propType = new DartType(customTypes, prop.PropertyType, package); } else { propType = this; } DartProperty dartProp = new DartProperty(propName, propType, prop); Members.Add(dartProp); } // Extract all the fields for the dart type List <FieldInfo> fields = customTypes.Contains(type) ? DartSupport.GetReferencedFields(type).ToList() : new List <FieldInfo>(0); foreach (FieldInfo field in fields) { string propName = field.Name; // Check if the object have reference to his same types (like a graph) DartType propType = null; if (field.FieldType != this.DotNetType) { propType = new DartType(customTypes, field.FieldType, package); } else { propType = this; } DartProperty dartProp = new DartProperty(propName, propType, field); Members.Add(dartProp); } }