Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="action"></param>
 /// <param name="ip">ip地址</param>
 /// <param name="rate">多久ping一次</param>
 public AsyncRepeatingPingTask(Action <int> action, string ip, float rate) : base(action)
 {
     _timeStart = Time.realtimeSinceStartup;
     Action     = action;
     _ip        = ip;
     _rate      = rate;
     AssertThat.IsFalse(ip.Contains(":"));
     ping = new Ping(_ip);
 }
 /// <summary>
 /// Regist Component who inherited from ITick
 /// </summary>
 /// <param name="iComponent"></param>
 public void Regist(IComponent iComponent)
 {
     if (iComponent is ITick)
     {
         var iTick = iComponent as ITick;
         AssertThat.IsFalse(ticks.Contains(iTick));
         ticks.Add(iTick);
     }
 }
Пример #3
0
        public void CopyFile(string sourcePath, string destPath)
        {
            AssertThat.IsTrue(IsFileExist(sourcePath));
            AssertThat.IsFalse(IsFileExist(destPath));
            var directory = Path.GetDirectoryName(destPath);

            CreateFolder(directory);
            File.Copy(sourcePath, destPath, true);
        }
Пример #4
0
        /// <summary>
        /// Create componentBase
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        private ComponentBase CreateComponent <T>(Type key)
        {
            var componentType = Center.Binder.BindInfos[key];

            AssertThat.IsNotNull(componentType, "Have not bind this type");
            var c = Activator.CreateInstance(componentType) as ComponentBase;

            AssertThat.IsNotNull(c, "Create component faild");
            AssertThat.IsFalse(_components.ContainsKey(key), "Already have this component");
            _components[key] = c;
            c.OnCreated();
            return(c);
        }
Пример #5
0
        public void CopyFolder(string sourcePath, string destinationPath)
        {
            AssertThat.IsTrue(IsFileExist(sourcePath));
            AssertThat.IsFalse(IsFileExist(destinationPath));
            CreateFolder(destinationPath);
            var tempFiles = Directory.GetFiles(sourcePath);

            foreach (var variable in tempFiles)
            {
                var tempFileName = Path.GetFileName(variable);
                var tempDestName = Path.Combine(destinationPath, tempFileName);
                File.Copy(variable, tempDestName, true);
            }
            var tempDirs = Directory.GetDirectories(sourcePath);

            foreach (var variable in tempDirs)
            {
                var tempDirName     = Path.GetFileName(variable);
                var tempDestDirName = Path.Combine(destinationPath, tempDirName);
                CopyFolder(variable, tempDestDirName);
            }
        }
Пример #6
0
 /// <summary>
 /// Set bind infos
 /// </summary>
 /// <param name="key"></param>
 /// <param name="component"></param>
 internal void SetKeyAndComponent(Type key, Type component)
 {
     AssertThat.IsFalse(BindInfos.ContainsKey(key), "Already have this key" + key.ToString());
     BindInfos[key] = component;
 }
Пример #7
0
 public void CreateFolder(string path)
 {
     AssertThat.IsFalse(IsFileExist(path));
     Directory.CreateDirectory(path);
 }
Пример #8
0
 public void Regist <T>(T t) where T : ITick, new()
 {
     AssertThat.IsFalse(_ticks.Contains(t), "Tick list alreay has this componentBase");
     _ticks.Add(t);
 }
Пример #9
0
 public void AddObject(string name, object obj)
 {
     AssertThat.IsFalse(_objs.ContainsKey(name), "Alread have this key");
     _objs[name] = obj;
 }
Пример #10
0
 public void RecleimThisObjectToPool(T t)
 {
     AssertThat.IsFalse(_objects.Contains(t), "Already have this object");
     _objects.Add(t);
     t.OnObjectInPool();
 }
 public void AddTask(ITick task)
 {
     AssertThat.IsFalse(_asyncTasks.Contains(task), "task already exist");
     _asyncTasks.Add(task);
 }
Пример #12
0
 public void RecleimObject(T t)
 {
     AssertThat.IsFalse(_objects.Contains(t), "Already have this object");
     _objects.Add(t);
     _hanlder.OnObjectInPool(t);
 }
Пример #13
0
 /// <summary>
 /// Add component to list
 /// </summary>
 /// <param name="component"></param>
 private void AddComponentToList(IComponent component)
 {
     AssertThat.IsNotNull(component);
     AssertThat.IsFalse(components.Contains(component));
     components.Add(component);
 }