Ejemplo n.º 1
0
			///     Creates a new EventPropertyDescriptor.
			internal EventPropertyDescriptor(EventDescriptor eventDesc, EventBindingService eventSvc) : base(eventDesc, null) 
			{
				_eventDesc = eventDesc;
				_eventSvc = eventSvc;
			}
Ejemplo n.º 2
0
        internal static void ShowDefaultEvent(EditingContext context)
        {
            Selection selection = context.Items.GetValue <Selection>();

            if (selection == null)
            {
                return;
            }
            ModelItem primarySelection = selection.PrimarySelection;

            if (primarySelection == null)
            {
                return;
            }
            DefaultEventAttribute defaultEventAttribute = (DefaultEventAttribute)null;

            using (IEnumerator <object> enumerator = primarySelection.GetAttributes(typeof(DefaultEventAttribute)).GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    defaultEventAttribute = (DefaultEventAttribute)enumerator.Current;
                }
            }
            if (defaultEventAttribute == null || defaultEventAttribute.Name == null || primarySelection.Events == null)
            {
                return;
            }
            ModelEvent modelEvent = primarySelection.Events.Find(defaultEventAttribute.Name);

            if (modelEvent == null)
            {
                return;
            }
            EventBindingService service = context.Services.GetService <EventBindingService>();

            if (service == null)
            {
                return;
            }
            string methodName = (string)null;

            while (modelEvent.Handlers.Count > 0)
            {
                using (IEnumerator <string> enumerator = modelEvent.Handlers.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        methodName = enumerator.Current;
                    }
                }
                try
                {
                    service.ValidateMethodName(modelEvent, methodName);
                    break;
                }
                catch (NotSupportedException ex)
                {
                }
                modelEvent.Handlers.Remove(methodName);
                methodName = (string)null;
            }
            bool flag = false;

            foreach (string str in service.GetMethodHandlers(modelEvent))
            {
                if (methodName == null)
                {
                    methodName = str;
                    flag       = !service.AllowClassNameForMethodName();
                    break;
                }
                if (methodName == str)
                {
                    flag = true;
                    break;
                }
            }
            if (methodName == null || !flag)
            {
                if (methodName == null)
                {
                    methodName = service.CreateUniqueMethodName(modelEvent);
                    if (methodName == null)
                    {
                        return;
                    }
                }
                else
                {
                    flag = true;
                }
                if (!service.IsExistingMethodName(modelEvent, methodName) && !service.CreateMethod(modelEvent, methodName))
                {
                    return;
                }
                if (!flag && !service.AddEventHandler(modelEvent, methodName))
                {
                    modelEvent.Handlers.Add(methodName);
                }
            }
            service.ShowMethod(modelEvent, methodName);
        }