Ejemplo n.º 1
0
        public void DeleteAsset(MissionAsset asset)
        {
            Debug.Assert(asset != null, "asset != null");

            EntityDefinition      entity      = asset as EntityDefinition;
            FlightGroupDefinition flightGroup = asset as FlightGroupDefinition;
            FactionDefinition     faction     = asset as FactionDefinition;

            if (entity != null)
            {
                GetFlightGroup(entity.flightGroupId)?.RemoveEntity(entity);
            }
            else if (flightGroup != null)
            {
                faction = GetFaction(flightGroup.factionId);
                if (faction.flightGroups.Count == 1)
                {
                    Debug.Log($"Can't Delete Flight Group {flightGroup.name}, every faction needs at least one flight group");
                    return;
                }
                GetFaction(flightGroup.factionId)?.RemoveFlightGroup(flightGroup);
            }
            else if (faction != null)
            {
                factions.Remove(faction);
            }
            else
            {
                throw new ArgumentException($"Can\'t delete: {asset.GetType().Name}");
            }
            onChange?.Invoke(asset.id);
        }
Ejemplo n.º 2
0
 private static IEntityRecord Create(string name, EntityDefinition definition)
 {
     var e = Entity.Create(name);
     foreach (var c in definition.Parameters.GetComponents())
         e.Add(BuildComponent(c, definition.Parameters));
     return e;
 }
Ejemplo n.º 3
0
        public EntityDefinition CloneEntityDefinition(EntityDefinition toClone)
        {
            EntityDefinition clone = Snapshot <EntityDefinition> .Clone(toClone);

            GetFlightGroup(clone.flightGroupId).AddEntity(clone);
            return(clone);
        }
Ejemplo n.º 4
0
        private void SetControlsFromObject(EntityDefinition def)
        {
            removeButton.Enabled   = true;
            moveUpButton.Enabled   = listBox.SelectedIndex > 0;
            moveDownButton.Enabled = listBox.SelectedIndex < listBox.Items.Count - 1;

            nameTextBox.Enabled         = true;
            limitTextBox.Enabled        = true;
            sizeXTextBox.Enabled        = true;
            sizeYTextBox.Enabled        = true;
            originXTextBox.Enabled      = true;
            originYTextBox.Enabled      = true;
            resizableXCheckBox.Enabled  = true;
            resizableYCheckBox.Enabled  = true;
            rotatableCheckBox.Enabled   = true;
            valuesEditor.Enabled        = true;
            nodesCheckBox.Enabled       = true;
            graphicTypeComboBox.Enabled = true;
            itemGroupComboBox.Enabled   = true;

            //Basics
            nameTextBox.Text    = def.Name;
            limitTextBox.Text   = def.Limit.ToString();
            sizeXTextBox.Text   = def.Size.Width.ToString();
            sizeYTextBox.Text   = def.Size.Height.ToString();
            originXTextBox.Text = def.Origin.X.ToString();
            originYTextBox.Text = def.Origin.Y.ToString();

            //Resizable/rotation
            resizableXCheckBox.Checked    = def.ResizableX;
            resizableYCheckBox.Checked    = def.ResizableY;
            rotatableCheckBox.Checked     = def.Rotatable;
            rotationIncrementTextBox.Text = def.RotateIncrement.ToString();
            RotationFieldsVisible         = def.Rotatable;

            //Nodes
            nodesCheckBox.Checked          = def.NodesDefinition.Enabled;
            nodeLimitTextBox.Text          = def.NodesDefinition.Limit.ToString();
            nodeDrawComboBox.SelectedIndex = (int)def.NodesDefinition.DrawMode;
            nodeGhostCheckBox.Checked      = def.NodesDefinition.Ghost;
            NodesFieldsVisible             = def.NodesDefinition.Enabled;

            //Values
            valuesEditor.SetList(def.ValueDefinitions);

            //Graphic
            graphicTypeComboBox.SelectedIndex = (int)def.ImageDefinition.DrawMode;
            GraphicFieldsVisibility           = (int)def.ImageDefinition.DrawMode;
            rectangleColorChooser.Color       = def.ImageDefinition.RectColor;
            imageFileTextBox.Text             = def.ImageDefinition.ImagePath;
            imageFileTiledCheckBox.Checked    = def.ImageDefinition.Tiled;
            imageFileWarningLabel.Visible     = !CheckImageFile();
            LoadImageFilePreview();

            // Get index of group from group name
            var gntemp = groups.groupNames.Where(ob => ob == def.GroupName);

            itemGroupComboBox.SelectedIndex = (gntemp.Count() > 0 && gntemp.Single() != "") ? itemGroupComboBox.Items.IndexOf(gntemp.Single()) : 0;
        }
