public override void GetContent(CompilerContext context, ParseTreeNode parseNode) { #region Get the optional type list if (parseNode.ChildNodes[1].HasChildNodes()) { _TypesToDump = ((parseNode.ChildNodes[1].ChildNodes[1].AstNode as TypeListNode).Types).Select(tlnode => tlnode.TypeName).ToList(); } #endregion _DumpType = (parseNode.ChildNodes[2].AstNode as DumpTypeNode).DumpType; _DumpFormat = (parseNode.ChildNodes[3].AstNode as DumpFormatNode).DumpFormat; _DumpableGrammar = context.Compiler.Language.Grammar as IDumpable; if (_DumpableGrammar == null) { throw new GraphDBException(new Error_NotADumpableGrammar(context.Compiler.Language.Grammar.GetType().ToString())); } if (parseNode.ChildNodes[4].HasChildNodes()) { _DumpDestination = parseNode.ChildNodes[4].ChildNodes[1].Token.ValueString; } }
public IEnumerable <string> ExportGraphDML(DumpFormats myDumpFormat, IEnumerable <IVertexType> myVertexTypesToDump, SecurityToken mySecurityToken, Int64 myTransactionToken) { throw new NotImplementedException(); }
public void Init(ParsingContext context, ParseTreeNode parseNode) { #region Get the optional type list if (HasChildNodes(parseNode.ChildNodes[1])) { _TypesToDump = ((parseNode.ChildNodes[1].ChildNodes[1].AstNode as VertexTypeListNode).Types) .Select(tlnode => tlnode.TypeName).ToList(); } #endregion _DumpType = (parseNode.ChildNodes[2].AstNode as DumpTypeNode).DumpType; _DumpFormat = (parseNode.ChildNodes[3].AstNode as DumpFormatNode).DumpFormat; _DumpableGrammar = context.Parser.Language.Grammar as IDumpable; if (_DumpableGrammar == null) { throw new NotADumpableGrammarException(context.Parser.Language.Grammar.GetType().ToString(), ""); } if (HasChildNodes(parseNode.ChildNodes[4])) { _DumpDestination = parseNode.ChildNodes[4].ChildNodes[1].Token.ValueString; } }
static void Save(Image <Rgba32> image, string pathWithoutExtension, DumpFormats formats, IList <ExportedImageInfo> filenames) { if ((formats & DumpFormats.Png) != 0) { var path = Path.ChangeExtension(pathWithoutExtension, "png"); using var stream = File.OpenWrite(path); image.SaveAsPng(stream); filenames.Add(new ExportedImageInfo { Path = path, Format = DumpFormats.Png, Width = image.Width, Height = image.Height }); } }
public void Init(ParsingContext context, ParseTreeNode parseNode) { #region Get the optional type list if (HasChildNodes(parseNode.ChildNodes[1])) { _TypesToDump = ((parseNode.ChildNodes[1].ChildNodes[1].AstNode as VertexTypeListNode).Types) .Select(tlnode => tlnode.TypeName).ToList(); } #endregion _DumpType = (parseNode.ChildNodes[2].AstNode as DumpTypeNode).DumpType; _DumpFormat = (parseNode.ChildNodes[3].AstNode as DumpFormatNode).DumpFormat; _DumpableGrammar = context.Parser.Language.Grammar as IDumpable; if (_DumpableGrammar == null) throw new NotADumpableGrammarException(context.Parser.Language.Grammar.GetType().ToString(), ""); if (HasChildNodes(parseNode.ChildNodes[4])) _DumpDestination = parseNode.ChildNodes[4].ChildNodes[1].Token.ValueString; }
public void Init(ParsingContext context, ParseTreeNode parseNode) { var _GraphQL = context.Parser.Language.Grammar; if (HasChildNodes(parseNode)) { var _Terminal = parseNode.ChildNodes[1].Token.Terminal; if (_Terminal == _GraphQL.ToTerm("GQL")) { DumpFormat = DumpFormats.GQL; } else { throw new InvalidDumpFormatException(_Terminal.ToString(), ""); } } else { DumpFormat = DumpFormats.GQL; } }
public void GetContent(CompilerContext context, ParseTreeNode parseNode) { var _GraphQL = GetGraphQLGrammar(context); if (parseNode.HasChildNodes()) { var _Terminal = parseNode.ChildNodes[1].Token.Terminal; if (_Terminal == _GraphQL.S_GQL) { DumpFormat = DumpFormats.GQL; } else { throw new GraphDBException(new Errors.Error_InvalidDumpFormat(_Terminal.DisplayName)); } } else { DumpFormat = DumpFormats.GQL; } }
public DumpGraphics(DumpFormats formats) => _formats = formats;
private Exceptional<String> CreateGraphDMLforDBObjectUndefinedAttributes(DumpFormats myDumpFormat, IDictionary<String, IObject> myAttributes, GraphDBType myGraphDBType, DBObjectStream myDBObjectStream) { var stringBuilder = new StringBuilder(); var delimiter = ", "; foreach (var attribute in myAttributes) { #region A single value... if (attribute.Value is ADBBaseObject) { stringBuilder.Append(String.Concat(attribute.Key, " = ", CreateGraphDMLforADBBaseObject(myDumpFormat, attribute.Value as ADBBaseObject))); } #endregion #region ..or, it is a List or Set, since the Set constraint was already verified we can use a list else if (attribute.Value is IBaseEdge) { stringBuilder.Append(String.Concat(attribute.Key, " = ", S_LISTOF.ToUpperString(), " ", S_BRACKET_LEFT)); foreach (var val in (attribute.Value as IBaseEdge)) { stringBuilder.Append(CreateGraphDMLforADBBaseObject(myDumpFormat, val as ADBBaseObject) + delimiter); } stringBuilder.RemoveSuffix(delimiter); stringBuilder.Append(S_BRACKET_RIGHT); } #endregion else { return new Exceptional<String>(new Error_NotImplemented(new StackTrace(true))); } stringBuilder.Append(delimiter); } return new Exceptional<String>(stringBuilder.ToString()); }
private Exceptional<String> CreateGraphDMLforDBObjectDefinedAttributes(DumpFormats myDumpFormat, IDictionary<AttributeUUID, IObject> myAttributes, GraphDBType myGraphDBType, DBObjectStream myDBObjectStream, DBContext myDBContext) { var stringBuilder = new StringBuilder(); var delimiter = ", "; foreach (var attribute in myAttributes) { if (attribute.Value == null) { continue; } var typeAttribute = myGraphDBType.GetTypeAttributeByUUID(attribute.Key); #region Reference attributes if (typeAttribute.GetDBType(myDBContext.DBTypeManager).IsUserDefined) { #region IReferenceEdge if (attribute.Value is ASetOfReferencesEdgeType) { #region Create edge GDML stringBuilder.Append(String.Concat(typeAttribute.Name, " = ", S_SETOFUUIDS.ToUpperString(), " ", S_BRACKET_LEFT)); //myEdgeBuilder.Append(String.Concat(typeAttribute.Name, " = ", S_SETOF.ToUpperString(), " ", S_BRACKET_LEFT)); #region Create an assignment content - if edge does not contain any elements create an empty one if ((attribute.Value as ASetOfReferencesEdgeType).GetAllReferenceIDs().CountIsGreater(0)) { if (attribute.Value is ASetOfReferencesWithInfoEdgeType) { #region Create attribute assignments foreach (var val in (attribute.Value as ASetOfReferencesWithInfoEdgeType).GetAllReferenceIDsWeighted()) { stringBuilder.Append(String.Concat("'", val.Item1.ToString(), "'")); if (val.Item2 != null) { stringBuilder.Append(String.Concat(S_colon, S_BRACKET_LEFT, CreateGraphDMLforADBBaseObject(myDumpFormat, val.Item2), S_BRACKET_RIGHT)); } stringBuilder.Append(delimiter); } stringBuilder.RemoveSuffix(delimiter); #endregion } else { #region Create an assignment content - if edge does not contain any elements create an empty one if ((attribute.Value as ASetOfReferencesEdgeType).GetAllReferenceIDs().CountIsGreater(0)) { #region Create attribute assignments foreach (var val in (attribute.Value as ASetOfReferencesEdgeType).GetAllReferenceIDs()) { stringBuilder.Append(String.Concat("'", val.ToString(), "'")); stringBuilder.Append(delimiter); } stringBuilder.RemoveSuffix(delimiter); #endregion } #endregion } } #endregion stringBuilder.Append(S_BRACKET_RIGHT); #endregion } #endregion #region SingleReference else if (typeAttribute.KindOfType == KindsOfType.SingleReference) { stringBuilder.Append(String.Concat(typeAttribute.Name, " = ", S_REFUUID.ToUpperString(), " ", S_BRACKET_LEFT)); stringBuilder.Append(String.Concat("'", (attribute.Value as ASingleReferenceEdgeType).GetUUID().ToString(), "'")); stringBuilder.Append(S_BRACKET_RIGHT); } #endregion else { return new Exceptional<String>(new Error_NotImplemented(new System.Diagnostics.StackTrace(true))); } stringBuilder.Append(delimiter); } #endregion #region NonReference attributes else { #region ListOfNoneReferences if (typeAttribute.KindOfType == KindsOfType.ListOfNoneReferences) { stringBuilder.Append(String.Concat(typeAttribute.Name, " = ", S_LISTOF.ToUpperString(), " ", S_BRACKET_LEFT)); foreach (var val in (attribute.Value as IBaseEdge)) { stringBuilder.Append(CreateGraphDMLforADBBaseObject(myDumpFormat, val as ADBBaseObject) + delimiter); } stringBuilder.RemoveSuffix(delimiter); stringBuilder.Append(S_BRACKET_RIGHT); } #endregion #region SetOfNoneReferences else if (typeAttribute.KindOfType == KindsOfType.SetOfNoneReferences) { stringBuilder.Append(String.Concat(typeAttribute.Name, " = ", S_SETOF.ToUpperString(), " ", S_BRACKET_LEFT)); foreach (var val in (attribute.Value as IBaseEdge)) { stringBuilder.Append(CreateGraphDMLforADBBaseObject(myDumpFormat, val as ADBBaseObject) + delimiter); } stringBuilder.RemoveSuffix(delimiter); stringBuilder.Append(S_BRACKET_RIGHT); } #endregion #region SpecialAttribute else if (typeAttribute.KindOfType == KindsOfType.SpecialAttribute) { throw new GraphDBException(new Error_NotImplemented(new System.Diagnostics.StackTrace(true))); } #endregion #region Single value else { stringBuilder.Append(String.Concat(typeAttribute.Name, " = ", CreateGraphDMLforADBBaseObject(myDumpFormat, attribute.Value as ADBBaseObject))); } #endregion stringBuilder.Append(delimiter); } #endregion } return new Exceptional<String>(stringBuilder.ToString()); }
private Exceptional<String> CreateGraphDMLforDBObject(DumpFormats myDumpFormat, DBContext myDBContext, GraphDBType myGraphDBType, DBObjectStream myDBObjectStream) { var stringBuilder = new StringBuilder(); var delimiter = ", "; stringBuilder.Append(String.Concat(S_INSERT.ToUpperString(), " ", S_INTO.ToUpperString(), " ", myGraphDBType.Name, " ", S_VALUES.ToUpperString(), " ", S_BRACKET_LEFT)); stringBuilder.Append(String.Concat(S_UUID.ToUpperString(), " = '", myDBObjectStream.ObjectUUID.ToString(), "'", delimiter)); #region CreateGraphDMLforDBODefinedAttributes var defAttrsDML = CreateGraphDMLforDBObjectDefinedAttributes(myDumpFormat, myDBObjectStream.GetAttributes(), myGraphDBType, myDBObjectStream, myDBContext); if (!defAttrsDML.Success()) { return defAttrsDML; } stringBuilder.Append(defAttrsDML.Value); #endregion #region CreateGDMLforDBOUnDefinedAttributes var undefAttrs = myDBObjectStream.GetUndefinedAttributes(myDBContext.DBObjectManager); if (!undefAttrs.Success()) { return new Exceptional<String>(undefAttrs); } if (undefAttrs.Value.Count > 0) { Exceptional<String> undefAttrsDML = CreateGraphDMLforDBObjectUndefinedAttributes(myDumpFormat, undefAttrs.Value, myGraphDBType, myDBObjectStream); if (!undefAttrsDML.Success()) { return undefAttrsDML; } stringBuilder.Append(undefAttrsDML.Value); } #endregion stringBuilder.RemoveSuffix(delimiter); stringBuilder.Append(S_BRACKET_RIGHT); return new Exceptional<String>(stringBuilder.ToString()); }
private String CreateGraphDMLforADBBaseObject(DumpFormats myDumpFormat, ADBBaseObject myADBBaseObject) { var dbNumber = myADBBaseObject as DBNumber; if (dbNumber != null) return dbNumber.ToString(new CultureInfo("en-US")); return String.Concat("'", myADBBaseObject.ToString(new CultureInfo("en-US")), "'"); }
public static IList <ExportedImageInfo> ExportImage(AssetId assetId, IAssetManager assets, string directory, DumpFormats formats, Func <int, int, bool> frameFilter = null) { var filenames = new List <ExportedImageInfo>(); var config = assets.GetAssetInfo(assetId); var palette = assets.LoadPalette((Base.Palette)(config?.Get <int?>("PaletteHint", null) ?? (int)Base.Palette.Inventory)); var texture = assets.LoadTexture(assetId); if (texture == null) { return(filenames); } if (texture is TrueColorTexture trueColor) { var path = Path.Combine(directory, $"{assetId.Id}_{assetId}"); var image = trueColor.ToImage(); Save(image, path, formats, filenames); } else if (texture is VeldridEightBitTexture tilemap && ( assetId.Type == AssetType.Font || assetId.Type == AssetType.TilesetGraphics || assetId.Type == AssetType.AutomapGraphics)) { if (palette == null) { CoreUtil.LogError($"Could not load palette for {assetId}"); return(filenames); } var colors = tilemap.DistinctColors(null); int palettePeriod = palette.CalculatePeriod(colors); for (int palFrame = 0; palFrame < palettePeriod; palFrame++) { if (frameFilter != null && !frameFilter(0, palFrame)) { continue; } var path = Path.Combine(directory, $"{assetId.Id}_{palFrame}_{assetId}"); var image = tilemap.ToImage(palette.GetPaletteAtTime(palFrame)); Save(image, path, formats, filenames); } }
/// <summary> /// Exports the types /// </summary> /// <param name="myDumpFormat">The dump format.</param> /// <param name="myVertexTypesToDump">The vertex types to dump.</param> /// <param name="myEdgeTypesToDump">The edge types to dump.</param> public IEnumerable<String> ExportGraphDDL(DumpFormats myDumpFormat, IEnumerable<IVertexType> myVertexTypesToDump, IEnumerable<IEdgeType> myEdgeTypesToDump) { StringBuilder vertexStringBuilder; StringBuilder edgeStringBuilder; var delimiter = ", "; #region CREATE EDGE TYPE / TYPES if (myEdgeTypesToDump.Count() == 0) edgeStringBuilder = new StringBuilder(); else if (myEdgeTypesToDump.Count() > 1) edgeStringBuilder = new StringBuilder(String.Concat(S_CREATE.ToUpperString(), " ", S_EDGE.ToUpperString(), " ", S_TYPES.ToUpperString(), " ")); else edgeStringBuilder = new StringBuilder(String.Concat(S_CREATE.ToUpperString(), " ", S_EDGE.ToUpperString(), " ", S_TYPE.ToUpperString(), " ")); #endregion #region go threw each type and add attributes foreach (var edgeType in myEdgeTypesToDump) { edgeStringBuilder.Append(String.Concat(CreateGraphDDL_EdgeType(edgeType), delimiter)); } #endregion //z.B. Create vertex type User Attributes (String Name, LIST<Tags> Hobbies) var edgeRetString = edgeStringBuilder.ToString(); #region remove ending if (edgeRetString.EndsWith(delimiter)) { edgeRetString = edgeRetString.Substring(0, edgeRetString.Length - delimiter.Length); } //no attributes found so set string to empty if (edgeRetString.EndsWith("TYPES") || edgeRetString.EndsWith("TYPE")) { edgeRetString = String.Empty; } #endregion #region CREATE VERTEX TYPE / TYPES if(myVertexTypesToDump.Count() == 0) vertexStringBuilder = new StringBuilder(); else if (myVertexTypesToDump.Count() > 1) vertexStringBuilder = new StringBuilder(String.Concat(S_CREATE.ToUpperString(), " ", S_VERTEX.ToUpperString(), " ", S_TYPES.ToUpperString(), " ")); else vertexStringBuilder = new StringBuilder(String.Concat(S_CREATE.ToUpperString(), " ", S_VERTEX.ToUpperString(), " ", S_TYPE.ToUpperString(), " ")); #endregion #region go threw each type and add attributes foreach (var vertexType in myVertexTypesToDump) { vertexStringBuilder.Append(String.Concat(CreateGraphDDL_VertexType(vertexType), delimiter)); } #endregion //z.B. Create vertex type User Attributes (Int64 Age, String Name, Set<User> Friends, User Father, LIST<String> Hobbies, Set<User(Weighted)> weightedUser) var vertexRetString = vertexStringBuilder.ToString(); #region remove ending if (vertexRetString.EndsWith(delimiter)) { vertexRetString = vertexRetString.Substring(0, vertexRetString.Length - delimiter.Length); } //no attributes found so set string to empty if (vertexRetString.EndsWith("TYPES") || vertexRetString.EndsWith("TYPE")) { vertexRetString = String.Empty; } #endregion var result = new List<String>(); if(!String.IsNullOrWhiteSpace(edgeRetString)) result.Add(edgeRetString); if (!String.IsNullOrWhiteSpace(vertexRetString)) result.Add(vertexRetString); return result; }
private String CreateGraphDDLOfAttributeDefinition(DumpFormats myDumpFormat, TypeAttribute myTypeAttribute, DBContext myDBContext) { if (myTypeAttribute.EdgeType != null) { return String.Concat(myTypeAttribute.EdgeType.GetGDDL(myTypeAttribute.GetDBType(myDBContext.DBTypeManager)), " ", myTypeAttribute.Name); } else { return String.Concat(myTypeAttribute.GetDBType(myDBContext.DBTypeManager).Name, " ", myTypeAttribute.Name); } }
private String CreateGraphDDLOfAttributes(DumpFormats myDumpFormat, IEnumerable<TypeAttribute> myTypeAttributes, DBContext myDBContext) { var stringBuilder = new StringBuilder(); var delimiter = ", "; foreach (var _Attribute in myTypeAttributes) { stringBuilder.Append(CreateGraphDDLOfAttributeDefinition(myDumpFormat, _Attribute, myDBContext)); stringBuilder.Append(delimiter); } if (stringBuilder.Length > delimiter.Length) { stringBuilder.Remove(stringBuilder.Length - delimiter.Length, 2); } return stringBuilder.ToString(); }
private String CreateGraphDDL(DumpFormats myDumpFormat, GraphDBType myGraphDBType, DBContext myDBContext) { var stringBuilder = new StringBuilder(); stringBuilder.AppendFormat("{0} ", myGraphDBType.Name); if (myGraphDBType.ParentTypeUUID != null) { stringBuilder.AppendFormat("{0} {1} ", S_EXTENDS.ToUpperString(), myGraphDBType.GetParentType(myDBContext.DBTypeManager).Name);//builder.AppendLine(); #region Not backwardEdge attributes if (myGraphDBType.GetFilteredAttributes(ta => !ta.IsBackwardEdge).CountIsGreater(0)) { stringBuilder.Append(S_ATTRIBUTES.ToUpperString() + S_BRACKET_LEFT.ToUpperString() + CreateGraphDDLOfAttributes(myDumpFormat, myGraphDBType.GetFilteredAttributes(ta => !ta.IsBackwardEdge), myDBContext) + S_BRACKET_RIGHT.ToUpperString() + " "); } #endregion #region BackwardEdge attributes if (myGraphDBType.GetFilteredAttributes(ta => ta.IsBackwardEdge).CountIsGreater(0)) { stringBuilder.Append(S_BACKWARDEDGES.ToUpperString() + S_BRACKET_LEFT.ToUpperString() + CreateGraphDDLOfBackwardEdges(myDumpFormat, myGraphDBType.GetFilteredAttributes(ta => ta.IsBackwardEdge), myDBContext) + S_BRACKET_RIGHT.ToUpperString() + " "); } #endregion #region Uniques if (myGraphDBType.GetUniqueAttributes().CountIsGreater(0)) { stringBuilder.Append(S_UNIQUE.ToUpperString() + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfAttributeUUIDs(myDumpFormat, myGraphDBType.GetUniqueAttributes(), myGraphDBType) + S_BRACKET_RIGHT.Symbol + " "); } #endregion #region Mandatory attributes if (myGraphDBType.GetMandatoryAttributes().CountIsGreater(0)) { stringBuilder.Append(S_MANDATORY.ToUpperString() + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfAttributeUUIDs(myDumpFormat, myGraphDBType.GetMandatoryAttributes(), myGraphDBType) + S_BRACKET_RIGHT.Symbol + " "); } #endregion #region Indices if (myGraphDBType.GetAllAttributeIndices(false).CountIsGreater(0)) { stringBuilder.Append(S_INDICES.ToUpperString() + S_BRACKET_LEFT.Symbol + CreateGraphDDLOfIndices(myDumpFormat, myGraphDBType.GetAllAttributeIndices(false), myGraphDBType) + S_BRACKET_RIGHT.Symbol + " "); } #endregion } return stringBuilder.ToString(); }
/// <summary> /// Create the GraphDML of all DBObjects in the database. /// </summary> /// <param name="myDumpFormat"></param> /// <param name="dbContext"></param> /// <param name="objectManager"></param> /// <returns></returns> public Exceptional<List<String>> ExportGraphDML(DumpFormats myDumpFormat, DBContext dbContext, IEnumerable<GraphDBType> myTypesToDump) { //var _StringBuilder = new StringBuilder(); var queries = new List<String>(); var exceptional = new Exceptional<List<String>>(); #region Go through each type foreach (var graphDBType in myTypesToDump) { var UUIDIdx = graphDBType.GetUUIDIndex(dbContext.DBTypeManager); #region Take UUID index foreach (var aDBO in dbContext.DBObjectCache.LoadListOfDBObjectStreams(graphDBType, UUIDIdx.GetAllUUIDs(graphDBType, dbContext))) { if (!aDBO.Success()) { exceptional.PushIExceptional(aDBO); } else { var gdmlExceptional = CreateGraphDMLforDBObject(myDumpFormat, dbContext, graphDBType, aDBO.Value); if (!gdmlExceptional.Success()) { exceptional.PushIExceptional(aDBO); } else { queries.Add(gdmlExceptional.Value); } } } #endregion } #endregion //_Exceptional.Value = _StringBuilder.ToString(); exceptional.Value = queries; return exceptional; }
public Exceptional<List<String>> ExportGraphDDL(DumpFormats myDumpFormat, DBContext myDBContext, IEnumerable<GraphDBType> myTypesToDump) { var stringBuilder = new StringBuilder(String.Concat(S_CREATE.ToUpperString(), " ", S_TYPES.ToUpperString(), " ")); var delimiter = ", "; foreach (var _GraphDBType in myTypesToDump) { stringBuilder.Append(String.Concat(CreateGraphDDL(myDumpFormat, _GraphDBType, myDBContext), delimiter)); } var retString = stringBuilder.ToString(); if (retString.EndsWith(delimiter)) { retString = retString.Substring(0, retString.Length - delimiter.Length); } return new Exceptional<List<String>>(new List<String>() { retString }); }
public IEnumerable<string> ExportGraphDDL(DumpFormats myDumpFormat, IEnumerable<IVertexType> myVertexTypesToDump, IEnumerable<IEdgeType> myEdgeTypesToDump) { throw new NotImplementedException(); }
/// <summary> /// Exports the types /// </summary> /// <param name="myDumpFormat">The dump format.</param> /// <param name="myTypesToDump">The types to dump.</param> public IEnumerable<String> ExportGraphDDL(DumpFormats myDumpFormat, IEnumerable<IVertexType> myTypesToDump) { StringBuilder stringBuilder; var delimiter = ", "; #region CREATE VERTEX TYPE / TYPES if (myTypesToDump.Count() > 1) stringBuilder = new StringBuilder(String.Concat(S_CREATE.ToUpperString(), " ", S_VERTEX.ToUpperString(), " ", S_TYPES.ToUpperString(), " ")); else stringBuilder = new StringBuilder(String.Concat(S_CREATE.ToUpperString(), " ", S_VERTEX.ToUpperString(), " ", S_TYPE.ToUpperString(), " ")); #endregion #region go threw each type and add attributes foreach (var vertexType in myTypesToDump) { stringBuilder.Append(String.Concat(CreateGraphDDL(vertexType), delimiter)); } #endregion //z.B. Create vertex type User Attributes (Int64 Age, String Name, Set<User> Friends, User Father, LIST<String> Hobbies, Set<User(Weighted)> weightedUser) var retString = stringBuilder.ToString(); #region remove ending if (retString.EndsWith(delimiter)) { retString = retString.Substring(0, retString.Length - delimiter.Length); } //no attributes found so set string to empty if (retString.EndsWith("TYPES") || retString.EndsWith("TYPE")) { retString = String.Empty; } #endregion return new List<String> { retString }; }
public IEnumerable<string> ExportGraphDML(DumpFormats myDumpFormat, IEnumerable<IVertexType> myVertexTypesToDump, SecurityToken mySecurityToken, Int64 myTransactionToken) { throw new NotImplementedException(); }
public IList <ExportedImageInfo> ExportImage( AssetId assetId, IAssetManager assets, string directory, DumpFormats formats, Func <int, int, bool> frameFilter = null) { var filenames = new List <ExportedImageInfo>(); var config = assets.GetAssetInfo(assetId); AlbionPalette palette; if (config != null) { var rawPaletteId = config.Get(AssetProperty.PaletteId, 0); var paletteId = new PaletteId(AssetType.Palette, rawPaletteId); palette = assets.LoadPalette(paletteId); } else { palette = assets.LoadPalette(Base.Palette.Inventory); } var texture = assets.LoadTexture(assetId); if (texture == null) { return(filenames); } if (texture is IReadOnlyTexture <uint> trueColor) { var path = Path.Combine(directory, $"{assetId.Id}_{assetId}"); var image = ImageSharpUtil.ToImageSharp(trueColor.GetLayerBuffer(0)); Save(image, path, formats, filenames); } else if (texture is IReadOnlyTexture <byte> tilemap && ( assetId.Type == AssetType.Font || assetId.Type == AssetType.TilesetGraphics || assetId.Type == AssetType.AutomapGraphics)) { if (palette == null) { Error($"Could not load palette for {assetId}"); return(filenames); } var colors = BlitUtil.DistinctColors(tilemap.PixelData); int palettePeriod = palette.CalculatePeriod(colors); for (int palFrame = 0; palFrame < palettePeriod; palFrame++) { if (frameFilter != null && !frameFilter(0, palFrame)) { continue; } var path = Path.Combine(directory, $"{assetId.Id}_{palFrame}_{assetId}"); var image = ImageSharpUtil.ToImageSharp(tilemap.GetLayerBuffer(0), palette.GetPaletteAtTime(palFrame)); Save(image, path, formats, filenames); } } else if (texture is IReadOnlyTexture <byte> eightBit) { for (int subId = 0; subId < eightBit.Regions.Count; subId++) { if (palette == null) { Error($"Could not load palette for {assetId}"); break; } var colors = BlitUtil.DistinctColors(eightBit.GetRegionBuffer(subId)); int palettePeriod = palette.CalculatePeriod(colors); for (int palFrame = 0; palFrame < palettePeriod; palFrame++) { if (frameFilter != null && !frameFilter(subId, palFrame)) { continue; } var path = Path.Combine(directory, $"{assetId.Id}_{subId}_{palFrame}_{assetId}"); var image = ImageSharpUtil.ToImageSharp(eightBit.GetRegionBuffer(subId), palette.GetPaletteAtTime(palFrame)); Save(image, path, formats, filenames); } } } else { var path = Path.Combine(directory, $"{assetId.Id}_{assetId}.png.todo"); File.WriteAllText(path, ""); return(null); } return(filenames); }
public IEnumerable <string> ExportGraphDDL(DumpFormats myDumpFormat, IEnumerable <IVertexType> myVertexTypesToDump, IEnumerable <IEdgeType> myEdgeTypesToDump) { throw new NotImplementedException(); }
public void Dump(string baseDir, ISet <AssetType> types, DumpFormats formats, AssetId[] dumpIds) { void Export <TEnum>(string name) where TEnum : unmanaged, Enum { var directory = Path.Combine(baseDir, "data", "exported", "gfx", name); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } var ids = Enum.GetValues(typeof(TEnum)).OfType <TEnum>().ToArray(); Console.WriteLine($"Dumping {ids.Length} assets to {directory}..."); var assets = Resolve <IAssetManager>(); foreach (var id in ids) { var assetId = AssetId.From(id); if (dumpIds != null && !dumpIds.Contains(assetId)) { continue; } ExportImage(assetId, assets, directory, formats, (frame, palFrame) => palFrame < 10); // Limit to 10, some of the tile sets can get a bit silly. } } foreach (var type in types) { switch (type) { // case AssetType.Slab: Export<Base.Slab> ("SLAB"); break; case AssetType.AutomapGraphics: Export <Base.AutomapTiles> ("Automap"); break; case AssetType.CombatBackground: Export <Base.CombatBackground> ("CombatBackgrounds"); break; case AssetType.CombatGraphics: Export <Base.CombatGraphics> ("Combat"); break; case AssetType.CoreGraphics: Export <Base.CoreSprite> ("Core"); break; case AssetType.BackgroundGraphics: Export <Base.DungeonBackground>("Backgrounds"); break; case AssetType.Floor: Export <Base.Floor> ("Floors"); break; case AssetType.Object3D: Export <Base.DungeonObject> ("Objects"); break; case AssetType.WallOverlay: Export <Base.WallOverlay> ("Overlays"); break; case AssetType.Wall: Export <Base.Wall> ("Walls"); break; case AssetType.Font: Export <Base.Font> ("Fonts"); break; case AssetType.FullBodyPicture: Export <Base.FullBodyPicture> ("InventoryBackgrounds"); break; case AssetType.TilesetGraphics: Export <Base.TilesetGraphics> ("Tiles"); break; case AssetType.ItemGraphics: Export <Base.ItemGraphics> ("Item"); break; case AssetType.LargeNpcGraphics: Export <Base.LargeNpc> ("NpcLarge"); break; case AssetType.LargePartyGraphics: Export <Base.LargePartyMember> ("PartyLarge"); break; case AssetType.MonsterGraphics: Export <Base.MonsterGraphics> ("Monster"); break; case AssetType.Picture: Export <Base.Picture> ("Picture"); break; case AssetType.SmallNpcGraphics: Export <Base.SmallNpc> ("NpcSmall"); break; case AssetType.SmallPartyGraphics: Export <Base.SmallPartyMember> ("PartySmall"); break; case AssetType.Portrait: Export <Base.Portrait> ("Portrait"); break; case AssetType.TacticalIcon: Export <Base.TacticalGraphics> ("TacticalIcon"); break; } } }
/// <summary> /// Add just the Attribute names /// </summary> /// <param name="myDumpFormat"></param> /// <param name="typeAttribute"></param> /// <param name="indent"></param> /// <param name="indentWidth"></param> /// <returns></returns> private String CreateGraphDDLOfAttributeUUIDs(DumpFormats myDumpFormat, IEnumerable<AttributeUUID> myAttributes, GraphDBType myGraphDBType) { var stringBuilder = new StringBuilder(); var delimiter = ", "; foreach (var _Attribute in myAttributes) { stringBuilder.Append(myGraphDBType.GetTypeAttributeByUUID(_Attribute).Name); stringBuilder.Append(delimiter); } if (stringBuilder.Length > delimiter.Length) { stringBuilder.Remove(stringBuilder.Length - delimiter.Length, 2); } return stringBuilder.ToString(); }
/// <summary> /// Create the DDL for attributeIndices /// </summary> /// <param name="myDumpFormat"></param> /// <param name="myAttributeIndices"></param> /// <param name="indent"></param> /// <param name="indentWidth"></param> /// <returns></returns> private String CreateGraphDDLOfIndices(DumpFormats myDumpFormat, IEnumerable<AAttributeIndex> myAttributeIndices, GraphDBType myGraphDBType) { var _StringBuilder = new StringBuilder(); var _Delimiter = ", "; foreach (var _AttributeIndex in myAttributeIndices) { if (_AttributeIndex is UUIDIndex || _AttributeIndex.IndexEdition == DBConstants.UNIQUEATTRIBUTESINDEX) continue; _StringBuilder.Append(String.Concat(S_BRACKET_LEFT, _AttributeIndex.IndexName)); if (_AttributeIndex.IsUniqueIndex) { _StringBuilder.Append(String.Concat(" ", S_UNIQUE.ToUpperString())); } _StringBuilder.Append(String.Concat(" ", S_EDITION.ToUpperString(), " ", _AttributeIndex.IndexEdition)); _StringBuilder.Append(String.Concat(" ", S_INDEXTYPE.ToUpperString(), " ", _AttributeIndex.IndexType.ToString())); _StringBuilder.Append(String.Concat(" ", S_ON.ToUpperString(), " " + S_ATTRIBUTES.ToUpperString(), " ", CreateGraphDDLOfAttributeUUIDs(myDumpFormat, _AttributeIndex.IndexKeyDefinition.IndexKeyAttributeUUIDs, myGraphDBType))); _StringBuilder.Append(S_BRACKET_RIGHT); _StringBuilder.Append(_Delimiter); } if (_StringBuilder.Length > _Delimiter.Length) { _StringBuilder.Remove(_StringBuilder.Length - _Delimiter.Length, 2); } return _StringBuilder.ToString(); }
/// <summary> /// Create the GraphDML of all DBObjects in the database. /// </summary> /// <param name="myDumpFormat">The dump format.</param> /// <param name="myTypesToDump">The types to dum.</param> /// <param name="mySecurityToken">The security token.</param> /// <param name="myTransactionToken">The transaction token.</param> public IEnumerable<String> ExportGraphDML(DumpFormats myDumpFormat, IEnumerable<IVertexType> myTypesToDump, SecurityToken mySecurityToken, Int64 myTransactionToken) { var queries = new List<String>(); CreateVertexTypesDict(mySecurityToken, myTransactionToken); #region Go through each type foreach (var aVertexType in myTypesToDump) { var propertyDefinitions = aVertexType.GetPropertyDefinitions(true).ToDictionary(key => key.ID, value => value); foreach (var aVertex in GetAllVertices(aVertexType, mySecurityToken, myTransactionToken)) { queries.Add(CreateGraphDMLforIVertex(aVertexType, aVertex, propertyDefinitions)); } } #endregion return queries; }
private String CreateGraphDDLOfBackwardEdges(DumpFormats myDumpFormat, IEnumerable<TypeAttribute> myTypeAttributes, DBContext myDBContext) { var stringBuilder = new StringBuilder(); var delimiter = ", "; foreach (var _Attribute in myTypeAttributes) { var typeAttrInfos = _Attribute.BackwardEdgeDefinition.GetTypeAndAttributeInformation(myDBContext.DBTypeManager); stringBuilder.Append(String.Concat(typeAttrInfos.Item1.Name, ".", typeAttrInfos.Item2.Name, " ", _Attribute.Name)); stringBuilder.Append(delimiter); } if (stringBuilder.Length > delimiter.Length) { stringBuilder.Remove(stringBuilder.Length - delimiter.Length, 2); } return stringBuilder.ToString(); }