private void ParseInterface(XmlNode element) { if (IsAttributeValid(element.Attributes["name"])) { EntityInterface entity = CreateEntityInterface(element); IterateChilds(element, entity); } }
public void IDescriptionTest() { EntityInterface ientity = project.Model[5] as EntityInterface; //Class stuff Assert.AreEqual("IDescription", ientity.Name, "Interface Name should be 'IDescription'!"); Assert.AreEqual("public", ientity.Visibility, "Class Visibility should be 'public'!"); }
private static void BuildInterfaceTestModel() { EntityInterface iPerson = GetInterface(); Model list = new Model(); list.Add(iPerson); interfaces.Model = list; }
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 BuildClassTestModel() { EntityInterface iPerson = GetInterface(); EntityClass parent = new EntityClass(); parent.Name = "Pai"; EntityClass category = new EntityClass(); category.Name = "Category"; category.Visibility = "public"; category.Interfaces.Add(iPerson); category.Parent = parent; EntityField field = new EntityField(); field.Name = "Id"; field.Visibility = "protected"; 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); category.IsAbstract = true; category.Persistable = true; category.Visibility = "protected"; EntityMethod init = new EntityMethod(); init.Name = "Init"; category.Methods.Add(init); Model list = new Model(); list.Add(category); classes.Model = list; }
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); }
/// <summary> /// Takes a concrete class acting as the EntityInterface and converts it to act as type T. /// </summary> /// <typeparam name="T">The destination concrete type of Tinterface. It must be a class. It must implement Tinterface. It must have a generic constructor.</typeparam> /// <param name="item"></param> /// <returns>The same instance passed in, if the source concrete class is the same as the destination type T. If the destination type is different, then a shallow copy is returned where all public properties of EntityInterface, including inherited properties, are copied.</returns> public static T ToConcrete <T>(this EntityInterface item) where T : class, EntityInterface, new() { return(ConcreteConverter.ToConcrete <T, EntityInterface>(item)); }
public void SmsTest() { EntityClass entity = project.Model[1] as EntityClass; //Class stuff Assert.AreEqual("Sms", entity.Name, "Class Name should be 'Sms'!"); Assert.AreEqual("public", entity.Visibility, "Class Visibility should be 'public'!"); Assert.AreEqual(false, entity.IsAbstract, "Class should not be abstract!"); //Implemented Interfaces Assert.AreEqual(1, entity.Interfaces.Count, "Sms should have 1 Interface"); EntityInterface iDescription = entity.Interfaces[0]; Assert.AreEqual("IDescription", iDescription.Name, "Sms interface name is incorrect"); Assert.AreEqual("_10_5_1dc00e8_1135161125319_156036_314", iDescription.Id, "Sms interface id is incorrect"); //Attribute Stuff Assert.AreEqual(4, entity.Fields.Count, "Sms should Have 4 fields"); EntityField id = entity.Fields[0]; Assert.AreEqual("id", id.Name, "Field id has an incorrect Name"); Assert.AreEqual("private", id.Visibility, "Field id has an incorrect modifier"); Assert.AreEqual("int", id.Type.Name, "Field id has an incorrect type"); Assert.IsNull(id.ReferenceType, "Field id should not have a ReferenceType"); EntityField description = entity.Fields[1]; Assert.AreEqual("_10_5_1dc00e8_1135160692997_580873_136", description.Id, "Field size has an incorrect Id"); Assert.AreEqual("description", description.Name, "Field description has an incorrect Name"); Assert.AreEqual("private", description.Visibility, "Field description has an incorrect modifier"); Assert.AreEqual("string", description.Type.Name, "Field description has an incorrect type"); Assert.IsNull(description.ReferenceType, "Field description should not have a ReferenceType"); EntityField messages = entity.Fields[2]; Assert.AreEqual("category", messages.Name, "Field messages has an incorrect Name"); Assert.AreEqual("private", messages.Visibility, "Field messages has an incorrect modifier"); Assert.AreEqual("Category", messages.Type.Name, "Field messages has an incorrect type"); Assert.AreEqual(true, messages.InfoOnly, "Field messages should be InfoOnly"); Assert.IsNotNull(messages.ReferenceType, "Field messages should have a ReferenceType"); Assert.AreEqual(Multiplicity.ManyToOne, messages.Mult, "Field messages has an incorrect Multiplicity"); messages = entity.Fields[3]; Assert.AreEqual("user", messages.Name, "Field messages has an incorrect Name"); Assert.AreEqual("private", messages.Visibility, "Field messages has an incorrect modifier"); Assert.AreEqual("User", messages.Type.Name, "Field messages has an incorrect type"); Assert.AreEqual(true, messages.InfoOnly, "Field messages should be InfoOnly"); Assert.IsNotNull(messages.ReferenceType, "Field messages should have a ReferenceType"); Assert.AreEqual(Multiplicity.ManyToOne, messages.Mult, "Field messages has an incorrect Multiplicity"); //Method Stuff Assert.AreEqual(1, entity.Methods.Count, "1 Method were expected"); EntityMethod method = entity.Methods[0]; Assert.IsNotNull(method.ReturnEntity, "Return type was expected"); Assert.AreEqual("ToHtml", method.Name, "Incorrect method name"); Assert.AreEqual("public", method.MethodModifier, "Incorrect method modifier"); //Parameter Stuff Assert.AreEqual(0, entity.Methods[0].Parameters.Count, "0 Parameters were expected"); }
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; }
private static void CreatePrincipalEntity( IProject project ) { EntityClass principal = project.GetEntity( "Principal" ); if( principal == null ) { principal = new EntityClass( "Principal", "public" ); EntityField id = new EntityField( "id" ); id.IsPrimaryKey = true; id.Type = intType; id.IsPreview = true; principal.AddField( id ); project.Model.Add( principal ); } principal.Lazy = true; if( !principal.HasField( "name" ) ) { EntityField name = new EntityField( "name" ); name.MaxSize = 200; name.IsRequired = true; name.IsPreview = true; name.Represents = true; name.Type = stringType; principal.AddField( name ); } if( !principal.HasField( "password" ) ) { EntityField password = new EntityField( "password" ); password.MaxSize = 50; password.IsRequired = true; password.Type = stringType; password.Secret = true; principal.AddField( password ); } if( !principal.HasField( "email" ) ) { EntityField mail = new EntityField( "email" ); mail.MaxSize = 200; mail.IsPreview = true; mail.IsRequired = true; mail.Type = stringType; //mail.Regex.Add( mail.Unique = true; principal.AddField( mail ); } if( !principal.HasField( "ip" ) ) { EntityField ip = new EntityField( "ip" ); ip.MaxSize = 15; ip.Type = stringType; ip.IsPreview = true; //ip.Regex.Add( principal.AddField( ip ); } if( !principal.HasField( "registDate" ) ) { EntityField registDate = new EntityField( "registDate" ); registDate.IsRequired = true; registDate.Type = dateTimeType; //principal.Regex.Add( principal.AddField( registDate ); } if( !principal.HasField( "lastLogin" ) ) { EntityField lastLogin = new EntityField( "lastLogin" ); lastLogin.IsRequired = true; lastLogin.Type = dateTimeType; //principal.Regex.Add( principal.AddField( lastLogin ); } if( !principal.HasField( "approved" ) ) { EntityField approved = new EntityField( "approved" ); approved.IsRequired = true; approved.Type = boolType; approved.Default = false; principal.AddField( approved ); } if( !principal.HasField( "isOnline" ) ) { EntityField isOnline = new EntityField( "isOnline" ); isOnline.Type = boolType; isOnline.Default = false; principal.AddField( isOnline ); } if( !principal.HasField( "locked" ) ) { EntityField locked = new EntityField( "locked" ); locked.Type = boolType; locked.Default = false; principal.AddField( locked ); } if( !principal.HasField( "locale" ) ) { EntityField locale = new EntityField( "locale" ); locale.Type = stringType; locale.IsRequired = true; locale.MaxSize = 6; principal.AddField( locale ); } if( !principal.HasField( "roles" ) ) { EntityField role = new EntityField( "roles" ); role.Type = CreateRoleEntity( project, principal ); role.Mult = Multiplicity.ManyToMany; role.Lazy = false; principal.AddField( role ); } if( !principal.HasField("confirmationCode") ) { EntityField confirmationCode = new EntityField("confirmationCode"); confirmationCode.Type = stringType; confirmationCode.IsRequired = true; principal.AddField(confirmationCode); } EntityInterface iPrincipal = new EntityInterface(); iPrincipal.Name = "System.Security.Principal.IPrincipal"; principal.Interfaces.Add( iPrincipal ); }
public static Vector2 GetAvoidSteer(Boid unit, EntityInterface collider) { return((unit.Position - collider.Position).GetVerticalComponent(unit.Forward).normalized); }
private static void CreatePrincipalEntity(IProject project) { EntityClass principal = project.GetEntity("Principal"); if (principal == null) { principal = new EntityClass("Principal", "public"); EntityField id = new EntityField("id"); id.IsPrimaryKey = true; id.Type = intType; id.IsPreview = true; principal.AddField(id); project.Model.Add(principal); } principal.Lazy = true; if (!principal.HasField("name")) { EntityField name = new EntityField("name"); name.MaxSize = 200; name.IsRequired = true; name.IsPreview = true; name.Represents = true; name.Type = stringType; principal.AddField(name); } if (!principal.HasField("password")) { EntityField password = new EntityField("password"); password.MaxSize = 50; password.IsRequired = true; password.Type = stringType; password.Secret = true; principal.AddField(password); } if (!principal.HasField("email")) { EntityField mail = new EntityField("email"); mail.MaxSize = 200; mail.IsPreview = true; mail.IsRequired = true; mail.Type = stringType; //mail.Regex.Add( mail.Unique = true; principal.AddField(mail); } if (!principal.HasField("ip")) { EntityField ip = new EntityField("ip"); ip.MaxSize = 15; ip.Type = stringType; ip.IsPreview = true; //ip.Regex.Add( principal.AddField(ip); } if (!principal.HasField("registDate")) { EntityField registDate = new EntityField("registDate"); registDate.IsRequired = true; registDate.Type = dateTimeType; //principal.Regex.Add( principal.AddField(registDate); } if (!principal.HasField("lastLogin")) { EntityField lastLogin = new EntityField("lastLogin"); lastLogin.IsRequired = true; lastLogin.Type = dateTimeType; //principal.Regex.Add( principal.AddField(lastLogin); } if (!principal.HasField("approved")) { EntityField approved = new EntityField("approved"); approved.IsRequired = true; approved.Type = boolType; approved.Default = false; principal.AddField(approved); } if (!principal.HasField("isOnline")) { EntityField isOnline = new EntityField("isOnline"); isOnline.Type = boolType; isOnline.Default = false; principal.AddField(isOnline); } if (!principal.HasField("locked")) { EntityField locked = new EntityField("locked"); locked.Type = boolType; locked.Default = false; principal.AddField(locked); } if (!principal.HasField("locale")) { EntityField locale = new EntityField("locale"); locale.Type = stringType; locale.IsRequired = true; locale.MaxSize = 6; principal.AddField(locale); } if (!principal.HasField("roles")) { EntityField role = new EntityField("roles"); role.Type = CreateRoleEntity(project, principal); role.Mult = Multiplicity.ManyToMany; role.Lazy = false; principal.AddField(role); } if (!principal.HasField("confirmationCode")) { EntityField confirmationCode = new EntityField("confirmationCode"); confirmationCode.Type = stringType; confirmationCode.IsRequired = true; principal.AddField(confirmationCode); } EntityInterface iPrincipal = new EntityInterface(); iPrincipal.Name = "System.Security.Principal.IPrincipal"; principal.Interfaces.Add(iPrincipal); }