void Run() { string[] filesExpanded = args.files.SelectMany <string, string>(path => { if (Directory.Exists(path)) { return(Directory.EnumerateFiles(path)); } else { return(new string[] { path }); } }).ToArray(); List <Type> allTypes = (new WinMDTypes(filesExpanded)).Types; var types = allTypes.Where(type => AbiTypeRuntimeClass.IsValidRuntimeClass(type) && args.matches.Any(regex => regex.IsMatch(type.Namespace + "." + type.Name)) ).Select(rawType => new AbiTypeRuntimeClass(rawType) ).Where(abiType => !abiType.NoInstanceClass); var typeFactories = allTypes.Where(type => AbiTypeRuntimeClass.IsValidRuntimeClass(type) && args.matches.Any(regex => regex.IsMatch(type.Namespace + "." + type.Name)) ).Select( rawType => new AbiTypeRuntimeClass(rawType) ).Where( abiType => abiType.Factory != null ).Select( abiType => abiType.Factory ); var results = ProcessTypes(types.ToList <IAbiType>()).Concat( ProcessTypes(typeFactories.ToList <IAbiType>())). ToList <FileOutput>(); results.Sort(delegate(FileOutput left, FileOutput right) { return(left.Name.CompareTo(right.Name)); }); foreach (var result in results) { if (args.outPath == null) { Console.WriteLine("// " + result.Name); Console.WriteLine(result.Content); Console.WriteLine(); } else { StreamWriter streamWriter = File.CreateText(args.outPath + "\\" + result.Name); streamWriter.WriteLine(result.Content); streamWriter.Flush(); streamWriter.Close(); } } }
public IAbiType[] GetParentClasses(ReferenceCollector refs) { return(this.unprojectedType.GetInterfaces().Where( tinterface => AbiTypeRuntimeClass.IsValidType(tinterface) ).Select( tinterface => new AbiTypeRuntimeClass(tinterface) ).ToArray()); }
public string GetShortName(ReferenceCollector refs) { Type type = unprojectedType; refs.AddReference(type); string name = GetAbiTypeShortName(type); if (type.GenericTypeArguments.Count() > 0) { name += "<" + String.Join(", ", type.GenericTypeArguments.Where( typeArg => AbiTypeRuntimeClass.IsValidType(typeArg) ).Select(typeArgument => (new AbiTypeRuntimeClass(typeArgument)).GetShortName(refs) )) + ">"; } return(name); }
public string GetParameters(ReferenceCollector refs, bool commentOutParamNames = false, bool shortNames = true) { List <string> parameters = this.methodInfo.GetParameters().Where( parameter => AbiTypeRuntimeClass.IsValidType(parameter.ParameterType) ).Select(parameter => { string paramName = parameter.Name; if (commentOutParamNames) { paramName = "/* " + paramName + " */"; } IAbiType paramType = (new AbiTypeRuntimeClass(parameter.ParameterType)).DefaultInterface; string paramTypeName = ""; if (parameter.IsIn) { paramTypeName = shortNames ? paramType.GetShortNameAsInParam(refs) : paramType.GetFullNameAsInParam(refs); } else { paramTypeName = shortNames ? paramType.GetShortNameAsOutParam(refs) : paramType.GetFullNameAsOutParam(refs); } return(paramTypeName + " " + paramName); }).ToList(); if (methodInfo.ReturnType != null && methodInfo.ReturnType.Name != "Void") { string paramName = "value"; if (commentOutParamNames) { paramName = "/* " + paramName + " */"; } var defaultInterface = (new AbiTypeRuntimeClass(methodInfo.ReturnType)).DefaultInterface; string paramType = shortNames ? defaultInterface.GetShortNameAsOutParam(refs) : defaultInterface.GetFullNameAsOutParam(refs); parameters.Add(paramType + " " + paramName); } return(String.Join(", ", parameters)); }
public AbiTypeRuntimeClassFactory(AbiTypeRuntimeClass innerClass) { this.innerClass = innerClass; }