コード例 #1
0
ファイル: Globals.cs プロジェクト: zi-yu/midgard
        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;
        }
コード例 #2
0
ファイル: XmiLoader.cs プロジェクト: zi-yu/midgard
        private EntityParameter CreateEntityParameter( XmlNode element )
        {
            EntityParameter parameter = new EntityParameter();

            if( element.Attributes["xmi:id"] != null ) {
                parameter.Id = element.Attributes["xmi:id"].Value;
            }

            if( element.Attributes["name"] != null ) {
                parameter.Name = element.Attributes["name"].Value;
            }

            if( element.Attributes["direction"] != null ) {
                string kind = element.Attributes["direction"].Value.ToLower();

                if( kind.CompareTo( "return" ) == 0 ) {
                    parameter.IsReturn = true;
                } else {
                    if( kind.CompareTo( "inout" ) != 0 ) {
                        parameter.Modifier = kind;
                    }
                }
            }

            return parameter;
        }
コード例 #3
0
ファイル: Globals.cs プロジェクト: zi-yu/midgard
        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;
        }