Пример #1
0
        private void RunChildPatch(DataAccessor <DMSource> accessor, DMSource model)
        {
            if (model.PatchClientID != null || model.PatchType != null)
            {
                var patchData = PatchTools.GetPatchData(model);
                if (patchData.PatchType == PatchTypeEnum.CREATE)
                {
                    accessor.CreateObject(model);
                }
                else if (patchData.PatchType == PatchTypeEnum.UPDATE)
                {
                    accessor.UpdateObject(model);
                }
                else if (patchData.PatchType == PatchTypeEnum.DELETE)
                {
                    accessor.DeleteObject(model.ID);
                }
            }

            accessor.DATA_MAP.ConnectionTypes.ForEach(connectionType =>
            {
                foreach (IDataModel connectionModel in accessor.DATA_MAP.ConnectionValue(connectionType, model))
                {
                    if (connectionModel.PatchType != null)
                    {
                        ExicuteNextChain(PatchTypeEnum.GetType(connectionModel.PatchType),
                                         accessor, connectionType, model, connectionModel);
                    }
                }
            });
        }
Пример #2
0
        private void RunChildAdd(DataAccessor <DMSource> accessor, DMSource model)
        {
            accessor.CreateObject(model);

            accessor.DATA_MAP.ConnectionTypes.ForEach(connectionType =>
            {
                foreach (IDataModel connectionModel in accessor.DATA_MAP.ConnectionValue(connectionType, model))
                {
                    if (connectionModel.PatchType != null)
                    {
                        ExicuteNextChain(PatchTypeEnum.GetType(connectionModel.PatchType),
                                         accessor, connectionType, model, connectionModel);
                    }
                }
            });
        }
Пример #3
0
        public PatchEntry(string line)
        {
            var parts = line.Split(new string[] { "->" }, StringSplitOptions.None);

            if (parts.Length < 2)
            {
                throw new PatchConfigException($"Invalid Entry : \"{line}\"");
            }

            for (int i = 0; i < parts.Length; i++)
            {
                parts[i] = parts[i].Trim(' ');
            }


            PatchType = (PatchTypeEnum)Enum.Parse(typeof(PatchTypeEnum), parts[0]);
            Address   = new MemAddress(parts[1]);

            switch (PatchType)
            {
            case PatchTypeEnum.bl:
            case PatchTypeEnum.b:
            case PatchTypeEnum.ptr:
                if (parts.Length != 3)
                {
                    throw new PatchConfigException($"Invalid Entry : \"{line}\"");
                }
                Data = new MemAddress(parts[2]);
                break;

            case PatchTypeEnum.data:
                if (parts.Length != 3)
                {
                    throw new PatchConfigException($"Invalid Entry : \"{line}\"");
                }
                Data = Utils.HexToBytes(parts[2]);
                break;

            default:
                throw new PatchConfigException("Invalid patch type");
            }
        }
Пример #4
0
        private void ExicuteNextChain(PatchTypeEnum type, DataAccessor <DMSource> accessor, Type connectionType,
                                      DMSource model, IDataModel connectionModel)
        {
            switch (type.EnumValue)
            {
            case PatchTypeEnum.Enum.Create:
            {
                Type managerType = RC.GetManagerType(connectionType);
                var  method      = GetMethod(managerType, connectionType);
                method.Invoke(RC.GetManager(connectionType), new object[] { CommitTypeEnum.ADD, connectionModel, 0 });
                accessor.CreateConnection(model, accessor.DATA_MAP.Connection(connectionType), connectionModel.ID);
                break;
            }

            case PatchTypeEnum.Enum.Update:
            {
                Type managerType = RC.GetManagerType(connectionType);
                var  method      = GetMethod(managerType, connectionType);
                method.Invoke(RC.GetManager(connectionType), new object[] { CommitTypeEnum.UPDATE, connectionModel, connectionModel.ID });
                accessor.UpdateConnection(model, accessor.DATA_MAP.Connection(connectionType), connectionModel.ID);
                break;
            }

            case PatchTypeEnum.Enum.Delete:
            {
                Type managerType = RC.GetManagerType(connectionType);
                var  method      = GetMethod(managerType, connectionType);
                method.Invoke(RC.GetManager(connectionType), new object[] { CommitTypeEnum.REMOVE, connectionModel, connectionModel.ID });
                accessor.DeleteConnection(model.GetConnectionID(connectionType, connectionModel.ID));
                break;
            }

            default:
                break;
            }
        }