// Obtian all Dart subtypes internal static ICollection <DartType> GetDartSubtypes(DartType type, ICollection <DartType> exportedTypes) { ICollection <Type> netSubTypes = ReflectionHelper.GetSubTypes(exportedTypes.Select(ct => ct.DotNetType).ToList(), type.DotNetType).ToList(); ICollection <DartType> dartSubtypes = exportedTypes.Where(ct => netSubTypes.Contains(ct.DotNetType)).OrderBy(et => et.DotNetType.FullName).ToList(); return(dartSubtypes); }
public DartReturnType(ICollection <Type> customTypes, Type type, string package) { Type t = GetNestedType(type); IsVoid = (t == typeof(void)); Type = IsVoid ? null : new DartType(customTypes, t, package); }
public DartService(ICollection <Type> customTypes, Type type, List <MethodInfo> methods, List <EventInfo> events, string package, Func <MethodInfo, string> getMethodId) { Type = new DartType(customTypes, type, package); Methods = new List <DartMethod>(); Events = new List <DartEvent>(); foreach (MethodInfo method in methods) { Type r = DotNetTools.WrapReturnIntoFakeClass(type, method); Type p = DotNetTools.WrapParamsIntoFakeClass(type, method); Type[] tmp = { r, p }; DartType returnType = new DartType(customTypes.Concat(tmp).ToList(), r, package); DartType paramType = new DartType(customTypes.Concat(tmp).ToList(), p, package); Methods.Add(new DartMethod(customTypes, method, returnType, paramType, package, getMethodId)); } foreach (EventInfo @event in events) { Type args = @event.GetPlatformEventArgs(); DartType dartArgs = new DartType(customTypes, args, package); Events.Add(new DartEvent(customTypes, @event, dartArgs, package)); } }
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(); }
internal static string GetDartDirectoryPath(string dartLibFolderPath, DartType type) { // Example /app/protocol/my_item.dart string packagePath = type.Namespace;//+ type.FileName; string totalPath = $"{dartLibFolderPath}{packagePath.Replace(DartProject.DartSeparator, Path.DirectorySeparatorChar)}"; return(totalPath); }
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(); }
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); } }