public bool Save()
        {
            bool remember = this.Updating;

            try
            {
                this.Updating = true;

                if ((this.Class != null) && (this.MethodType != null))
                {
                    string errors;
                    string selector = MethodDefinitionControl.GetSelector(this.txtSourceCode.Text, out errors);
                    if (selector == null)
                    {
                        MessageBox.Show(errors, "Could not save", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }

                    ChangTransaction.Perform(delegate(ChangTransaction t)
                    {
                        ISet <Method> methods;
                        if (this.MethodType == Classes.MethodType.Class)
                        {
                            methods = this.Class.ClassMethods;
                        }
                        else
                        {
                            methods = this.Class.InstanceMethods;
                        }
                        Method method = methods.FirstOrDefault(m => m.Selector == selector);
                        if (method == null)
                        {
                            method          = new Method(this.Class);
                            method.Selector = selector;
                            methods.Add(method);
                            this.txtNativeName.Text = MethodDefinitionControl.GenerateNativeName(selector);
                        }

                        method.Source = this.txtSourceCode.Text;
                        method.Annotations.Replace("ist.runtime.native-name", this.txtNativeName.Text);

                        this.ProtocolNameHolder.TriggerChanged(this.ProtocolName, this.ProtocolName);
                        this.MethodNameHolder.Value = selector;
                        this.MethodNameHolder.TriggerChanged(selector, selector);
                    });
                }

                //if (!this.SystemImplementation.GlobalItems.Contains(this.Global))
                //    this.SystemImplementation.GlobalItems.Add(this.Global);
                this.MarkClean();
                //this.SystemImplementation.GlobalItems.TriggerChanged();
                //this.GlobalHolder.TriggerChanged(this.Global, this.Global);
            }
            finally
            {
                this.Updating = remember;
            }
            return(true);
        }
Пример #2
0
 public void TriggerChanged()
 {
     if (this.Changed == null)
     {
         return;
     }
     ChangTransaction.Perform(delegate(ChangTransaction t)
     {
         CollectionChangedEventArgs e = new CollectionChangedEventArgs(t);
         this.Changed(this, e);
     });
 }