aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Core/ExtensionMethods
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-01-08 15:28:10 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-01-08 15:28:10 +0200
commitd1e8b5dc2cfa93bf042773b4bf04a0f0bfc1f53d (patch)
tree1bcd27f1461650204ba2e7b340f271ce703b1a41 /Software/Visual_Studio/Tango.Core/ExtensionMethods
parent0ec56a54ca0c64a2f7ba402a1b99b3c217cd5ae5 (diff)
downloadTango-d1e8b5dc2cfa93bf042773b4bf04a0f0bfc1f53d.tar.gz
Tango-d1e8b5dc2cfa93bf042773b4bf04a0f0bfc1f53d.zip
Added code comments for:
CodeGeneration. Core.
Diffstat (limited to 'Software/Visual_Studio/Tango.Core/ExtensionMethods')
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/DateTimeExtensions.cs3
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/DependencyObjectExtensions.cs4
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs12
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs4
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/IMessageExtensions.cs3
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/IServiceLocatorExtensions.cs14
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs16
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs41
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs11
-rw-r--r--Software/Visual_Studio/Tango.Core/ExtensionMethods/TypeExtensions.cs (renamed from Software/Visual_Studio/Tango.Core/ExtensionMethods/ReflectionExtensions.cs)28
10 files changed, 108 insertions, 28 deletions
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/DateTimeExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/DateTimeExtensions.cs
index 2c413b787..8e1b539fb 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/DateTimeExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/DateTimeExtensions.cs
@@ -5,6 +5,9 @@ using System.Text;
using System.Threading.Tasks;
+/// <summary>
+/// Contains <see cref="DateTime"/> extension methods.
+/// </summary>
public static class DateTimeExtensions
{
/// <summary>
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/DependencyObjectExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/DependencyObjectExtensions.cs
index 16fd43728..565582318 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/DependencyObjectExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/DependencyObjectExtensions.cs
@@ -8,9 +8,9 @@ using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
-/// <exclude/>
+
/// <summary>
-/// Contains a collection of DependencyObject extension methods.
+/// Contains a collection of <see cref="DependencyObject"/> extension methods.
/// </summary>
public static class DependencyObjectExtensions
{
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs
index 106dd4f44..e5beea90a 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/EnumExtensions.cs
@@ -6,12 +6,15 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
+/// <summary>
+/// Contains <see cref="Enum"/> extension methods.
+/// </summary>
public static class EnumExtensions
{
/// <summary>
- /// Gets the Enum value description.
+ /// Gets the Enum description attribute value.
/// </summary>
- /// <param name="value">The value.</param>
+ /// <param name="value">The enum value.</param>
/// <returns></returns>
public static String ToDescription(this Enum value)
{
@@ -26,6 +29,11 @@ public static class EnumExtensions
return value.ToString();
}
+ /// <summary>
+ /// Gets the enum integer value.
+ /// </summary>
+ /// <param name="value">The value.</param>
+ /// <returns></returns>
public static int ToInt32(this Enum value)
{
return (int)((object)value);
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs
index a0bad0323..e6fea6393 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IEnumerableExtensions.cs
@@ -5,7 +5,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-
+/// <summary>
+/// Contains <see cref="IEnumerable{T}"/> extension methods.
+/// </summary>
public static class IEnumerableExtensions
{
/// <summary>
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IMessageExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IMessageExtensions.cs
index 53522780a..2a5ef523b 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IMessageExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IMessageExtensions.cs
@@ -6,6 +6,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
+/// <summary>
+/// Contains <see cref="IMessage"/> extension methods.
+/// </summary>
public static class IMessageExtensions
{
/// <summary>
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IServiceLocatorExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IServiceLocatorExtensions.cs
index d39cf478f..3b5496578 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/IServiceLocatorExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/IServiceLocatorExtensions.cs
@@ -6,8 +6,16 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
+/// <summary>
+/// Contains <see cref="IServiceLocator"/> extension methods.
+/// </summary>
public static class IServiceLocatorExtensions
{
+ /// <summary>
+ /// Gets all registered instances.
+ /// </summary>
+ /// <param name="locator">The service locator.</param>
+ /// <returns></returns>
public static List<Object> GetAllInstances(this IServiceLocator locator)
{
var dictionaries = locator.GetType().GetField("_instancesRegistry", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(locator) as Dictionary<Type, Dictionary<string, object>>;
@@ -15,6 +23,12 @@ public static class IServiceLocatorExtensions
return instances;
}
+ /// <summary>
+ /// Gets all instances by the specified base type T.
+ /// </summary>
+ /// <typeparam name="T">Base type</typeparam>
+ /// <param name="locator">The service locator.</param>
+ /// <returns></returns>
public static List<T> GetAllInstancesByBase<T>(this IServiceLocator locator)
{
return locator.GetAllInstances().Where(x => typeof(T).IsAssignableFrom(x.GetType())).Select(x => (T)x).ToList();
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs
index 87beb06c3..c0baeef79 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObjectExtensions.cs
@@ -7,9 +7,17 @@ using System.Text;
using System.Threading.Tasks;
using Tango.Serialization;
-
+/// <summary>
+/// Contains <see cref="Object"/> extension methods.
+/// </summary>
public static class ObjectExtensions
{
+ /// <summary>
+ /// Performs shallow cloning of the object excluding generic properties..
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="obj">The object.</param>
+ /// <returns></returns>
public static T ShallowClone<T>(this T obj)
{
var cloned = Activator.CreateInstance<T>();
@@ -25,6 +33,12 @@ public static class ObjectExtensions
return cloned;
}
+ /// <summary>
+ /// Performs a shallow mapping to the specified object excluding generic properties.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="source">The source.</param>
+ /// <param name="destination">The destination object.</param>
public static void ShallowCopyTo<T>(this T source, T destination)
{
foreach (var prop in typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance))
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs
index 4f2d9ca20..d7161953f 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ObservableCollectionExtensions.cs
@@ -5,32 +5,41 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
-
+/// <summary>
+/// Contains <see cref="ObservableCollection{T}"/> extension methods.
+/// </summary>
public static class ObservableCollectionExtensions
{
+
/// <summary>
- /// Replace an element in the array.
+ /// Replaces the specified old element with the specified new element.
/// </summary>
/// <typeparam name="T"></typeparam>
- /// <param name="items">The items.</param>
- /// <param name="condition">The condition.</param>
- /// <param name="replaceAction">The replace action.</param>
- /// <returns></returns>
- public static void Replace<T>(this ObservableCollection<T> items, T oldElement, T newElement)
+ /// <param name="collection">The observable collection.</param>
+ /// <param name="oldElement">The old element.</param>
+ /// <param name="newElement">The new element.</param>
+ public static void Replace<T>(this ObservableCollection<T> collection, T oldElement, T newElement)
{
- int index = items.IndexOf(oldElement);
- items.Remove(oldElement);
- items.Insert(index, newElement);
+ int index = collection.IndexOf(oldElement);
+ collection.Remove(oldElement);
+ collection.Insert(index, newElement);
}
- public static void Swap<T>(this ObservableCollection<T> items, T element1, T element2)
+ /// <summary>
+ /// Swaps the specified elements.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="collection">The observable collection.</param>
+ /// <param name="element1">Element1.</param>
+ /// <param name="element2">Element2.</param>
+ public static void Swap<T>(this ObservableCollection<T> collection, T element1, T element2)
{
- int index1 = items.IndexOf(element1);
- int index2 = items.IndexOf(element2);
+ int index1 = collection.IndexOf(element1);
+ int index2 = collection.IndexOf(element2);
- T tmp = items[index1];
- items[index1] = items[index2];
- items[index2] = tmp;
+ T tmp = collection[index1];
+ collection[index1] = collection[index2];
+ collection[index2] = tmp;
}
}
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs
index 544b4a1da..ff8174976 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/StringExtensions.cs
@@ -6,6 +6,9 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
+/// <summary>
+/// Contains <see cref="String"/> extension methods.
+/// </summary>
public static class StringExtensions
{
private static Regex titleRegEx;
@@ -22,7 +25,7 @@ public static class StringExtensions
}
/// <summary>
- /// Normal ToString conversion with null checking.
+ /// Converts the object to string. If the object is null, will return null.
/// </summary>
/// <param name="obj">The object.</param>
/// <returns></returns>
@@ -42,7 +45,7 @@ public static class StringExtensions
}
/// <summary>
- /// Formats the string to title style.
+ /// Formats the string as title style.
/// </summary>
/// <param name="str">The string.</param>
/// <returns></returns>
@@ -52,7 +55,7 @@ public static class StringExtensions
}
/// <summary>
- /// Singularizes the specified text.
+ /// Singularizes the string.
/// </summary>
/// <param name="text">The text.</param>
/// <returns></returns>
@@ -63,7 +66,7 @@ public static class StringExtensions
}
/// <summary>
- /// Pluralizes the specified text.
+ /// Pluralizes the string.
/// </summary>
/// <param name="text">The text.</param>
/// <returns></returns>
diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ReflectionExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/TypeExtensions.cs
index 7efcd925d..a73685658 100644
--- a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ReflectionExtensions.cs
+++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/TypeExtensions.cs
@@ -5,8 +5,17 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
-public static class ReflectionExtensions
+/// <summary>
+/// Contains <see cref="Type"/> extension methods.
+/// </summary>
+public static class TypeExtensions
{
+ /// <summary>
+ /// Gets all the extension methods registered in the specified assembly.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <param name="extensionsAssembly">The extensions assembly.</param>
+ /// <returns></returns>
public static IEnumerable<MethodInfo> GetExtensionMethods(this Type type, Assembly extensionsAssembly)
{
var query = from t in extensionsAssembly.GetTypes()
@@ -19,12 +28,27 @@ public static class ReflectionExtensions
return query;
}
+ /// <summary>
+ /// Gets the specified extension method by assembly and name.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <param name="extensionsAssembly">The extensions assembly.</param>
+ /// <param name="name">The name.</param>
+ /// <returns></returns>
public static MethodInfo GetExtensionMethod(this Type type, Assembly extensionsAssembly, string name)
{
return type.GetExtensionMethods(extensionsAssembly).FirstOrDefault(m => m.Name == name);
}
- public static MethodInfo GetExtensionMethod(this Type type, Assembly extensionsAssembly, string name, Type[] types)
+ /// <summary>
+ /// Gets the extension method.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <param name="extensionsAssembly">The extensions assembly.</param>
+ /// <param name="name">The name.</param>
+ /// <param name="types">The types.</param>
+ /// <returns></returns>
+ private static MethodInfo GetExtensionMethod(this Type type, Assembly extensionsAssembly, string name, Type[] types)
{
var methods = (from m in type.GetExtensionMethods(extensionsAssembly)
where m.Name == name