PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/JTacticalSim.API/Component/Extension.cs

https://github.com/Queztionmark/JTacticalSim
C# | 663 lines | 404 code | 104 blank | 155 comment | 20 complexity | 18d431b68dc89d172f3e728ea8a7f5cb MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Reflection;
  6. using System.Drawing;
  7. using JTacticalSim.API.Component;
  8. using JTacticalSim.API.DTO;
  9. using JTacticalSim.API.Game;
  10. using JTacticalSim.API.Service;
  11. using JTacticalSim.Utility;
  12. using JTacticalSim.API.InfoObjects;
  13. namespace JTacticalSim.API.Component
  14. {
  15. public static class Extension
  16. {
  17. /// <summary>
  18. /// Returns all units at a given tile
  19. /// </summary>
  20. /// <param name="o"></param>
  21. /// <returns></returns>
  22. public static IEnumerable<IUnit> GetAllUnits(this IBoardComponent o)
  23. {
  24. var factions = o.TheGame().JTSServices.GameService.GetAllFactions();
  25. return o.TheGame().JTSServices.UnitService.GetUnitsAt(o.Location, factions);
  26. }
  27. /// <summary>
  28. /// Returns the net stealth adjustment for the geography of a given tile
  29. /// </summary>
  30. /// <param name="o"></param>
  31. /// <returns></returns>
  32. public static double GetNetStealthAdjustment(this ITile o)
  33. {
  34. return o.GetAllDemographics().Sum(d => d.DemographicClass.StealthModifier);
  35. }
  36. /// <summary>
  37. /// Returns the net attack adjustment for the geography of a given tile
  38. /// </summary>
  39. /// <param name="o"></param>
  40. /// <returns></returns>
  41. public static double GetNetAttackAdjustment(this ITile o)
  42. {
  43. return o.GetAllDemographics().Sum(d => d.DemographicClass.AttackModifier);
  44. }
  45. /// <summary>
  46. /// Returns the net defence adjustment for the geography of a given tile
  47. /// </summary>
  48. /// <param name="o"></param>
  49. /// <returns></returns>
  50. public static double GetNetDefenceAdjustment(this ITile o)
  51. {
  52. return o.GetAllDemographics().Sum(d => d.DemographicClass.DefenceModifier);
  53. }
  54. /// <summary>
  55. /// Returns the net movement adjustment for the geography of the tile
  56. /// </summary>
  57. /// <param name="o"></param>
  58. /// <returns></returns>
  59. public static int GetNetMovementAdjustment(this ITile o)
  60. {
  61. return Convert.ToInt32(Math.Round(o.GetAllDemographics().Sum(d => d.DemographicClass.MovementModifier)));
  62. }
  63. /// <summary>
  64. /// Returns an info object categorizing the strategy assessments of the tile.
  65. /// </summary>
  66. /// <param name="o"></param>
  67. /// <returns></returns>
  68. public static StrategicAssessmentInfo GetStrategicValues(this ITile o)
  69. {
  70. var r = o.TheGame().JTSServices.AIService.DetermineTileStrategicValue(o);
  71. if (r.Status == ResultStatus.EXCEPTION) throw r.ex;
  72. return r.Result;
  73. }
  74. /// <summary>
  75. /// Returns the average strategy assessment rating of the aggragated assessment ratings of the tile.
  76. /// </summary>
  77. /// <param name="o"></param>
  78. /// <returns></returns>
  79. public static StrategicAssessmentRating GetNetStrategicValue(this ITile o)
  80. {
  81. var r = o.TheGame().JTSServices.RulesService.GetOverallRatingForStrategicAssessment(o.GetStrategicValues());
  82. if (r.Status == ResultStatus.EXCEPTION) throw r.ex;
  83. if (r.Status == ResultStatus.FAILURE) o.HandleError(r.Message, null);
  84. return r.Result;
  85. }
  86. /// <summary>
  87. /// Returns the specific texture image for the tile
  88. /// </summary>
  89. /// <param name="o"></param>
  90. /// <returns></returns>
  91. public static Image GetDemographicTextureImage(this ITile o)
  92. {
  93. var r = o.TheGame().JTSServices.GraphicsService.GetDemographicTextureImage(o.SpriteName);
  94. return r;
  95. }
  96. /// <summary>
  97. /// Returns the default texture image for the first BaseGeography of the tile
  98. /// </summary>
  99. /// <param name="o"></param>
  100. /// <returns></returns>
  101. public static Image GetDefaultDemographicTextureImage(this ITile o)
  102. {
  103. var r = o.TheGame().JTSServices.GraphicsService.GetDefaultDemographicTextureImage(o.BaseGeography.FirstOrDefault().DemographicClass.SpriteName);
  104. return r;
  105. }
  106. public static List<IVictoryCondition> VictoryConditions(this IFaction f)
  107. {
  108. return f.TheGame().JTSServices.GameService.GetGameVictoryConditionsByFaction(f);
  109. }
  110. public static bool GameVictoryAchieved(this IFaction f)
  111. {
  112. return f.TheGame().JTSServices.RulesService.GameVictoryAchieved(f).Result;
  113. }
  114. public static bool IsBeingTransported(this IMoveableComponent o)
  115. {
  116. return o.TheGame().JTSServices.RulesService.ComponentIsBeingTransported(o).Result;
  117. }
  118. public static bool IsVisible(this IMoveableComponent o)
  119. {
  120. return o.TheGame().JTSServices.RulesService.ComponentIsVisible(o).Result;
  121. }
  122. public static IUnitStack GetCurrentStack(this IMoveableComponent o)
  123. {
  124. return o.TheGame().JTSServices.TileService.GetCurrentStack(o);
  125. }
  126. /// <summary>
  127. /// Converts an object of type IPathableObject to another type of IPathableObject
  128. /// retaining only the IPathableObject members
  129. /// </summary>
  130. /// <typeparam name="T"></typeparam>
  131. /// <param name="o"></param>
  132. /// <returns></returns>
  133. public static T ToPathableObject<T>(this IPathableObject o)
  134. where T : IPathableObject, new()
  135. {
  136. var retVal = new T();
  137. Type sourceType = o.GetType();
  138. Type destinationType = retVal.GetType();
  139. foreach (var p in sourceType.GetProperties())
  140. {
  141. var destinationP = destinationType.GetProperty(p.Name);
  142. if (destinationP != null && destinationP.CanWrite)
  143. {
  144. destinationP.SetValue(retVal, p.GetValue(o, null), null);
  145. }
  146. }
  147. return retVal;
  148. }
  149. /// <summary>
  150. /// Returns the net stealth adjustment for the type and class of a given unit
  151. /// </summary>
  152. /// <param name="o"></param>
  153. /// <returns></returns>
  154. public static double GetNetStealthAdjustment(this IUnit o)
  155. {
  156. return o.UnitInfo.UnitClass.StealthModifier +
  157. o.UnitInfo.UnitType.StealthModifier;
  158. }
  159. /// <summary>
  160. /// Returns the net attack adjustment for the type and class of a given unit
  161. /// </summary>
  162. /// <param name="o"></param>
  163. /// <returns></returns>
  164. public static double GetNetAttackAdjustment(this IUnit o)
  165. {
  166. return o.UnitInfo.UnitClass.AttackModifier +
  167. o.UnitInfo.UnitType.AttackModifier;
  168. }
  169. /// <summary>
  170. /// Returns the net attack distance adjustment for the type and class of a given unit
  171. /// </summary>
  172. /// <param name="o"></param>
  173. /// <returns></returns>
  174. public static int GetNetAttackDistanceAdjustment(this IUnit o)
  175. {
  176. return Convert.ToInt32(Math.Round(o.UnitInfo.UnitClass.AttackDistanceModifier)) +
  177. Convert.ToInt32(Math.Round(o.UnitInfo.UnitType.AttackDistanceModifier));
  178. }
  179. /// <summary>
  180. /// Returns the net defence adjustment for the type and class of a given unit
  181. /// </summary>
  182. /// <param name="o"></param>
  183. /// <returns></returns>
  184. public static double GetNetDefenceAdjustment(this IUnit o)
  185. {
  186. return o.UnitInfo.UnitClass.DefenceModifier +
  187. o.UnitInfo.UnitType.DefenceModifier;
  188. }
  189. /// <summary>
  190. /// Returns the net cost multiplier for the type and class of a given unit
  191. /// </summary>
  192. /// <param name="o"></param>
  193. /// <returns></returns>
  194. public static double GetNetCostMultiplier(this IUnit o)
  195. {
  196. return o.UnitInfo.UnitClass.UnitCostModifier +
  197. o.UnitInfo.UnitType.UnitCostModifier;
  198. }
  199. /// <summary>
  200. /// Returns the net movement adjustment for the type and class of a given unit
  201. /// </summary>
  202. /// <param name="o"></param>
  203. /// <returns></returns>
  204. public static int GetNetMovementAdjustment(this IUnit o)
  205. {
  206. return Convert.ToInt32(Math.Round(o.UnitInfo.UnitClass.MovementModifier)) +
  207. Convert.ToInt32(Math.Round(o.UnitInfo.UnitType.MovementModifier));
  208. }
  209. public static double GetWeight(this IUnit o)
  210. {
  211. return o.TheGame().JTSServices.RulesService.CalculateUnitWeight(o).Result;
  212. }
  213. public static double GetAllowableTransportWeight(this IUnit o)
  214. {
  215. return o.TheGame().JTSServices.RulesService.CalculateAllowableTransportWeight(o).Result;
  216. }
  217. /// <summary>
  218. /// Returns the relative 'strength' factor for a given unit based on rules criteria
  219. /// </summary>
  220. /// <param name="o"></param>
  221. /// <returns></returns>
  222. public static double GetNetStrengthFactor(this IUnit o)
  223. {
  224. return o.TheGame().JTSServices.RulesService.CalculateUnitStrength(o);
  225. }
  226. public static double GetUnitTargetDesirabilityFactor(this IUnit o)
  227. {
  228. return o.TheGame().JTSServices.RulesService.CalculateTargetDesirabilityForUnit(o);
  229. }
  230. public static bool IsCompatibleWithTransport(this IUnit o, IUnit transport)
  231. {
  232. return o.TheGame().JTSServices.RulesService.UnitCanTransportUnitTypeAndClass(transport, o).Result;
  233. }
  234. /// <summary>
  235. /// Removes the unit from it's current stack
  236. /// </summary>
  237. /// <param name="?"></param>
  238. /// <returns></returns>
  239. public static void RemoveFromStack(this IUnit o)
  240. {
  241. var stack = o.GetCurrentStack();
  242. if (stack != null) o.GetCurrentStack().RemoveUnit(o);
  243. }
  244. /// <summary>
  245. /// Fully removes the unit from the game data store, cache and current unit stack
  246. /// including any dependencies (assignments, transported units, etc..)
  247. /// </summary>
  248. /// <param name="o"></param>
  249. public static void RemoveFromGame(this IUnit o)
  250. {
  251. o.TheGame().JTSServices.UnitService.RemoveUnits(new List<IUnit> {o});
  252. o.TheGame().JTSServices.DataService.RemoveUnitAssignmentsFromUnit(o);
  253. o.GetTransportedUnits().ToList().ForEach(u => u.RemoveFromGame());
  254. o.RemoveFromStack();
  255. }
  256. public static void Select(this IUnit o)
  257. {
  258. var r = o.TheGame().GameBoard.AddSelectedUnit(o);
  259. if (r.Status != ResultStatus.SUCCESS)
  260. o.TheGame().CommandProcessor.SetInputError(r);
  261. }
  262. public static void Unselect(this IUnit o)
  263. {
  264. var r = o.TheGame().GameBoard.RemoveSelectedUnit(o);
  265. if (r.Status != ResultStatus.SUCCESS)
  266. o.TheGame().CommandProcessor.SetInputError(r);
  267. }
  268. public static bool IsSupplied(this IUnit o)
  269. {
  270. return o.TheGame().JTSServices.RulesService.UnitIsSupplied(o).Result;
  271. }
  272. public static bool HasMedicalSupport(this IUnit o)
  273. {
  274. return o.TheGame().JTSServices.RulesService.UnitHasMedicalSupport(o).Result;
  275. }
  276. public static bool IsUnitClass(this IUnit o, string className)
  277. {
  278. IServiceResult<bool> r = o.TheGame().JTSServices.RulesService.UnitIsUnitClass(o, className);
  279. //TODO: Handle result
  280. return r.Result;
  281. }
  282. public static bool IsUnitBaseType(this IUnit o, string baseTypeName)
  283. {
  284. IServiceResult<bool> r = o.TheGame().JTSServices.RulesService.UnitIsUnitBaseType(o, baseTypeName);
  285. //TODO: Handle result
  286. return r.Result;
  287. }
  288. public static bool CanDoBattleThisTurn(this IUnit o)
  289. {
  290. return o.TheGame().JTSServices.RulesService.UnitCanDoBattle(o).Result;
  291. }
  292. /// <summary>
  293. /// Determines wether this unit can occupy and claim a location for its faction
  294. /// </summary>
  295. /// <param name="o"></param>
  296. /// <returns></returns>
  297. public static bool CanClaimLocationForFaction(this IUnit o)
  298. {
  299. return o.TheGame().JTSServices.RulesService.UnitCanClaimNodeForFaction(o).Result;
  300. }
  301. public static bool IsRemoteBattleCapable(this IUnit o)
  302. {
  303. return (o.GetNetAttackDistanceAdjustment() > 0);
  304. }
  305. public static bool HasPathFromNodeInDirection(this IUnit o, Direction direction)
  306. {
  307. return o.TheGame().JTSServices.RulesService.UnitCanMoveInDirection(o, direction).Result;
  308. }
  309. public static double ReinforcementCost(this IUnitType o)
  310. {
  311. return (o.UnitCostModifier * o.TheGame().BasePointValues.CostBase);
  312. }
  313. public static double ReinforcementCost(this IUnitClass o)
  314. {
  315. return (o.UnitCostModifier * o.TheGame().BasePointValues.CostBase);
  316. }
  317. public static bool IsFriendly(this IBoardComponent o)
  318. {
  319. return o.Faction.Equals(o.TheGame().CurrentPlayerFaction);
  320. }
  321. public static void Refresh(this IBoard o)
  322. {
  323. var nodes = o.TheGame().JTSServices.NodeService.GetAllNodes().ToList();
  324. nodes.ForEach(n => n.DefaultTile().RefreshComponentStacks());
  325. }
  326. /// <summary>
  327. /// Returns the coordinate in the format x_y_z
  328. /// </summary>
  329. /// <returns></returns>
  330. public static string ToStringForName(this ICoordinate o)
  331. {
  332. return "{0}_{1}_{2}".F(o.X, o.Y, o.Z);
  333. }
  334. public static bool CanContinue(this IBattle o)
  335. {
  336. return o.TheGame().JTSServices.RulesService.BattleCanContinue(o).Result;
  337. }
  338. // ----------------------------------------------------------------------------------------------------
  339. // Display
  340. public static void DisplayInfo(this IPlayer player)
  341. {
  342. player.TheGame().Renderer.DisplayPlayerInfo(player);
  343. }
  344. public static void DisplayInfo(this IUnit unit)
  345. {
  346. unit.TheGame().Renderer.DisplayUnitInfo(unit);
  347. }
  348. public static void DisplayName(this IUnit unit)
  349. {
  350. unit.TheGame().Renderer.RenderUnitName(unit);
  351. }
  352. public static void DisplayInfo(this List<IUnit> units)
  353. {
  354. units.First().TheGame().Renderer.DisplayUnits(units);
  355. }
  356. public static void DisplayInfo(this ITile tile)
  357. {
  358. tile.TheGame().Renderer.DisplayTileInfo(tile);
  359. }
  360. public static void DisplayInfo(this INode node)
  361. {
  362. node.TheGame().Renderer.DisplayNodeInfo(node);
  363. }
  364. // Render
  365. public static void Render(this IBattle battle)
  366. {
  367. battle.TheGame().Renderer.On_BattlePreRender(new EventArgs());
  368. battle.TheGame().Renderer.RenderBattle(battle);
  369. battle.TheGame().Renderer.On_BattlePostRender(new EventArgs());
  370. }
  371. public static void RenderOutcome(this IBattle battle)
  372. {
  373. battle.TheGame().Renderer.RenderBattleOutcome(battle);
  374. }
  375. public static void RenderRetreat(this IBattle battle)
  376. {
  377. battle.TheGame().Renderer.RenderBattleRetreat(battle);
  378. }
  379. public static void Render(this IRound round)
  380. {
  381. round.TheGame().Renderer.On_RoundPreRender(new EventArgs());
  382. round.TheGame().Renderer.RenderBattleRound(round);
  383. round.TheGame().Renderer.On_RoundPostRender(new EventArgs());
  384. }
  385. public static void Render(this ISkirmish skirmish)
  386. {
  387. skirmish.TheGame().Renderer.On_SkirmishPreRender(new EventArgs());
  388. skirmish.TheGame().Renderer.RenderBattleSkirmish(skirmish);
  389. skirmish.TheGame().Renderer.On_SkirmishPostRender(new EventArgs());
  390. }
  391. public static void Render(this IBoard board)
  392. {
  393. board.TheGame().Renderer.On_BoardPreRender(new EventArgs());
  394. board.TheGame().Renderer.RenderBoard();
  395. board.TheGame().Renderer.On_BoardPostRender(new EventArgs());
  396. }
  397. public static void Render(this INode node)
  398. {
  399. node.TheGame().Renderer.On_NodePreRender(new EventArgs());
  400. node.TheGame().Renderer.RenderNode(node);
  401. node.TheGame().Renderer.On_NodePostRender(new EventArgs());
  402. }
  403. public static void Render(this ITile tile)
  404. {
  405. tile.TheGame().Renderer.On_TilePreRender(new EventArgs());
  406. tile.TheGame().Renderer.RenderTile(tile);
  407. tile.TheGame().Renderer.On_TilePostRender(new EventArgs());
  408. }
  409. public static void Render(this IUnit unit)
  410. {
  411. unit.TheGame().Renderer.On_UnitPreRender(new EventArgs());
  412. unit.TheGame().Renderer.RenderUnit(unit);
  413. unit.TheGame().Renderer.On_UnitPostRender(new EventArgs());
  414. }
  415. public static int Render(this IUnitStack stack)
  416. {
  417. return stack.TheGame().Renderer.RenderUnitStackInfo(stack);
  418. }
  419. // Data components
  420. public static bool IsDemographicType(this IDemographic o, string demographicTypeName)
  421. {
  422. var dt = o.TheGame().JTSServices.DemographicService.GetDemographicTypeByID(o.DemographicClass.DemographicType.ID);
  423. return (dt.Name.ToLowerInvariant() == demographicTypeName.ToLowerInvariant());
  424. }
  425. public static bool IsDemographicClass(this IDemographic o, string demographicClassName)
  426. {
  427. var dc = o.TheGame().JTSServices.DemographicService.GetDemographicClassByID(o.DemographicClass.ID);
  428. return (dc.Name.ToLowerInvariant() == demographicClassName.ToLowerInvariant());
  429. }
  430. public static bool IsHybrid(this IDemographic o)
  431. {
  432. return o.TheGame().JTSServices.RulesService.DemographicIsHybrid(o);
  433. }
  434. // Utility
  435. /// <summary>
  436. /// Resets the stack display order for individual units; refreshes and resets unit stacks at the node.
  437. /// </summary>
  438. /// <param name="node"></param>
  439. public static void ResetUnitStackOrder(this INode node)
  440. {
  441. var tile = node.DefaultTile();
  442. var stacks = tile.GetAllComponentStacks();
  443. var updateUnits = new List<IUnit>();
  444. stacks.ForEach(us =>
  445. {
  446. int i = 1;
  447. us.GetAllUnits().ForEach(u =>
  448. {
  449. u.StackOrder = i; i++;
  450. updateUnits.Add(u);
  451. });
  452. });
  453. node.DefaultTile().ResetComponentStackDisplayOrder();
  454. node.TheGame().JTSServices.UnitService.UpdateUnits(updateUnits);
  455. }
  456. public static void ResetComponentStackDisplayOrder(this ITile tile)
  457. {
  458. int i = 1;
  459. tile.GetAllComponentStacks().Where(cs => cs.HasVisibleComponents).ToList().ForEach(cs =>
  460. {
  461. cs.DisplayOrder = i; i++;
  462. });
  463. tile.TheGame().JTSServices.TileService.UpdateTiles(new List<ITile>{tile});
  464. }
  465. public static bool HasUniqueHame(this IUnit unit)
  466. {
  467. return unit.TheGame().JTSServices.RulesService.UnitNameIsUnique(unit.Name).Result;
  468. }
  469. public static bool NullOrNone(this List<IBaseComponent> o)
  470. {
  471. return (o == null || o.Count == 0);
  472. }
  473. public static bool ExistsInContext(this IBaseComponent o)
  474. {
  475. return o.TheGame().JTSServices.GenericComponentService.ExistsInContext(o);
  476. }
  477. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  478. /// <summary>
  479. /// Converts base data from one IServiceResult to another
  480. /// </summary>
  481. /// <typeparam name="T"></typeparam>
  482. /// <typeparam name="T2"></typeparam>
  483. /// <param name="result1"></param>
  484. /// <param name="result2"></param>
  485. public static void ConvertServiceResultData<T, T2>(this IServiceResult<T> result1, IServiceResult<T2> result2)
  486. {
  487. result1.Messages = result2.Messages;
  488. result1.Status = result2.Status;
  489. result1.ex = result2.ex;
  490. }
  491. /// <summary>
  492. /// Converts an IResult to a comparable base service result of the same generic type
  493. /// </summary>
  494. /// <typeparam name="T"></typeparam>
  495. /// <param name="componentResult"></param>
  496. /// <param name="serviceResult"></param>
  497. /// <returns></returns>
  498. public static void ConvertServiceResultData<T>(this IServiceResult<T> serviceResult,
  499. IResult<T> componentResult)
  500. {
  501. serviceResult.Messages = componentResult.Messages;
  502. serviceResult.Status = componentResult.Status;
  503. serviceResult.ex = componentResult.ex;
  504. serviceResult.Result = componentResult.Result;
  505. serviceResult.FailedObjects = componentResult.FailedObjects;
  506. serviceResult.SuccessfulObjects = componentResult.SuccessfulObjects;
  507. }
  508. /// <summary>
  509. /// Converts an IResult to a comparable base component result of the same generic type
  510. /// </summary>
  511. /// <typeparam name="T"></typeparam>
  512. /// <param name="componentResult"></param>
  513. /// <param name="serviceResult"></param>
  514. /// <returns></returns>
  515. public static void ConvertServiceResultData<T>(this IResult<T> componentResult,
  516. IServiceResult<T> serviceResult)
  517. {
  518. componentResult.Messages = serviceResult.Messages;
  519. componentResult.Status = serviceResult.Status;
  520. componentResult.ex = serviceResult.ex;
  521. componentResult.Result = serviceResult.Result;
  522. componentResult.FailedObjects = serviceResult.FailedObjects;
  523. componentResult.SuccessfulObjects = serviceResult.SuccessfulObjects;
  524. }
  525. /// <summary>
  526. /// Converts a service result to an IResult of the same generic type
  527. /// </summary>
  528. /// <typeparam name="T"></typeparam>
  529. /// <param name="componentResult"></param>
  530. /// <param name="serviceResult"></param>
  531. /// <param name="services"></param>
  532. public static void ConvertServiceResultData<T>(this IResult<T> componentResult,
  533. IServiceResult<T> serviceResult,
  534. IServiceDependant services)
  535. {
  536. var temp = services.GenericComponentService.ConvertServiceResultDataToComponentResult(serviceResult);
  537. componentResult.ex = temp.ex;
  538. componentResult.FailedObjects = temp.FailedObjects;
  539. componentResult.Messages = temp.Messages;
  540. componentResult.Result = temp.Result;
  541. componentResult.Status = temp.Status;
  542. componentResult.SuccessfulObjects = temp.SuccessfulObjects;
  543. }
  544. /// <summary>
  545. /// Returns a new IResult converted from a service result of the same generic type
  546. /// </summary>
  547. /// <typeparam name="T"></typeparam>
  548. /// <param name="serviceResult"></param>
  549. /// <param name="services"></param>
  550. /// <returns></returns>
  551. public static IResult<T> ConvertServiceResultData<T>(this IServiceResult<T> serviceResult,
  552. IServiceDependant services)
  553. {
  554. return services.GenericComponentService.ConvertServiceResultDataToComponentResult<T>(serviceResult);
  555. }
  556. //public static ICoordinate TopLeftAsCoordinate(this Rectangle r) { return _services.ComponentService.CreateCoordinate(r.Left, r.Top, 0); }
  557. //public static ICoordinate BottomRightAsCoordinate(this Rectangle r) { return _services.ComponentService.CreateCoordinate(r.Right, r.Bottom, 0); }
  558. }
  559. }