Exemplo n.º 1
0
 /// <summary>
 /// Adds the given events to the given type.
 /// </summary>
 /// <param name="type">The entity to add the events to.</param>
 /// <param name="events">A list of events to add.</param>
 private void AddEvents(CompositeType type, IEnumerable <NREvent> events)
 {
     foreach (NREvent nrEvent in events)
     {
         type.AddEvent().InitFromDeclaration(new NREventDeclaration(nrEvent));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 ///     Adds the given events to the given type.
 /// </summary>
 /// <param name="type">The entity to add the events to.</param>
 /// <param name="events">A list of events to add.</param>
 private void AddEvents(CompositeType type, IEnumerable <NREvent> events)
 {
     foreach (var nrEvent in events)
     {
         type.AddEvent().InitFromString(nrEvent.Declaration());
     }
 }
Exemplo n.º 3
0
 private void toolNewEvent_Click(object sender, EventArgs e)
 {
     if (parent.SupportsEvents)
     {
         Event _event = parent.AddEvent();
         AddNewOperation(_event);
     }
 }
Exemplo n.º 4
0
        private void toolNewEvent_Click(object sender, EventArgs e)
        {
            if (parent.SupportsEvents)
            {
                Event        _event = parent.AddEvent();
                ListViewItem item   = AddOperationToList(_event);

                OnContentsChanged(EventArgs.Empty);
                item.Focused  = true;
                item.Selected = true;
                txtName.SelectAll();
                txtName.Focus();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds the given events to the given type.
        /// </summary>
        /// <param name="type">The entity to add the fields to.</param>
        /// <param name="tp">.</param>
        private void AddEvents(CompositeType type, TypeDeclaration tp)
        {
            foreach (EventDeclaration ep in tp.Descendants.OfType <EventDeclaration>())
            {
                var variable = ep.Variables.First();
                if (variable == null)
                {
                    continue;
                }

                Event ev = type.AddEvent();

                ev.Name           = variable.Name;
                ev.AccessModifier = ep.Modifiers.ToEnClass();
                ev.Type           = ep.ReturnType.ToString();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Reflects all fields within the type <paramref name="xType"/>. Reflected
        /// fields are added to <paramref name="xFieldContainer"/>.
        /// </summary>
        /// <param name="xType">The fields are taken from this type.</param>
        /// <param name="xFieldContainer">Reflected fields are added to this FieldContainer.</param>
        private void ReflectFields(Type xType, CompositeType xFieldContainer)
        {
            #region --- Events

            EventInfo[]   axEvents  = xType.GetEvents(xStandardBindingFlags);
            List <string> astEvents = new List <string>();
            foreach (EventInfo xEvent in axEvents)
            {
                //Don't display derived events
                if (xEvent.DeclaringType != xType)
                {
                    continue;
                }
                //The access modifier isn't stored at the event. So we have to take
                //that from the corresponding add_XXX (or perhaps remove_XXX) method.
                MethodInfo xAddMethodInfo = xType.GetMethod("add_" + xEvent.Name, xStandardBindingFlags);
                if (!xImportSettings.CheckImportEvent(xAddMethodInfo))
                {
                    continue;
                }
                Event xNewEvent = xFieldContainer.AddEvent();
                xNewEvent.Name           = xEvent.Name;
                xNewEvent.AccessModifier = GetMethodAccessModifier(xAddMethodInfo);
                xNewEvent.IsStatic       = xAddMethodInfo.IsStatic;
                xNewEvent.Type           = GetTypeName(xEvent.EventHandlerType);
                astEvents.Add(xEvent.Name);
            }

            #endregion

            #region --- Fields

            FieldInfo[] axFields = xType.GetFields(xStandardBindingFlags);
            foreach (FieldInfo xField in axFields)
            {
                if (!xImportSettings.CheckImportField(xField))
                {
                    continue;
                }
                //Don't import fields belonging to events
                if (astEvents.Contains(xField.Name))
                {
                    continue;
                }
                //Don't display derived fields
                if (xField.DeclaringType != xType)
                {
                    continue;
                }

                //Don't add compiler generated fields (thaks to Luca)
                if (xField.GetCustomAttributes(typeof(CompilerGeneratedAttribute), true).Length > 0)
                {
                    continue;
                }

                Field xNewField = xFieldContainer.AddField();
                xNewField.Name           = xField.Name;
                xNewField.AccessModifier = GetFieldAccessModifier(xField);
                xNewField.IsReadonly     = xField.IsInitOnly;
                xNewField.IsStatic       = xField.IsStatic;
                if (xField.IsLiteral)
                {
                    xNewField.InitialValue = xField.GetValue(null).ToString();
                    xNewField.IsStatic     = false;
                    xNewField.IsConstant   = true;
                }
                xNewField.Type = GetTypeName(xField.FieldType);
            }

            #endregion

            ReflectOperations(xType, (CompositeType)xFieldContainer);
        }