Пример #1
0
        static private Entity?GetEntity(DatastoreModel datastore, IEnumerable <string> labels)
        {
            Entity?entity = null;

            foreach (string label in labels)
            {
                entity = entityByLabel.TryGetOrAdd(label, key => datastore.Entities.FirstOrDefault(item => item.Label.Name == label));
                if (!entity.IsAbstract)
                {
                    return(entity);
                }
            }
            return(null);
        }
 internal override SchemaInfo GetSchemaInfo(DatastoreModel datastoreModel) => new SchemaInfo(datastoreModel);
Пример #3
0
 internal SchemaInfo(DatastoreModel model)
 {
     Model = model;
     Initialize();
 }
Пример #4
0
 internal SchemaInfo_v4(DatastoreModel model) : base(model)
 {
 }
Пример #5
0
 internal virtual SchemaInfo GetSchemaInfo(DatastoreModel datastoreModel) => new SchemaInfo(datastoreModel);
Пример #6
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            List <Relationship>   relationships = new List <Relationship>();
            List <EntityTreeNode> entities      = tvEntities.Nodes.Cast <EntityTreeNode>().ToList().Select(x => x).ToList();

            List <Entity> parentEntities = new List <Entity>();

            entities.ForEach((node) =>
            {
                if (node.Loaded == false)
                {
                    node.LoadInheritance();
                    node.LoadRelationship();
                }

                parentEntities.AddRange(node.InheritNode.Nodes.Cast <InheritedEntityTreeNode>().ToList().Where(entity => parentEntities.Any(added => added.Guid == entity.Entity.Guid) == false).Select(x => x.Entity));
                relationships.AddRange(node.RelationshipNode.Nodes.Cast <RelationshipTreeNode>().ToList().Where(rel => relationships.Any(added => added.Name == rel.Relationship.Name) == false).Select(x => x.Relationship));
            });

            Dictionary <Guid, Entity> functionalIdByentities = EntitiesLookUp.Where(x => string.IsNullOrEmpty(x.Value.FunctionalId) == false).GroupBy(x => x.Value.FunctionalId).Select(x => x.FirstOrDefault()).ToDictionary(x => Guid.Parse(x.Value.FunctionalId), y => y.Value);
            List <Entity>             sortedResult           = SortDependencyEntities(entities.Select(x => x.Entity).ToList(), parentEntities);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("using System;");
            sb.AppendLine("using System.Text;");
            sb.AppendLine("using System.Linq;");
            sb.AppendLine("using System.Collections.Generic;");
            sb.AppendLine("using Blueprint41;");
            sb.AppendLine("using Blueprint41.Core;");
            sb.AppendLine("using Blueprint41.Neo4j.Persistence;");
            sb.AppendLine("using Blueprint41.Dynamic;");
            sb.AppendLine("");
            sb.AppendLine("namespace Datastore");
            sb.AppendLine("{");
            sb.AppendLine("    public partial class GbmModelTestV2 : DatastoreModel<GbmModelTestV2>");
            sb.AppendLine("    {");
            sb.AppendLine("        protected override void SubscribeEventHandlers()");
            sb.AppendLine("        {");
            sb.AppendLine("             throw new NotImplementedException();");
            sb.AppendLine("        }");
            sb.AppendLine("");
            sb.AppendLine("        protected override void InitializeEntities()");
            sb.AppendLine("        {");

            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                this.SelectedPath = fbd.SelectedPath;

                T4Template = new DatastoreModel();
                T4Template.FunctionalIds = Model.FunctionalIds.FunctionalId.Where(x => functionalIdByentities.ContainsKey(Guid.Parse(x.Guid)) || x.IsDefault == true).ToList();
                T4Template.Modeller      = Model;
                T4Template.Entities      = sortedResult;
                T4Template.Relationships = relationships;
                string output = T4Template.TransformText();

                sb.Append(output);
                sb.AppendLine();

                sb.AppendLine("        }");
                sb.AppendLine("    }");
                sb.AppendLine("}");

                string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this.SelectedPath, string.Format("{0}.cs", "DatastoreModel"));
                using (FileStream fs = File.Create(path))
                {
                    Byte[] info = new UTF8Encoding(true).GetBytes(sb.ToString());
                    fs.Write(info, 0, info.Length);
                }
                MessageBox.Show("Entities Generated on " + SelectedPath, "Generated", MessageBoxButtons.OK);
            }
        }