Exemplo n.º 1
0
        public void SetData <T>(string dataName, T data)
        {
            if (dataName == null)
            {
                return;
            }

            BTDebug.Info("BTDatabase: {0} = {1}", dataName, data);
            dataDic[dataName] = new WeakReference <object>(data);
        }
Exemplo n.º 2
0
        protected override BTResult OnTick(BTContext context)
        {
            string text = Message ?? "";

            switch (level)
            {
            case BTLogLevel.Info:
                BTDebug.Info(text);
                break;

            case BTLogLevel.Warning:
                BTDebug.Warning(text);
                break;

            case BTLogLevel.Error:
                BTDebug.Error(text);
                break;
            }

            return(BTResult.Success.Create(Message == null? "消息为空" : null));
        }
Exemplo n.º 3
0
        // Should use dataId as parameter to get data instead of this
        public T GetData <T>(string dataName)
        {
            if (dataName == null)
            {
                return(default(T));
            }

            if (!dataDic.ContainsKey(dataName))
            {
                BTDebug.Error("BTDatabase: Data for " + dataName + " does not exist!");
                return(default(T));
            }

            WeakReference <object> wr = dataDic[dataName];
            object o = null;

            if (!wr.TryGetTarget(out o))
            {
                return(default(T));
            }

            return((T)o);
        }