/// <summary> /// Loads the connected waypoints islands. /// </summary> /// <param name="waypoints">The waypoints.</param> /// <param name="connector">The connector.</param> public void LoadConnectedWaypointsIslands(String[] waypoints, IWaypointConnector connector) { if (waypoints == null || waypoints.Length == 0) { throw new Exception("MapName cannot be null"); } else if (connector.ConnectorType != ConnectorType.BETWEEN_COLLECTIONS_CONNECTEC) { throw new Exception("Wrong Type of Connector"); } int toadd = 0; foreach (var item in waypoints) { WaypointsCollection w = XmlContentLoader.LoadXmlContent(item, col.GetType()) as WaypointsCollection; foreach (Waypoint way in w.IdWaypoint.Values) { way.Id = way.Id + toadd; way.NeightBorWaypointsId = way.NeightBorWaypointsId.Select((p1, p2) => p1 + toadd).ToList <int>(); } IDictionary <int, Waypoint> xx = w.IdWaypoint.ToDictionary(t => t.Key + toadd, u => u.Value); w.IdWaypoint = new SerializableDictionary <int, Waypoint>(xx); toadd += w.IdWaypoint.Keys.Max(); this.col.IdWaypoint.Concate(w.IdWaypoint); } this.col = connector.ConnectWaypoints(col); }
public IProject Process(string filePath) { IXmlContentLoader loader = new XmlContentLoader(logger); loader.Load(filePath); if (!loader.IsSuccess) { return(null); } ProjectInfo info = ProcessProject(loader.Content, loader.FilePath); if (info == null) { return(null); } if (!info.IsNewFormat) { ProcessPackageConfig(info); } return(new Project(info.Path, info.Packages.ToImmutableDictionary())); }
/// <summary> /// Loads the unconnected waypoints. /// If it is connected, it will be unconnected /// </summary> /// <param name="FileName">Name of the file.</param> public void LoadUnconnectedWaypoints(String FileName) { if (FileName == null) { throw new Exception("MapName cannot be null"); } this.col = XmlContentLoader.LoadXmlContent(FileName, col.GetType()) as WaypointsCollection; if (col.State == WaypointsState.Connected) { Unconnect(); } }
/// <summary> /// Saves the connected waypoints to a file. /// </summary> /// <param name="fileName">Name of the file.</param> public void SaveConnectedWaypoints(String fileName) { if (col.State != WaypointsState.Connected) { throw new Exception("Waypoints are already Connected"); } else if (string.IsNullOrEmpty(fileName)) { throw new Exception("MapName cannot be null or empty"); } XmlContentLoader.SaveXmlContent(col, col.GetType(), fileName); }
public IConfig Process(string filePath) { IXmlContentLoader loader = new XmlContentLoader(logger); loader.Load(filePath); if (!loader.IsSuccess) { return(null); } return(ProcessConfig(loader.Content, loader.FilePath)); }
/// <summary> /// Loads the connected waypoints from a file /// </summary> /// <param name="FileName">Name of the file.</param> public void LoadConnectedWaypoints(String FileName) { if (FileName == null) { throw new Exception("MapName cannot be null"); } this.col = XmlContentLoader.LoadXmlContent(FileName, col.GetType()) as WaypointsCollection; foreach (Waypoint item in col.GetWaypointsList()) { if (item.Id > id) { id = item.Id + 1; } } col.State = WaypointsState.Connected; }
private void ProcessPackageConfig(ProjectInfo info) { string directoryPath = Path.GetDirectoryName(info.Path); string configPath = Path.Combine(directoryPath, PACKAGES_CONFIG_FILE_NAME); IXmlContentLoader loader = new XmlContentLoader(logger); loader.Load(configPath); if (!loader.IsSuccess) { return; } XElement root = loader.Content.Root; if (root == null || root.Name.LocalName != "packages") { return; } XNamespace xmlNamespace = root.GetDefaultNamespace(); foreach (XElement elementPackage in root.Elements(xmlNamespace + "package")) { string packageId = (string)elementPackage.Attribute("id"); string version = GetValueFromElement(elementPackage, "version", xmlNamespace); if (string.IsNullOrWhiteSpace(packageId) || string.IsNullOrWhiteSpace(version)) { logger.Warn("Invalid package definition in " + PACKAGES_CONFIG_FILE_NAME + ".", loader.FilePath, elementPackage); continue; } info.Packages[packageId] = new Package(packageId, version, CanBeUpdated(packageId, version)); } }