Example #1
0
        private void LoadSavedRenameOperations()
        {
            var serializedOps = EditorPrefs.GetString(RenameOpsEditorPrefsKey, string.Empty);

            if (string.IsNullOrEmpty(serializedOps))
            {
                var operation = new ReplaceStringOperation();
                var drawer    = new ReplaceStringOperationDrawer();
                drawer.SetModel(operation);
                var binding = new RenameOperationDrawerBinding(operation, drawer);
                this.RenameOperationsToApplyWithBindings.Add(binding);
            }
            else
            {
                var ops = serializedOps.Split(',');
                foreach (var op in ops)
                {
                    foreach (var binding in this.RenameOperationDrawerBindingPrototypes)
                    {
                        if (binding.Drawer.MenuDisplayPath == op)
                        {
                            this.AddRenameOperation(binding);
                            break;
                        }
                    }
                }
            }

            if (this.NumRenameOperations > 0)
            {
                this.FocusRenameOperationDeferred(this.RenameOperationsToApplyWithBindings.First().Operation);
            }
        }
Example #2
0
        private void AddRenameOperation(RenameOperationDrawerBinding prototypeBinding)
        {
            // Reconstruct the operation and drawer so we are working with new instances
            var renameOp = prototypeBinding.Operation.Clone();
            var drawer   = (IRenameOperationDrawer)System.Activator.CreateInstance(prototypeBinding.Drawer.GetType());

            drawer.SetModel(renameOp);

            var binding = new RenameOperationDrawerBinding(renameOp, drawer);

            this.RenameOperationsToApplyWithBindings.Add(binding);

            this.SaveRenameOperationsToPreferences();

            // Scroll to the bottom to focus the newly created operation.
            this.ScrollRenameOperationsToBottom();

            this.FocusRenameOperationDeferred(renameOp);
        }