private EntityInterface CreateEntityInterface( XmlNode element ) { EntityInterface entity = new EntityInterface(); if( element.Attributes["xmi:id"] != null ) { entity.Id = element.Attributes["xmi:id"].Value; } if( element.Attributes["name"] != null ) { entity.Name = element.Attributes["name"].Value; } if( element.Attributes["visibility"] != null ) { entity.Visibility = element.Attributes["visibility"].Value; } return entity; }
private static EntityInterface GetInterface() { /** IPerson Definition **/ EntityInterface iPerson = new EntityInterface(); iPerson.Name = "IPerson"; iPerson.Visibility = "public"; EntityMethod getDescription = new EntityMethod(); getDescription.Name = "GetPerson"; EntityParameter paramRet = new EntityParameter(); paramRet.IsReturn = true; paramRet.Type = IntrinsicTypes.Create( "System.String" ); EntityParameter param = new EntityParameter(); param.IsReturn = false; param.Type = IntrinsicTypes.Create( "System.Int32" ); param.Name = "id"; getDescription.ReturnEntity = paramRet; List<EntityParameter> parames = new List<EntityParameter>(); parames.Add(param); getDescription.Parameters = parames; EntityMethod init = new EntityMethod(); init.Name = "Init"; EntityMethod set = new EntityMethod(); set.Name = "SetData"; EntityParameter param1 = new EntityParameter(); param1.IsReturn = true; param1.Type = IntrinsicTypes.Create( "System.String" ); param1.Name = "nome"; EntityParameter param2 = new EntityParameter(); param2.IsReturn = false; param2.Type = IntrinsicTypes.Create( "System.Boolean" ); param2.Name = "isMale"; List<EntityParameter> parames2 = new List<EntityParameter>(); parames2.Add(param1); parames2.Add(param2); set.Parameters = parames2; iPerson.Methods.Add(getDescription); iPerson.Methods.Add(init); iPerson.Methods.Add(set); return iPerson; }
private void TemplateInterface(string output, EntityInterface entity) { Dictionary<string, object> param = new Dictionary<string, object>(); param.Add("entity", entity); param.Add("namespace", Project.Name + "." + ComponentType.Core.ToString()); string template = GetResource("BaseInterfaceTemplate.vtl"); Templates.Generate(template, output, param); }
private static void BuildSmsTestModel() { EntityField field = null; /** User **/ EntityClass user = new EntityClass(); user.Name = "Principal"; user.Visibility = "public"; field = new EntityField(); field.Name = "Id"; field.IsPrimaryKey = true; field.Type = new Int(); user.Fields.Add(field); /** IDescription Definition **/ EntityInterface iDescription = new EntityInterface(); iDescription.Name = "IDescription"; iDescription.Visibility = "public"; EntityMethod getDescription = new EntityMethod(); getDescription.Name = "GetDescription"; EntityParameter param = new EntityParameter(); param.IsReturn = true; param.Type = IntrinsicTypes.Create( "System.String" ); getDescription.ReturnEntity = param; iDescription.Methods.Add(getDescription); /** Category Definition **/ EntityClass category = new EntityClass(); category.Name = "Category"; category.Visibility = "public"; //category.Interfaces.Add(iDescription); field = new EntityField(); field.Name = "Id"; field.IsPrimaryKey = true; field.Type = new Int(); category.Fields.Add(field); field = new EntityField(); field.Name = "Description"; field.IsRequired = true; field.MaxSize = 500; field.Type = new Loki.DataRepresentation.IntrinsicEntities.String(); category.Fields.Add(field); /** Sms Definition **/ EntityClass message = new EntityClass(); message.Name = "SmsBase"; message.IsAbstract = true; message.Visibility = "public"; //message.Interfaces.Add(iDescription); field = new EntityField(); field.Name = "Id"; field.IsPrimaryKey = true; field.Type = new Int(); message.Fields.Add(field); field = new EntityField(); field.Name = "Description"; field.IsRequired = true; field.MaxSize = 500; field.Default = "No Description"; field.Type = new Loki.DataRepresentation.IntrinsicEntities.String(); message.Fields.Add(field); field = new EntityField(); field.Name = "Category"; field.Type = category; field.Mult = Multiplicity.ManyToOne; field.IsRequired = true; message.Fields.Add(field); field = new EntityField(); field.Name = "Principal"; field.Type = user; field.Mult = Multiplicity.ManyToOne; field.IsRequired = true; message.Fields.Add(field); field = new EntityField(); field.Name = "Messages"; field.Type = message; field.Mult = Multiplicity.OneToMany; field.InfoOnly = true; user.Fields.Add(field); field = new EntityField(); field.Name = "Messages"; field.Type = message; field.InfoOnly = true; field.Mult = Multiplicity.OneToMany; category.Fields.Add(field); /** ImageSms **/ EntityClass imageSms = new EntityClass(); imageSms.Name = "ImageSms"; imageSms.Visibility = "public"; imageSms.Parent = message; field = new EntityField(); field.Name = "ImageUrl"; field.Type = new Loki.DataRepresentation.IntrinsicEntities.String(); field.IsRequired = true; field.Default = "#"; imageSms.Fields.Add(field); /** TextSms **/ EntityClass textSms = new EntityClass(); textSms.Name = "TextSms"; textSms.Visibility = "public"; textSms.Parent = message; field = new EntityField(); field.Name = "Text"; field.Type = new Loki.DataRepresentation.IntrinsicEntities.String(); field.IsRequired = true; field.Default = "Empty"; textSms.Fields.Add(field); /** Setting up project **/ Model list = new Model(); list.Add(category); list.Add(iDescription); list.Add(user); list.Add(message); list.Add(imageSms); list.Add(textSms); smsTestModel.Model = list; }