Ejemplo n.º 5
0
        public SqlFilterBuilder(DbConnection connection, EntityDefinition entity = null)
        {
            Connection = connection;
            Entity     = entity;

            Parameters      = new List <DbParameter>();
            _FactoryCommand = Connection.CreateCommand();
        }
        public NewMovementCommandWindow(EntityDefinition ent)
        {
            InitializeComponent();

            this.entity = ent;
            CommandDropDown.Items.Add("AccelerateTo");
            CommandDropDown.Items.Add("Turn");
        }
Ejemplo n.º 7
0
 private static void WriteHierarchy(EntityDefinition entity, TextWriter writer)
 {
     foreach (var definition in entity.SubTypes)
     {
         writer.WriteLine("{0},{1},{2}", definition.Name, entity.Name, entity.Instantiable);
         WriteHierarchy(definition, writer);
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Adds a definition to the database if there is not already one with that id in it.
 /// Throws an exception on duplicate key.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="definition"></param>
 public void AddDefinition(string id, EntityDefinition definition)
 {
     if (_definitionDict.ContainsKey(id))
     {
         throw new System.Exception("Database already contains a definition with this key.");
     }
     _definitionDict[id] = definition;
 }
Ejemplo n.º 9
0
        public MovementPanel(EntityDefinition entityDefinition)
        {
            InitializeComponent();

            this.entity = entityDefinition;

            Redraw();
        }
Ejemplo n.º 10
0
 private void FillDocument(EntityDefinition entityDef, JObject doc, object entity)
 {
     EntityPropertyDefinition[] docWritePropOrder = OrderPropertiesForDocumentWriting(entityDef.Properties);
     foreach (EntityPropertyDefinition propDef in docWritePropOrder)
     {
         propDef.Write(entity, doc);
     }
 }
Ejemplo n.º 11
0
    public static Entity BuildNewEntity(EntityDefinition definition)
    {
        Entity returnEntity = new Entity();

        returnEntity.Name             = definition.Name;
        returnEntity.Stats            = new Dictionary <Stat, int>(definition.BaseStats);
        returnEntity.EntityDefinition = definition;
        return(returnEntity);
    }
    public override void OnApplyingModule(EntityDefinition entity)
    {
        var definitionAttributes = entity.Entity.GetCustomAttributes <EntityDefinitionAttribute>();

        foreach (var definitionAttribute in definitionAttributes)
        {
            definitionAttribute.ApplyToEntityDefinition(entity);
        }
    }
Ejemplo n.º 13
0
    public override void OnApplyingModule(EntityDefinition entity, EntityFieldDefinition field)
    {
        var definitionAttributes = field.Property.GetCustomAttributes <EntityFieldDefinitionAttribute>();

        foreach (var definitionAttribute in definitionAttributes)
        {
            definitionAttribute.ApplyToEntityFieldDefinition(entity, field);
        }
    }
Ejemplo n.º 14
0
        private static void UpdateEntity(EntityDefinition entity)
        {
            XDocument xDoc           = XDocument.Load(entityPath, LoadOptions.None);
            XElement  updatedElement = xDoc.Element("root").Descendants().First(d => d.Attribute("name").Value == entity.EntityName);

            updatedElement.SetAttributeValue("name", entity.EntityName);
            updatedElement.SetAttributeValue("fields", Serializer.Serialize(entity.EntityFields));
            SaveEntities(xDoc);
        }
Ejemplo n.º 15
0
        public Entity CreateEntity(string type)
        {
            EntityDefinition def      = Conf.EntityManagement.GetEntityDefinition(type);
            List <Section>   sections = def.GetInitalSections().Select(d => (Section)Activator.CreateInstance(Type.GetType(Conf.EntityManagement.GetSectionDefinition(d).Type))).ToList();

            return(new Entity {
                Type = type, Sections = sections
            });
        }
Ejemplo n.º 16
0
    public override void OnApplyingFallbackDefaults(EntityDefinition entity)
    {
        var metadata = entity.Using <CrudAdminEntityFeature>();

        if (string.IsNullOrWhiteSpace(metadata.DataSourceUrl))
        {
            metadata.DataSourceUrl = $"/api/{entity.NameKey.ToLower()}";
        }
    }
 public CodePropertiesAccessorTypeDeclaration(WXMLCodeDomGeneratorSettings settings, EntityDefinition entity, PropertyGroup group)
 {
     Entity           = entity;
     Group            = group;
     IsClass          = true;
     Name             = group.Name + "Accessor";
     PopulateMembers += OnPopulateMemebers;
     _settings        = settings;
 }
Ejemplo n.º 18
0
        public ViewpointModelItem GetViewpointItem(FileModel file, ViewpointModelItem parent)
        {
            string          parentName = parent.Definition.Name;
            ModelRepository models     = file.Parent.Models;

            EntityDefinition definition = null;
            var relationship            = models.GetRelationshipDefinition(this.Name);

            if (relationship != null)
            {
                if (relationship.Origin.Name == parentName)
                {
                    definition = relationship.GetTargetDefinition();
                }

                else if (relationship.Target.Name == parentName)
                {
                    definition = relationship.GetOriginDefinition();
                }

                else
                {
                    models.Diagnostic.Append(new DiagnositcMessage()
                    {
                        File     = file.FullPath,
                        Severity = SeverityEnum.Error,
                        Text     = $"Entity definition {parentName} don't match with origin or target entity definition"
                    });
                }
            }
            else
            {
                models.Diagnostic.Append(new DiagnositcMessage()
                {
                    File     = file.FullPath,
                    Severity = SeverityEnum.Error,
                    Text     = $"relitionship definition {this.Name} can't be resolved"
                });
            }

            var result = new ViewpointModelItem()
            {
                Kind         = ViewpointItem.Element,
                Relationship = relationship,
                Definition   = definition
            };

            if (definition != null)
            {
                foreach (var item in this.Children)
                {
                    result.AddChildren(item.GetViewpointItem(file, result));
                }
            }

            return(result);
        }
Ejemplo n.º 19
0
    private IEnumerable <EntityFieldEditorViewModel> BuildFieldsViewModel(EntityDefinition definition, TEntity value)
    {
        foreach (var field in definition.Fields)
        {
            var feature = field.Using <CrudAdminEntityFieldFeature>();

            yield return(BuildFieldViewModel(field, value, feature));
        }
    }
 /// <summary>
 /// Starts the gamemode.
 /// </summary>
 /// <param name="character">The character the player selected.</param>
 /// <param name="currentStage">The current stage we are on.</param>
 /// <param name="stageCollection"></param>
 public virtual void StartGameMode(EntityDefinition character, StageDefinition currentStage,
                                   StageCollection stageCollection = null)
 {
     this.stageCollection = stageCollection;
     this.currentStage    = currentStage;
     playerCamera         = Instantiate(gameManager.gameVariables.playerCameraPrefab.gameObject,
                                        spawnPointManager.GetSpawnPoint().position, Quaternion.identity)
                            .GetComponent <PlayerCamera>();
     ActivateGamemode();
 }
        public override void StartGameMode(EntityDefinition character,
                                           StageDefinition currentStage,
                                           StageCollection stageCollection = null)
        {
            base.StartGameMode(character, currentStage, stageCollection);

            playerCharacters.Add(simObjectManager.SpawnObject(character.entity, spawnPointManager.GetSpawnPoint().position, Quaternion.identity));
            playerCamera.SetLookAtTarget(playerCharacters[0].transform);
            playerCharacters[0].GetComponent <EntityManager>().Init(gameManager, playerCamera, CAF.Input.InputControlType.Direct);
        }
Ejemplo n.º 22
0
        private static void GenerateGenericView(TextWriter tw, EntityDefinition ed, bool isEditView)
        {
            var hb = new HtmlBuilder(tw);

            hb.Tag("form", h => ed.GetProperties()
                   .Aggregate(h, (h1, p) => h1.Begin("p").Text(p.Name).Text(GetEditControl(p, isEditView)).End())
                   .Tag("input", new { type = "submit", value = "save" }));

            hb.GetWriter().Flush();
        }
Ejemplo n.º 23
0
        public void MapDocTypeToEntity(string docType, Type entityType)
        {
            docTypeToEntityType.Add(docType, entityType);
            entityTypeToDocType.Add(entityType, docType);

            var entityDefBuilder       = new EntityDefinitionBuilder(entityType);
            EntityDefinition entityDef = entityDefBuilder.Build();

            entityDefinitions.Add(entityType, entityDef);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Create proxy from the specified document and entity type.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="entityType"></param>
        /// <returns></returns>
        public object CreateProxy(
            JToken doc, Type entityType, string id, PreProcessInfo preProcess,
            OdmViewProcessingOptions processingOptions, bool emptyProxy)
        {
            EntityDefinition entityDef = context.Mapping.GetEntityDefinition(entityType);
            object           proxy     = entityDef.CreateInstance();

            FillProxy(entityDef, proxy, doc, id, preProcess, processingOptions, emptyProxy);
            return(proxy);
        }
        public string GetEntitySchemaDefFileName(EntityDefinition entity)
        {
            WXMLCodeDomGeneratorSettings settings = GetSettings();
            string baseName =
                settings.FileNamePrefix +
                GetEntitySchemaDefClassName(entity) +
                settings.FileNameSuffix;

            return(baseName);
        }
Ejemplo n.º 26
0
        public void CreateAgent(Entity entity, EntityDefinition entityDefinition)
        {
            Agent agent = new Agent(entity);

            agent.goals     = new ListX <Goal>(entityDefinition.goals);
            agent.behaviors = entityDefinition.standaloneBehaviors ?? new ListX <AIBehavior>();
            agent.behaviorCompatibiltyFlags = -1;
            agents.Add(agent);
            agentsNeedingGoal.Add(agent);
        }
Ejemplo n.º 27
0
 public void SetEntityFaction(EntityDefinition entity, FactionDefinition faction, int index)
 {
     if (entity.factionId == faction.id)
     {
         return;
     }
     GetFlightGroup(entity.flightGroupId)?.RemoveEntity(entity);
     faction.GetDefaultFlightGroup().AddEntity(entity, index);
     onChange?.Invoke(entity.id);
 }
Ejemplo n.º 28
0
        private static void AddEntity(EntityDefinition entity)
        {
            XDocument xDoc       = XDocument.Load(entityPath, LoadOptions.None);
            XElement  newElement = new XElement("Entity");

            newElement.SetAttributeValue("name", entity.EntityName);
            newElement.SetAttributeValue("fields", Serializer.Serialize(entity.EntityFields));
            xDoc.Element("root").Add(newElement);
            SaveEntities(xDoc);
        }
        public MappingCommandBase(DbConnection connection)
        {
            Connection = connection;
            Entity     = ReflectionHelper.GetEntityDefinitionFromType <T>();

            if (String.IsNullOrEmpty(Entity.DbTableName))
            {
                throw new Exception("Couldn't resolve the tablename. Please instantiate the command either with a tablename or add a [Table] attribute to the data class.");
            }
        }
Ejemplo n.º 30
0
    /// <inheritdoc />
    protected internal override void ApplyToEntityDefinition(EntityDefinition entity)
    {
        var jsonLdFeature = entity.Using <JsonLdTypeFeature>();

        jsonLdFeature.TypeIri = Iri;

        var vocab = string.IsNullOrEmpty(DefaultVocab) ? $"{Iri}#" : DefaultVocab;

        jsonLdFeature.TermsDefaultVocab = vocab;
    }
    public override void OnApplyingModule(EntityDefinition entity, EntityFieldDefinition field)
    {
        var metadata = field.Using <CrudAdminEntityFieldFeature>();

        if (field.Property.Name == nameof(IEntity.Id))
        {
            metadata.DisplayInEditor = false;
            metadata.DisplayOnSearch = false;
        }
    }
Ejemplo n.º 32
0
 public static IEntityRecord Create(EntityInstance instance)
 {
     var def = definitions[instance.ClassName];
     var newdef = new EntityDefinition(instance.Name);
     foreach (var p in def.Parameters)
         newdef.Parameters.Add(p);
     foreach (var delta in instance.Deltas)
     {
         var key = delta.Component + ":" + delta.Parameter;
         if (delta.Type == DeltaType.Add)
         {
             if (newdef.Parameters.Contains(key)) newdef.Parameters.Remove(key);
             newdef.Parameters.Add(new Parameter(delta.Component, delta.Parameter, delta.Value));
         }
         else if (newdef.Parameters.Contains(key)) newdef.Parameters.Remove(key);
     }
     return Create(instance.Name, newdef);
 }
Ejemplo n.º 33
0
        public static void SaveAssets(EngineContext engineContext)
        {
            var entities = new List<EntityDefinition>();

            foreach (var entity in engineContext.EntityManager.Entities.OrderBy(x => x.Guid).Where(x => x.Name == "him"))
            {
                var entityDefinition = new EntityDefinition(entity.Guid);
                entities.Add(entityDefinition);

                foreach (var entityComponent in entity.Properties.Where(x => x.Value is EntityComponent).OrderBy(x => x.Key.Name))
                {
                    var componentDefinition = new EntityComponentDefinition { Name = entityComponent.Key.Name, Properties = new List<EntityComponentProperty>() };
                    entityDefinition.Components.Add(componentDefinition);

                    var entityComponentValue = entityComponent.Value as EntityComponent;

                    foreach (var field in entityComponentValue.GetType().GetFields())
                    {
                        if (field.GetCustomAttributes(typeof(VersionableAttribute), true).Length == 0)
                            continue;

                        componentDefinition.Properties.Add(new EntityComponentProperty(EntityComponentPropertyType.Field, field.Name, Encode(field.GetValue(entityComponentValue))));
                    }

                    foreach (var property in entityComponentValue.GetType().GetProperties())
                    {
                        if (property.GetCustomAttributes(typeof(VersionableAttribute), true).Length == 0)
                            continue;

                        componentDefinition.Properties.Add(new EntityComponentProperty(EntityComponentPropertyType.Property, property.Name, Encode(property.GetValue(entityComponentValue, null))));
                    }

                    componentDefinition.Properties = componentDefinition.Properties.OrderBy(x => x.Name).ToList();
                }
            }

            var fileStream = new FileStream(@"C:\DEV\hotei_scene\scene.hotei", FileMode.Create, FileAccess.Write);
            var stream = new BinarySerializationWriter(fileStream);
            stream.Context.Serializer = Serializer;
            stream.SerializeClass(null, ref entities, ArchiveMode.Serialize);
            fileStream.Close();
        }
Ejemplo n.º 34
0
 public void RemoveDefinition(EntityDefinition definition)
 {
     Definitions.Remove(definition.Name);
 }
Ejemplo n.º 35
0
        //TODO: TMP class holder
        public static string BuildCondition(Condition cond, EntityDefinition definition, string table)
        {
            string sqlCondition = null;

            var property = definition.Properties.Find(p => p.Name == cond.Property);
            if (property == null && cond.Property == "Id")
                property = new PropertyDefinition("Id", PropertyTypes.Integer, false);
            else if (property == null)
                throw new ArgumentException("Invalid property!");

            var column = string.Format("{0}.{1}", table, property.Name);

            string value = null;
            if (cond.Values.Single() is decimal)
                value = ((decimal)(object)cond.Values.Single()).ToString(System.Globalization.CultureInfo.InvariantCulture);
            else if (property.Type == PropertyTypes.EnumValue)
                value = (Convert.ToByte(cond.Values.Single())).ToString();
            else if (property.Type == PropertyTypes.Boolean)
                value = Convert.ToBoolean(cond.Values.Single()) ? "1" : "0";
            else
                value = cond.Values.Single().ToString();

            if (cond.Operator == Condition.Is)
            {
                if (property.Type == PropertyTypes.String)
                    sqlCondition = string.Format("{0} = '{1}'", column, value);
                else
                    sqlCondition = string.Format("{0} = {1}", column, value);
            }
            else if (cond.Operator == Condition.Not)
            {
                if (property.Type == PropertyTypes.String)
                    sqlCondition = string.Format("{0} <> '{1}'", column, value);
                else
                    sqlCondition = string.Format("{0} <> {1}", column, value);
            }
            else if (cond.Operator == Condition.LessThen)
                sqlCondition = string.Format("{0} < {1}", column, value);
            else if (cond.Operator == Condition.LessThenOrEqual)
                sqlCondition = string.Format("{0} <= {1}", column, value);
            else if (cond.Operator == Condition.GreaterThen)
                sqlCondition = string.Format("{0} > {1}", column, value);
            else if (cond.Operator == Condition.GreaterThenOrEqual)
                sqlCondition = string.Format("{0} >= {1}", column, value);
            else if (cond.Operator == Condition.StartsWith && property.Type == PropertyTypes.String)
                sqlCondition = string.Format("{0} LIKE '{1}%'", column, value);
            else
                throw new NotImplementedException("Unrecognized operator!");

            return sqlCondition;
        }
Ejemplo n.º 36
0
        private IEnumerable<StoredProcedure> BuildProcs(EntityDefinition def)
        {
            #region Build Create Proc

            StringBuilder create = new StringBuilder();
            create.AppendFormat("CREATE PROC [{0}_Create] \n", def.Name);
            create.Append("@Id INT OUTPUT ");

            def.Properties.ForEach(prop =>
            {
                if (prop.Type == PropertyTypes.Computed)
                    return;

                var size = prop is StringProperty ? ((StringProperty)prop).Length : -1;
                if (prop is StringProperty)
                {
                    create.AppendFormat("\n,@{0} {1}({2}) ", prop.Name, SqlDbType.NVarChar, ((StringProperty)prop).Length);
                }
                else
                    create.AppendFormat("\n,@{0} {1} ", prop.Name, EntityValueMapper.GetDbType(prop.Type));
                //parameters[idx++] = new ParameterInfo(prop.Name, prop.Type, size);
            });

            create.Append("\nAS\n");

            create.AppendFormat("INSERT INTO [{0}] \n(", def.Name);
            for (int i = 0; i < def.Properties.Count; i++)
            {
                if (def.Properties[i].Type != PropertyTypes.Computed)
                {
                    create.AppendFormat("[{0}]", def.Properties[i].Name);
                }

                if (i < def.Properties.Count - 1 && def.Properties[i + 1].Type != PropertyTypes.Computed)
                    create.Append(",\n");
            }
            create.Append(") VALUES \n (");

            for (int i = 0; i < def.Properties.Count; i++)
            {
                //Skip computed since they are not inserted
                if (def.Properties[i].Type != PropertyTypes.Computed)
                {
                    create.AppendFormat("@{0}", def.Properties[i].Name);
                }

                if (i < def.Properties.Count - 1 && def.Properties[i+1].Type != PropertyTypes.Computed)
                    create.Append(",\n");
            }
            create.Append(")\n");

            create.AppendFormat("\n SET @Id = SCOPE_IDENTITY();");

            #endregion

            #region Build Update Proc

            StringBuilder update = new StringBuilder();
            update.AppendFormat("CREATE PROC [{0}_Update] \n", def.Name);
            update.Append("@Id INT ");

            def.Properties.ForEach(prop =>
            {
                if (prop.Type == PropertyTypes.Computed)
                    return;

                var size = prop is StringProperty ? ((StringProperty)prop).Length : -1;
                if (prop is StringProperty)
                {
                    update.AppendFormat("\n,@{0} {1}({2}) ", prop.Name, SqlDbType.NVarChar, ((StringProperty)prop).Length);
                }
                else
                    update.AppendFormat("\n,@{0} {1} ", prop.Name, EntityValueMapper.GetDbType(prop.Type));
            });

            update.Append("\n AS \n");

            update.AppendFormat("UPDATE [{0}] \nSET \n", def.Name);
            for (int i = 0; i < def.Properties.Count; i++)
            {
                if (def.Properties[i].Type != PropertyTypes.Computed)
                {
                    update.AppendFormat("[{0}] = @{0}", def.Properties[i].Name);
                }

                //TODO: ugly code
                if (i < def.Properties.Count - 1 && def.Properties[i+1].Type != PropertyTypes.Computed)
                    update.Append(",\n");
            }
            update.AppendFormat("\nWHERE [Id] = @Id \n");

            #endregion

            #region Build Read Proc

            StringBuilder read = new StringBuilder();
            read.AppendFormat("CREATE PROC [{0}_Read] \n", def.Name);
            read.Append("@Id INT ");
            read.Append("\n AS \n");
            read.AppendFormat("SELECT * FROM [{0}] WHERE [Id] = @Id", def.Name);

            #endregion

            #region Build Delete Proc

            StringBuilder delete = new StringBuilder();
            delete.AppendFormat("CREATE PROC [{0}_Delete] \n", def.Name);
            delete.Append("@Id INT ");
            delete.Append("\n AS \n");
            delete.AppendFormat("DELETE FROM [{0}] WHERE Id = @Id", def.Name);

            #endregion

            return new StoredProcedure[]{
                new StoredProcedure(string.Format("{0}_Create", def.Name), create.ToString()),
                new StoredProcedure(string.Format("{0}_Read", def.Name), read.ToString()),
                new StoredProcedure(string.Format("{0}_Update", def.Name), update.ToString()),
                new StoredProcedure(string.Format("{0}_Delete", def.Name), delete.ToString())
            };
        }
Ejemplo n.º 37
0
 public void AddDefinition(EntityDefinition definition)
 {
     Definitions.Add(definition.Name, definition);
 }
Ejemplo n.º 38
0
 public static void Define(EntityDefinition definition)
 {
     if (!definitions.Contains(definition.Name))
         definitions.Add(definition);
 }
Ejemplo n.º 39
0
 public void DefineEntity(string definitionName, EntityDefinition definition)
 {
     _definitions[definitionName] = definition;
 }
Ejemplo n.º 40
0
 // Resolve conflicts for an entity
 public static void ResolveEntityConflicts(ThreeWayConflictType conflictType, IList<EntityDefinition>[] lists, int[] indices, IList<EntityDefinition> result)
 {
     switch (conflictType)
     {
         case ThreeWayConflictType.Modified1And2:
             var entityDefinition = new EntityDefinition(lists[0][indices[0]].Guid);
             ThreeWayMergeOrdered.Merge(entityDefinition.Components, lists[0][indices[0]].Components, lists[1][indices[1]].Components, lists[2][indices[2]].Components, x => x.Name, (x, y) => x == y, ResolveComponentConflicts);
             result.Add(entityDefinition);
             break;
         default:
             throw new NotImplementedException();
     }
 }