diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-08 15:28:10 +0200 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-01-08 15:28:10 +0200 |
| commit | d1e8b5dc2cfa93bf042773b4bf04a0f0bfc1f53d (patch) | |
| tree | 1bcd27f1461650204ba2e7b340f271ce703b1a41 /Software | |
| parent | 0ec56a54ca0c64a2f7ba402a1b99b3c217cd5ae5 (diff) | |
| download | Tango-d1e8b5dc2cfa93bf042773b4bf04a0f0bfc1f53d.tar.gz Tango-d1e8b5dc2cfa93bf042773b4bf04a0f0bfc1f53d.zip | |
Added code comments for:
CodeGeneration.
Core.
Diffstat (limited to 'Software')
31 files changed, 409 insertions, 73 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index f213af0d4..5d341b835 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; -using Tango.Core.Threading; +using Tango.Core.Helpers; using Tango.DAL.Observables; using Tango.MachineStudio.Common.Modules; using Tango.MachineStudio.Common.Navigation; @@ -29,7 +29,7 @@ namespace Tango.MachineStudio.UI.ViewModels private void Load() { - StaThreadHelper.StartStaThread(() => + ThreadsHelper.StartStaThread(() => { try { diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Class.cs b/Software/Visual_Studio/Tango.CodeGeneration/Class.cs index 45a32ae3e..6f1f4f3b9 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/Class.cs +++ b/Software/Visual_Studio/Tango.CodeGeneration/Class.cs @@ -6,6 +6,10 @@ using System.Threading.Tasks; namespace Tango.CodeGeneration { + /// <summary> + /// Represents a class code object + /// </summary> + /// <seealso cref="Tango.CodeGeneration.CodeObject" /> public class Class : CodeObject { /// <summary> diff --git a/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFile.cs b/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFile.cs index 7de161f71..bc0f37929 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFile.cs +++ b/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFile.cs @@ -6,26 +6,65 @@ using System.Threading.Tasks; namespace Tango.CodeGeneration { + /// <summary> + /// Represents a database entity code file. + /// </summary> + /// <seealso cref="Tango.CodeGeneration.Class" /> public class EntityCodeFile : Class { + /// <summary> + /// Gets or sets the name of the entity. + /// </summary> public String EntityName { get; set; } + /// <summary> + /// Gets or sets the name of the table. + /// </summary> public String TableName { get; set; } + /// <summary> + /// Gets or sets the table fields. + /// </summary> public List<EntityCodeFileField> Fields { get; set; } + /// <summary> + /// Initializes a new instance of the <see cref="EntityCodeFile"/> class. + /// </summary> + /// <param name="name">The code file name.</param> public EntityCodeFile(String name) : base(name) { Fields = new List<EntityCodeFileField>(); } } + /// <summary> + /// Represents a database entity code file field. + /// </summary> public class EntityCodeFileField { + /// <summary> + /// Gets or sets the name. + /// </summary> public String Name { get; set; } + + /// <summary> + /// Gets or sets the name of the field. + /// </summary> public String FieldName { get; set; } + + /// <summary> + /// Gets or sets the type. + /// </summary> public String Type { get; set; } + + /// <summary> + /// Gets or sets the description. + /// </summary> public String Description { get; set; } + + /// <summary> + /// Gets or sets a value indicating whether to initialize this field in the constructor. + /// </summary> public bool Construct { get; set; } } } diff --git a/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFileJava.cs b/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFileJava.cs index d2bfd80fc..194cd0fc1 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFileJava.cs +++ b/Software/Visual_Studio/Tango.CodeGeneration/EntityCodeFileJava.cs @@ -6,14 +6,31 @@ using System.Threading.Tasks; namespace Tango.CodeGeneration { + /// <summary> + /// Represents a database entity Java code file. + /// </summary> + /// <seealso cref="Tango.CodeGeneration.Class" /> public class EntityCodeFileJava : Class { + /// <summary> + /// Gets or sets the name of the entity. + /// </summary> public String EntityName { get; set; } + /// <summary> + /// Gets or sets the name of the table. + /// </summary> public String TableName { get; set; } + /// <summary> + /// Gets or sets the table fields. + /// </summary> public List<EntityCodeFileField> Fields { get; set; } + /// <summary> + /// Initializes a new instance of the <see cref="EntityCodeFileJava"/> class. + /// </summary> + /// <param name="name">The code file name.</param> public EntityCodeFileJava(String name) : base(name) { Fields = new List<EntityCodeFileField>(); diff --git a/Software/Visual_Studio/Tango.CodeGeneration/EnumerationField.cs b/Software/Visual_Studio/Tango.CodeGeneration/EnumerationField.cs index f8bb98b9b..038055cb9 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/EnumerationField.cs +++ b/Software/Visual_Studio/Tango.CodeGeneration/EnumerationField.cs @@ -6,10 +6,24 @@ using System.Threading.Tasks; namespace Tango.CodeGeneration { + /// <summary> + /// Represents a single enumeration field. + /// </summary> public class EnumerationField { + /// <summary> + /// Gets or sets the field name. + /// </summary> public String Name { get; set; } + + /// <summary> + /// Gets or sets the value. + /// </summary> public int Value { get; set; } + + /// <summary> + /// Gets or sets an optional description. + /// </summary> public String Description { get; set; } } } diff --git a/Software/Visual_Studio/Tango.CodeGeneration/EnumerationFile.cs b/Software/Visual_Studio/Tango.CodeGeneration/EnumerationFile.cs index e49b7fa48..800513912 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/EnumerationFile.cs +++ b/Software/Visual_Studio/Tango.CodeGeneration/EnumerationFile.cs @@ -6,12 +6,25 @@ using System.Threading.Tasks; namespace Tango.CodeGeneration { + /// <summary> + /// Represents enumeration code file. + /// </summary> + /// <seealso cref="Tango.CodeGeneration.CodeFile" /> public class EnumerationFile : CodeFile { + /// <summary> + /// Gets or sets enum the name. + /// </summary> public String Name { get; set; } + /// <summary> + /// Gets or sets the collection of enum fields. + /// </summary> public List<EnumerationField> Fields { get; set; } + /// <summary> + /// Initializes a new instance of the <see cref="EnumerationFile"/> class. + /// </summary> public EnumerationFile() { Fields = new List<EnumerationField>(); diff --git a/Software/Visual_Studio/Tango.CodeGeneration/EnumerationFileJava.cs b/Software/Visual_Studio/Tango.CodeGeneration/EnumerationFileJava.cs index 6a42326f7..205e528df 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/EnumerationFileJava.cs +++ b/Software/Visual_Studio/Tango.CodeGeneration/EnumerationFileJava.cs @@ -6,12 +6,25 @@ using System.Threading.Tasks; namespace Tango.CodeGeneration { + /// <summary> + /// Represents a Java enumeration file. + /// </summary> + /// <seealso cref="Tango.CodeGeneration.CodeFile" /> public class EnumerationFileJava : CodeFile { + /// <summary> + /// Gets or sets the enum name. + /// </summary> public String Name { get; set; } + /// <summary> + /// Gets or sets the collection of enum fields. + /// </summary> public List<EnumerationField> Fields { get; set; } + /// <summary> + /// Initializes a new instance of the <see cref="EnumerationFileJava"/> class. + /// </summary> public EnumerationFileJava() { Fields = new List<EnumerationField>(); diff --git a/Software/Visual_Studio/Tango.CodeGeneration/Helper.cs b/Software/Visual_Studio/Tango.CodeGeneration/Helper.cs index 2e0e449f1..dff85a011 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/Helper.cs +++ b/Software/Visual_Studio/Tango.CodeGeneration/Helper.cs @@ -10,6 +10,9 @@ using System.Threading.Tasks; namespace Tango.CodeGeneration { + /// <summary> + /// Contains several code generation helper methods. + /// </summary> internal static class Helper { /// <summary> diff --git a/Software/Visual_Studio/Tango.CodeGeneration/ObservablesAdapterFile.cs b/Software/Visual_Studio/Tango.CodeGeneration/ObservablesAdapterFile.cs index 7b1e3d8fe..f62149757 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/ObservablesAdapterFile.cs +++ b/Software/Visual_Studio/Tango.CodeGeneration/ObservablesAdapterFile.cs @@ -6,6 +6,10 @@ using System.Threading.Tasks; namespace Tango.CodeGeneration { + /// <summary> + /// Represents the Tango DAL layer observables adapter code file. + /// </summary> + /// <seealso cref="Tango.CodeGeneration.Class" /> public class ObservablesAdapterFile : Class { diff --git a/Software/Visual_Studio/Tango.CodeGeneration/TangoDAOJavaFile.cs b/Software/Visual_Studio/Tango.CodeGeneration/TangoDAOJavaFile.cs index 5221365e4..566f13311 100644 --- a/Software/Visual_Studio/Tango.CodeGeneration/TangoDAOJavaFile.cs +++ b/Software/Visual_Studio/Tango.CodeGeneration/TangoDAOJavaFile.cs @@ -6,20 +6,42 @@ using System.Threading.Tasks; namespace Tango.CodeGeneration { + /// <summary> + /// Represents the Tango DAO Java code file. + /// </summary> + /// <seealso cref="Tango.CodeGeneration.CodeFile" /> public class TangoDAOJavaFile : CodeFile { + /// <summary> + /// Gets or sets the class name. + /// </summary> public String Name { get; set; } + /// <summary> + /// Gets or sets the entities. + /// </summary> public List<TangoDAOEntity> Entities { get; set; } + /// <summary> + /// Initializes a new instance of the <see cref="TangoDAOJavaFile"/> class. + /// </summary> public TangoDAOJavaFile() { Entities = new List<TangoDAOEntity>(); } + /// <summary> + /// Represents a Tango DAO Java entity. + /// </summary> public class TangoDAOEntity { + /// <summary> + /// Gets or sets the entity name. + /// </summary> public String Name { get; set; } + + /// <summary> + /// Gets or sets the name of the table. public String TableName { get; set; } } } diff --git a/Software/Visual_Studio/Tango.Core/Cryptography/ICryptographer.cs b/Software/Visual_Studio/Tango.Core/Cryptography/ICryptographer.cs index a5c9ea923..3148ea4da 100644 --- a/Software/Visual_Studio/Tango.Core/Cryptography/ICryptographer.cs +++ b/Software/Visual_Studio/Tango.Core/Cryptography/ICryptographer.cs @@ -6,11 +6,39 @@ using System.Threading.Tasks; namespace Tango.Core.Cryptography { + /// <summary> + /// Represents a string encryption and decryption engine. + /// </summary> public interface ICryptographer { + /// <summary> + /// Encrypts the specified text. + /// </summary> + /// <param name="text">The text.</param> + /// <returns></returns> String Encrypt(String text); + + /// <summary> + /// Decrypts the specified text. + /// </summary> + /// <param name="text">The text.</param> + /// <returns></returns> String Decrypt(String text); + + /// <summary> + /// Encrypts the specified text using the specified pass key. + /// </summary> + /// <param name="text">The text.</param> + /// <param name="key">The key.</param> + /// <returns></returns> String Encrypt(String text, String key); + + /// <summary> + /// Decrypts the specified text using the specified pass key. + /// </summary> + /// <param name="text">The text.</param> + /// <param name="key">The key.</param> + /// <returns></returns> String Decrypt(String text, String key); } } diff --git a/Software/Visual_Studio/Tango.Core/Cryptography/Rfc2898Cryptographer.cs b/Software/Visual_Studio/Tango.Core/Cryptography/Rfc2898Cryptographer.cs index 9d369d323..c7273d370 100644 --- a/Software/Visual_Studio/Tango.Core/Cryptography/Rfc2898Cryptographer.cs +++ b/Software/Visual_Studio/Tango.Core/Cryptography/Rfc2898Cryptographer.cs @@ -6,13 +6,28 @@ using SimpleValidator.Extensions; namespace Tango.Core.Cryptography { + /// <summary> + /// Represents an Rfc2898 <see cref="ICryptographer">Cryptographer</see>. + /// </summary> + /// <seealso cref="Tango.Core.Cryptography.ICryptographer" /> public class Rfc2898Cryptographer : ICryptographer { + /// <summary> + /// Decrypts the specified text. + /// </summary> + /// <param name="text">The text.</param> + /// <returns></returns> public string Decrypt(string text) { return Decrypt(text, Properties.Resources.EncryptionPassword); } + /// <summary> + /// Decrypts the specified text using the specified pass key. + /// </summary> + /// <param name="text">The text.</param> + /// <param name="key">The key.</param> + /// <returns></returns> public string Decrypt(string text, string key) { if (text.IsNullOrWhiteSpace()) return text; @@ -38,11 +53,22 @@ namespace Tango.Core.Cryptography return text; } + /// <summary> + /// Encrypts the specified text. + /// </summary> + /// <param name="text">The text.</param> + /// <returns></returns> public string Encrypt(string text) { return Encrypt(text, Properties.Resources.EncryptionPassword); } + /// <summary> + /// Encrypts the specified text using the specified pass key. + /// </summary> + /// <param name="text">The text.</param> + /// <param name="key">The key.</param> + /// <returns></returns> public string Encrypt(string text, string key) { if (text.IsNullOrWhiteSpace()) return text; 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 diff --git a/Software/Visual_Studio/Tango.Core/Helpers/AssemblyHelper.cs b/Software/Visual_Studio/Tango.Core/Helpers/AssemblyHelper.cs index 405020e66..d241a60f8 100644 --- a/Software/Visual_Studio/Tango.Core/Helpers/AssemblyHelper.cs +++ b/Software/Visual_Studio/Tango.Core/Helpers/AssemblyHelper.cs @@ -8,8 +8,15 @@ using System.Threading.Tasks; namespace Tango.Core.Helpers { + /// <summary> + /// Contains several assembly related helper methods. + /// </summary> public static class AssemblyHelper { + /// <summary> + /// Gets the current assembly folder path. + /// </summary> + /// <returns></returns> public static String GetCurrentAssemblyFolder() { string codeBase = Assembly.GetExecutingAssembly().CodeBase; diff --git a/Software/Visual_Studio/Tango.Core/Helpers/ColorHelper.cs b/Software/Visual_Studio/Tango.Core/Helpers/ColorHelper.cs index c88d5aead..c5ebc7474 100644 --- a/Software/Visual_Studio/Tango.Core/Helpers/ColorHelper.cs +++ b/Software/Visual_Studio/Tango.Core/Helpers/ColorHelper.cs @@ -13,7 +13,7 @@ namespace Tango.Core.Helpers public static class ColorHelper { /// <summary> - /// Converts a color to integer. + /// Converts the specified color to integer. /// </summary> /// <param name="color">The color.</param> /// <returns></returns> @@ -24,7 +24,7 @@ namespace Tango.Core.Helpers } /// <summary> - /// Converts an integer to color. + /// Converts the specified integer to color. /// </summary> /// <param name="integer">The integer.</param> /// <returns></returns> diff --git a/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs b/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs index 63487fe1b..9b6fe55e9 100644 --- a/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs +++ b/Software/Visual_Studio/Tango.Core/Helpers/PathHelper.cs @@ -7,6 +7,9 @@ using System.Threading.Tasks; namespace Tango.Core.Helpers { + /// <summary> + /// Contains several path helper methods. + /// </summary> public static class PathHelper { /// <summary> @@ -20,11 +23,20 @@ namespace Tango.Core.Helpers return tempDirectory; } + /// <summary> + /// Gets the application startup path. + /// </summary> + /// <returns></returns> public static String GetStartupPath() { return AppDomain.CurrentDomain.BaseDirectory; } + /// <summary> + /// Tries to delete the specified folder. + /// </summary> + /// <param name="path">The folder path.</param> + /// <returns></returns> public static bool TryDeleteFolder(String path) { try @@ -38,6 +50,11 @@ namespace Tango.Core.Helpers } } + /// <summary> + /// Tries to delete the specified file. + /// </summary> + /// <param name="path">The file path.</param> + /// <returns></returns> public static bool TryDeleteFile(String path) { try @@ -51,30 +68,38 @@ namespace Tango.Core.Helpers } } - public static void CopyDirectory(string sourceDirName, string destDirName, bool copySubDirs) + /// <summary> + /// Copies the specified directory source path to the specified destination. + /// </summary> + /// <param name="sourcePath">The source path.</param> + /// <param name="destinationPath">The destination path.</param> + /// <param name="copySubDirs">if set to <c>true</c> will copy sub directories.</param> + /// <exception cref="DirectoryNotFoundException">Source directory does not exist or could not be found: " + /// + sourcePath</exception> + public static void CopyDirectory(string sourcePath, string destinationPath, bool copySubDirs) { // Get the subdirectories for the specified directory. - DirectoryInfo dir = new DirectoryInfo(sourceDirName); + DirectoryInfo dir = new DirectoryInfo(sourcePath); if (!dir.Exists) { throw new DirectoryNotFoundException( "Source directory does not exist or could not be found: " - + sourceDirName); + + sourcePath); } DirectoryInfo[] dirs = dir.GetDirectories(); // If the destination directory doesn't exist, create it. - if (!Directory.Exists(destDirName)) + if (!Directory.Exists(destinationPath)) { - Directory.CreateDirectory(destDirName); + Directory.CreateDirectory(destinationPath); } // Get the files in the directory and copy them to the new location. FileInfo[] files = dir.GetFiles(); foreach (FileInfo file in files) { - string temppath = Path.Combine(destDirName, file.Name); + string temppath = Path.Combine(destinationPath, file.Name); file.CopyTo(temppath, false); } @@ -83,7 +108,7 @@ namespace Tango.Core.Helpers { foreach (DirectoryInfo subdir in dirs) { - string temppath = Path.Combine(destDirName, subdir.Name); + string temppath = Path.Combine(destinationPath, subdir.Name); CopyDirectory(subdir.FullName, temppath, copySubDirs); } } diff --git a/Software/Visual_Studio/Tango.Core/Helpers/ThreadsHelper.cs b/Software/Visual_Studio/Tango.Core/Helpers/ThreadsHelper.cs index bd934747d..79353e7cc 100644 --- a/Software/Visual_Studio/Tango.Core/Helpers/ThreadsHelper.cs +++ b/Software/Visual_Studio/Tango.Core/Helpers/ThreadsHelper.cs @@ -2,29 +2,71 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Threading; +using Tango.Logging; namespace Tango.Core.Helpers { + /// <summary> + /// Contains several UI threading helper methods. + /// </summary> public static class ThreadsHelper { - private static Dispatcher _dispatcher; - + private static Dispatcher _dispatcher; //Holds the current dispatcher. + + /// <summary> + /// Sets the current dispatcher. + /// </summary> + /// <param name="dispatcher">The dispatcher.</param> public static void SetDisptacher(Dispatcher dispatcher) { _dispatcher = dispatcher; } + /// <summary> + /// Invokes the UI thread. + /// </summary> + /// <param name="action">The action.</param> public static void InvokeUI(Action action) { + if (_dispatcher == null) + { + LogManager.Log(new NullReferenceException("The UI dispatcher was not set!")); + } + _dispatcher.BeginInvoke(action); } + /// <summary> + /// Invokes the UI thread while blocking the current thread. + /// </summary> + /// <param name="action">The action.</param> public static void InvokeUINow(Action action) { + if (_dispatcher == null) + { + LogManager.Log(new NullReferenceException("The UI dispatcher was not set!")); + } + _dispatcher.Invoke(action); } + + /// <summary> + /// Starts a new STA thread which will be running the specified action. + /// </summary> + /// <param name="action">The action.</param> + public static void StartStaThread(Action action) + { + Thread thread = new Thread(() => + { + action(); + }); + thread.SetApartmentState(ApartmentState.STA); + thread.IsBackground = true; + thread.Start(); + } } } diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index c560aa06f..3df22d497 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -85,7 +85,7 @@ <Compile Include="ExtensionMethods\IMessageExtensions.cs" /> <Compile Include="ExtensionMethods\IParameterizedExtensions.cs" /> <Compile Include="ExtensionMethods\ObjectExtensions.cs" /> - <Compile Include="ExtensionMethods\ReflectionExtensions.cs" /> + <Compile Include="ExtensionMethods\TypeExtensions.cs" /> <Compile Include="ExtensionMethods\IServiceLocatorExtensions.cs" /> <Compile Include="ExtensionMethods\StringExtensions.cs" /> <Compile Include="Helpers\AssemblyHelper.cs" /> @@ -103,12 +103,15 @@ <DesignTime>True</DesignTime> <DependentUpon>Resources.resx</DependentUpon> </Compile> - <Compile Include="Threading\StaThreadHelper.cs" /> </ItemGroup> <ItemGroup> <None Include="packages.config" /> </ItemGroup> <ItemGroup> + <ProjectReference Include="..\Tango.Logging\Tango.Logging.csproj"> + <Project>{bc932dbd-7cdb-488c-99e4-f02cf441f55e}</Project> + <Name>Tango.Logging</Name> + </ProjectReference> <ProjectReference Include="..\Tango.Serialization\Tango.Serialization.csproj"> <Project>{22f87980-e990-4686-be81-be63d562c4d5}</Project> <Name>Tango.Serialization</Name> diff --git a/Software/Visual_Studio/Tango.Core/Threading/StaThreadHelper.cs b/Software/Visual_Studio/Tango.Core/Threading/StaThreadHelper.cs deleted file mode 100644 index 5c1f5b93c..000000000 --- a/Software/Visual_Studio/Tango.Core/Threading/StaThreadHelper.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace Tango.Core.Threading -{ - public static class StaThreadHelper - { - public static void StartStaThread(Action action) - { - Thread thread = new Thread(() => - { - action(); - }); - thread.SetApartmentState(ApartmentState.STA); - thread.IsBackground = true; - thread.Start(); - } - } -} diff --git a/Software/Visual_Studio/Tango.Logging/ExtensionMethods/StringExtensions.cs b/Software/Visual_Studio/Tango.Logging/ExtensionMethods/StringExtensions.cs new file mode 100644 index 000000000..f969adeda --- /dev/null +++ b/Software/Visual_Studio/Tango.Logging/ExtensionMethods/StringExtensions.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace Tango.Logging +{ + /// <summary> + /// Contains <see cref="String"/> extension methods. + /// </summary> + public static class StringExtensions + { + /// <summary> + /// Converts the object to string. If the object is null, will return null. + /// </summary> + /// <param name="obj">The object.</param> + /// <returns></returns> + public static String ToStringSafe(this object obj) + { + return obj != null ? obj.ToString() : String.Empty; + } + } +} diff --git a/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj b/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj index 56728f097..93d0cd4ea 100644 --- a/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj +++ b/Software/Visual_Studio/Tango.Logging/Tango.Logging.csproj @@ -34,7 +34,6 @@ <Reference Include="PresentationCore" /> <Reference Include="PresentationFramework" /> <Reference Include="System" /> - <Reference Include="System.Core" /> <Reference Include="System.Windows" /> <Reference Include="System.Xaml" /> <Reference Include="System.Xml.Linq" /> @@ -55,6 +54,7 @@ <DependentUpon>ConsoleWindow.xaml</DependentUpon> </Compile> <Compile Include="ExceptionLogItem.cs" /> + <Compile Include="ExtensionMethods\StringExtensions.cs" /> <Compile Include="FileLogger.cs" /> <Compile Include="GlobalExceptionTrapper.cs" /> <Compile Include="IGlobalExceptionTrapper.cs" /> @@ -66,12 +66,6 @@ <Compile Include="VSOutputLogger.cs" /> </ItemGroup> <ItemGroup> - <ProjectReference Include="..\Tango.Core\Tango.Core.csproj"> - <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> - <Name>Tango.Core</Name> - </ProjectReference> - </ItemGroup> - <ItemGroup> <Page Include="ConsoleWindow.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> diff --git a/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db b/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db Binary files differindex d676fc8c3..12c88039d 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db +++ b/Software/Visual_Studio/Web/Tango.MachineService/App_Data/Tango.db |
