/// <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); } }
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); }
/// <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); }
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); } }
/// <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; }
public void CreateFolder(string path) { AssertThat.IsFalse(IsFileExist(path)); Directory.CreateDirectory(path); }
public void Regist <T>(T t) where T : ITick, new() { AssertThat.IsFalse(_ticks.Contains(t), "Tick list alreay has this componentBase"); _ticks.Add(t); }
public void AddObject(string name, object obj) { AssertThat.IsFalse(_objs.ContainsKey(name), "Alread have this key"); _objs[name] = obj; }
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); }
public void RecleimObject(T t) { AssertThat.IsFalse(_objects.Contains(t), "Already have this object"); _objects.Add(t); _hanlder.OnObjectInPool(t); }
/// <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); }