public string Export(ScriptExportType exportType) { if (exportType.DeclaringType != null) { throw new NotSupportedException("You can export only topmost types"); } if (IsBuiltInType(exportType)) { return(null); } string subPath = GetExportSubPath(exportType); string filePath = Path.Combine(m_exportPath, subPath); string uniqueFilePath = ToUniqueFileName(filePath); string directory = Path.GetDirectoryName(uniqueFilePath); if (!DirectoryUtils.Exists(directory)) { DirectoryUtils.CreateVirtualDirectory(directory); } using (Stream fileStream = FileUtils.CreateVirtualFile(uniqueFilePath)) { using (StreamWriter writer = new InvariantStreamWriter(fileStream, new UTF8Encoding(false))) { exportType.Export(writer); } } AddExportedType(exportType); return(uniqueFilePath); }
public string Export(ScriptExportType exportType) { if (exportType.DeclaringType != null) { throw new NotSupportedException("You can export only topmost types"); } if (IsBuiltInType(exportType)) { return(null); } string subPath = GetExportSubPath(exportType); string filePath = Path.Combine(m_exportPath, subPath); string directory = Path.GetDirectoryName(filePath); if (!DirectoryUtils.Exists(directory)) { DirectoryUtils.CreateDirectory(directory); } using (FileStream file = FileUtils.OpenWrite(filePath)) { using (StreamWriter writer = new StreamWriter(file)) { exportType.Export(writer); } } AddExportedType(exportType); return(filePath); }
private static string GetExportSubPath(ScriptExportType type) { string typeName = type.NestedName; int index = typeName.IndexOf('<'); if (index >= 0) { string normalName = typeName.Substring(0, index); typeName = normalName + $".{typeName.Count(t => t == ',') + 1}"; } return(GetExportSubPath(type.Module, type.Namespace, typeName)); }
private static bool IsBuiltInType(ScriptExportType type) { if (IsDotNetLibrary(type.Module)) { return(true); } if (IsUnityLibrary(type.Module)) { return(true); } return(false); }
public string GetTypeNestedName(ScriptExportType relativeType) { string typeName = TypeName; if (DeclaringType == null) { return(TypeName); } if (relativeType == DeclaringType) { return(TypeName); } string declaringName = NestType.GetTypeNestedName(relativeType); return($"{declaringName}.{typeName}"); }
private void AddExportedType(ScriptExportType exportType) { m_exported.Add(exportType.FullName); foreach (ScriptExportEnum nestedEnum in exportType.NestedEnums) { m_exported.Add(nestedEnum.FullName); } foreach (ScriptExportDelegate @delegate in exportType.Delegates) { m_exported.Add(@delegate.FullName); } foreach (ScriptExportType nestedType in exportType.NestedTypes) { AddExportedType(nestedType); } }
public string GetTypeNestedName(ScriptExportType relativeType) { if(relativeType == null) { return Name; } if (ScriptType.IsEngineObject(Namespace, Name)) { return $"{Namespace}.{Name}"; } if (DeclaringType == null) { return TypeName; } if (relativeType == DeclaringType) { return TypeName; } string declaringName = DeclaringType.GetTypeNestedName(relativeType); return $"{declaringName}.{TypeName}"; }
public string GetTypeNestedName(ScriptExportType relativeType) { if (relativeType == null) { return(NestedName); } if (SerializableType.IsEngineObject(Namespace, NestedName)) { return($"{Namespace}.{NestedName}"); } if (DeclaringType == null) { return(TypeName); } if (relativeType == DeclaringType) { return(TypeName); } string declaringName = NestType.GetTypeNestedName(relativeType); return($"{declaringName}.{TypeName}"); }
public ScriptExportType CreateExportType(TypeReference type) { ScriptExportType exportType = RetrieveType(type); return(exportType); }
private static bool IsBuiltInType(ScriptExportType type) { return(IsBuiltInLibrary(type.Module)); }