Exemplo n.º 1
0
        internal void AddMembersTo(Project project)
        {
            var properties = new List <Property>();
            var actions    = new List <Action>();

            foreach (PropertyInfo prop in this.GetType().GetProperties())
            {
                object value = prop.GetValue(this, new object[0]);

                if (value != null)
                {
                    var attr = (ArpPropertyAttribute)prop.GetCustomAttributes(typeof(ArpPropertyAttribute), false).FirstOrDefault();
                    if (attr != null)
                    {
                        bool propertyExists = project.Properties.Any(a => a.Name == attr.Name);
                        bool actionExists   = project.Actions.OfType <SetPropertyAction>().Any(a => a.PropName == attr.Name);

                        if (attr.Name == "ARPPRODUCTICON")
                        {
                            if (!propertyExists)
                            {
                                properties.Add(new Property(attr.Name, "app_icon.ico"));
                                project.Add(new IconFile(new Id("app_icon.ico"), value.ToString()));
                            }
                        }
                        else
                        {
                            if (attr.SetAsAction)
                            {
                                if (!actionExists)
                                {
                                    actions.Add(new SetPropertyAction(new Id("Set_" + attr.Name), attr.Name, value.ToString())
                                    {
                                        Step = Step.CostFinalize
                                    });
                                }
                            }
                            else
                            {
                                if (!propertyExists)
                                {
                                    properties.Add(new Property(attr.Name, value.ToString()));
                                }
                            }
                        }
                    }
                }
            }

            project.AddProperties(properties.ToArray());
            project.AddActions(actions.ToArray());
        }