public void Parse() { Targets.Clear(); SetCommands.Clear(); allCommands.Clear(); blocks.Clear(); Children.Clear(); projectName = ""; contentFile = new TextFile(file); foreach (Match m in ReadNextCommand()) { try { ParseCommand(m); } catch (Exception ex) { throw new Exception(string.Format("Exception: {0}\nFile: {1}", ex.Message, file)); } } VariableManager = new CMakeVariableManager(this); foreach (CMakeCommand command in targetCommands) { CMakeTarget target = new CMakeTarget(command, this); if (!target.IsAliasOrImported) { Targets.Add(string.Format("{0}:{1}", target.Name, command.Offset), target); target.PrintTarget(); } } targetCommands.Clear(); foreach (CMakeFileFormat f in Children.Values) { targets = targets.Concat(f.Targets).ToDictionary(x => x.Key, x => x.Value); } if (blocks.Count > 0) { CMakeCommand c = blocks.Pop(); throw new Exception(string.Format("Unmatched block command '{0}' in file '{1}' offset '{2}'.", c.Name, file, c.Offset)); } LoggingService.LogDebug("CMake file '{0}' is Loaded.", file); }
public void SetServerIp253(int port) { archorPort = port; foreach (var archor in archorList) { string archorIp = archor.GetClientIP(); var localIp = IpHelper.GetLocalIp(archorIp); if (localIp == null) { continue; } var udp = GetLightUDP(localIp); IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(archorIp), archorPort); var cmd = ""; if (archorIp.StartsWith("192.168.3.")) { if (archor.ServerIp != "192.168.3.253") { cmd = SetCommands.GetCmd("192.168.3.253"); } } else if (archorIp.StartsWith("192.168.4.")) { if (archor.ServerIp != "192.168.4.253") { cmd = SetCommands.GetCmd("192.168.4.253"); } } else if (archorIp.StartsWith("192.168.5.")) { if (archor.ServerIp != "192.168.5.253") { cmd = SetCommands.GetCmd("192.168.5.253"); } } udp.SendHex(cmd, ipEndPoint); AddLog(string.Format("发送 :: [{0}]:{1}", ipEndPoint, cmd)); } }
public string SRandMember(string key) => Multi(SetCommands.SRandMember(key));
public Task <long> SCardAsync(string key) => MultiAsync(SetCommands.SCard(key));
public Task <long> SUnionStoreAsync(string destination, params string[] keys) => MultiAsync(SetCommands.SUnionStore(destination, keys));
public Task <string[]> SUnionAsync(params string[] keys) => MultiAsync(SetCommands.SUnion(keys));
public Task <long> SRemAsync(string key, params object[] members) => MultiAsync(SetCommands.SRem(key, members));
public Task <string[]> SRandMemberAsync(string key, long count) => MultiAsync(SetCommands.SRandMember(key, count));
public Task <bool> SIsMemberAsync(string key, object member) => MultiAsync(SetCommands.SIsMember(key, member));
public bool SIsMember(string key, object member) => Multi(SetCommands.SIsMember(key, member));
public Task <string[]> SInterAsync(params string[] keys) => MultiAsync(SetCommands.SInter(keys));
public string[] SInter(params string[] keys) => Multi(SetCommands.SInter(keys));
public Task <string[]> SDiffAsync(params string[] keys) => MultiAsync(SetCommands.SDiff(keys));
public string[] SDiff(params string[] keys) => Multi(SetCommands.SDiff(keys));
public Task <string> SRandMemberAsync(string key) => MultiAsync(SetCommands.SRandMember(key));
public string[] SRandMember(string key, long count) => Multi(SetCommands.SRandMember(key, count));
public string[] SMembers(string key) => Multi(SetCommands.SMembers(key));
public long SRem(string key, params object[] members) => Multi(SetCommands.SRem(key, members));
public Task <string[]> SMembersAsync(string key) => MultiAsync(SetCommands.SMembers(key));
public string[] SUnion(params string[] keys) => Multi(SetCommands.SUnion(keys));
public bool SMove(string source, string destination, object member) => Multi(SetCommands.SMove(source, destination, member));
public long SUnionStore(string destination, params string[] keys) => Multi(SetCommands.SUnionStore(destination, keys));
public Task <bool> SMoveAsync(string source, string destination, object member) => MultiAsync(SetCommands.SMove(source, destination, member));
void ParseCommand(Match commandMatch) { string commandName = id.Match(commandMatch.Value).Value; CMakeCommand command = new CMakeCommand(commandName, commandMatch, this); switch (command.Name.ToLower()) { case "if": blocks.Push(command); break; case "elseif": blocks.Pop(); blocks.Push(command); break; case "else": blocks.Pop(); blocks.Push(command); break; case "endif": blocks.Pop(); break; case "while": blocks.Push(command); break; case "endwhile": blocks.Pop(); break; case "foreach": blocks.Push(command); break; case "endforeach": blocks.Pop(); break; case "project": projectName = command.Arguments [0].ToString(); break; case "set": SetCommands.Add(string.Format("{0}:{1}", command.Arguments [0].GetValues() [0], commandMatch.Index), command); break; case "add_library": case "add_executable": targetCommands.Add(command); break; case "add_subdirectory": var temp = new FilePath(command.Arguments [0].ToString()); var fullPath = file.ParentDirectory.Combine(temp).Combine("CMakeLists.txt"); if (!System.IO.File.Exists(fullPath)) { break; } if (Parent == null) { if (!Children.ContainsKey(temp)) { Children.Add(temp, new CMakeFileFormat(fullPath, Project, this)); } } else { if (!Parent.Children.ContainsKey(temp)) { Children.Add(temp, new CMakeFileFormat(fullPath, Project, Parent)); } } break; } command.IsNested = blocks.Count == 0; allCommands.Add(string.Format("{0}:{1}", commandName, commandMatch.Index), command); }
public string SPop(string key) => Multi(SetCommands.SPop(key));
public Task <string> SPopAsync(string key) => MultiAsync(SetCommands.SPop(key));
public long SCard(string key) => Multi(SetCommands.SCard(key));