﻿#region License
/*****************************************************************************
 *
 *Copyright 2016 cathy33
 *
 *Licensed under the Apache License, Version 2.0 (the "License");
 *you may not use this file except in compliance with the License.
 *You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *Unless required by applicable law or agreed to in writing, software
 *distributed under the License is distributed on an "AS IS" BASIS,
 *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *See the License for the specific language governing permissions and
 *limitations under the License.
 *
 *****************************************************************************/
#endregion

using Infinity.Core.Data;
using Infinity.Core.Event;
using Infinity.Core.Variant;

namespace Infinity.Client
{
    partial class CKernel
    {
        public void RegisterEntityCallback(string entity_type, EntityEvent event_enum, DataEventHandler handler)
        {
            _DataCallbackManager.AddEntityCallback(entity_type, event_enum, handler);
        }

        public void RegisterPropertyCallback(string entity_type, string property_name, PropertyEvent event_enum, DataEventHandler handler)
        {
            _DataCallbackManager.AddPropertyCallback(entity_type, property_name, event_enum, handler);
        }

        public void RegisterRecordCallback(string entity_type, string record_name, RecordEvent event_enum, DataEventHandler handler)
        {
            _DataCallbackManager.AddRecordCallback(entity_type, record_name, event_enum, handler);
        }

        public void RegisterContainerCallback(string entity_type, string container_name, ContainerEvent event_enum, DataEventHandler handler)
        {
            _DataCallbackManager.AddContainerCallback(entity_type, container_name, event_enum, handler);
        }

        public void RegisterCommandCallback(int command_msg, MsgEventHandler handler)
        {
            _CommandMsgCallbackManager.AddEvent(command_msg, handler);
        }

        public void RegisterSystemCallback(int custom_msg, MsgEventHandler handler)
        {
            _CustomMsgCallbackManager.AddEvent(custom_msg, handler);
        }

        public void CallCommandMsgHandler(PersistID self, int command_msg, VariantList msg)
        {
            _CommandMsgCallbackManager.CallbackHandler(command_msg, this, self, msg);
        }

        public void CallSystemMsgHandler(PersistID self, int custom_msg, VariantList msg)
        {
            _CustomMsgCallbackManager.CallbackHandler(custom_msg, this, self, msg);
        }

        public void RegisterDataTypeCallback(DataType data_type, TypeEventHandler handler)
        {
            _DataTypeCallbackManager.AddEvent(data_type, handler);
        }

        public void CallDataTypeCallback(DataType data_type, PersistID self, VariantList args)
        {
            _DataTypeCallbackManager.CallbackHandler(data_type, this, self, args);
        }

        public void RegisterCustomCallback(int custom_msg, MsgEventHandler handler)
        {
            _CustomMsgCallbackManager.AddEvent(custom_msg, handler);
        }

        public void CallCustomMsgHandler(PersistID self, int custom_msg, VariantList msg)
        {
            _CustomMsgCallbackManager.CallbackHandler(custom_msg, this, self, msg);
        }
    }
}
