예제 #1
0
        private void UpdateMethods()
        {
            if (IsValid != true || SelectedItem == null || string.IsNullOrEmpty(OperationCode))
            {
                return;
            }

            var methods     = SelectedItem.PmMethodCodes;
            var emptyresult = new EditableBusinessObjectCollection <object>();

            emptyresult.AcceptChanges();

            if (!methods.ContainsKey(OperationCode))
            {
                methods[OperationCode] = emptyresult;
            }

            if (methods[OperationCode] == null)
            {
                methods[OperationCode] = emptyresult;
            }

            var result = methods[OperationCode];

            var id  = SelectedItem.Id;
            var key = string.Format("{0}:{1}", id, OperationCode);

            if (!_owner.IsDeleted.ContainsKey(key))
            {
                _owner.IsDeleted[key] = true;
                if (!_owner.DataForDelete.ContainsKey(id))
                {
                    _owner.DataForDelete[id] = SelectedItem.Clone();
                }
                var oldvalue = result == null
                    ? new EditableBusinessObjectCollection <object>()
                    : new EditableBusinessObjectCollection <object>(result);
                oldvalue.AcceptChanges();
                _owner.DataForDelete[id].PmMethodCodes[OperationCode] = oldvalue;
            }

            //Показываем выбранные методы в гриде
            result.Clear();
            if (SelectedMethods != null)
            {
                foreach (var m in SelectedMethods)
                {
                    result.Add(m);
                }
                result.AcceptChanges();
            }

            if (!NotNeedRefresh)
            {
                SetIsDirty();
            }
        }
예제 #2
0
        private EditableBusinessObjectCollection <object> GetTrueMethods(string opcode, IDictionary <string, EditableBusinessObjectCollection <object> > methods)
        {
            if (methods == null)
            {
                throw new ArgumentNullException("methods");
            }

            var emptyResult = new EditableBusinessObjectCollection <object>();

            emptyResult.AcceptChanges();

            if (string.IsNullOrEmpty(opcode))
            {
                return(emptyResult);
            }

            if (!methods.ContainsKey(opcode))
            {
                methods[opcode] = emptyResult;
            }

            return(methods[opcode] ?? (methods[opcode] = emptyResult));
        }