From 6d29a46b635a8f0c6cbc69fc883889fef9c4e623 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Tue, 15 Oct 2013 13:13:09 +0200 Subject: [PATCH] refatcor utilityplc --- .../Utility/AbstractBackgroundTasks.cs | 20 ++-- .../Utility/AbstractFile.cs | 44 ++++---- .../Utility/AbstractHttpRequest.cs | 35 +++--- .../Utility/DefaultStringManager.cs | 105 ++++++++---------- .../CampusAppWPortalLib8/Utility/Logger.cs | 30 +++-- .../Utility/XmlManager.cs | 48 ++++---- 6 files changed, 130 insertions(+), 152 deletions(-) diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs index 434104b4..a3bdca7f 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractBackgroundTasks.cs @@ -1,21 +1,19 @@ //----------------------------------------------------------------------- // -// Company copyright tag. +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. // -// stubbfel -// 18.09.2013 -//---------------------------------------------------------------------- - +// Stubbfel +// 15.10.2013 +// Implements the abstract background tasks class +//----------------------------------------------------------------------- namespace CampusAppWPortalLib8.Utility { - /// - /// abstract class for BackGroundTask - /// + /// abstract class for BackGroundTask. + /// Stubbfel, 15.10.2013. public abstract class AbstractBackgroundTasks { - /// - /// Gets or sets the name of the last running task - /// + /// Gets or sets the name of the last running task. + /// The name of the last added task. protected static string LastAddedTaskName { get; set; } } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractFile.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractFile.cs index 0724f50e..311da049 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractFile.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractFile.cs @@ -1,22 +1,21 @@ -//----------------------------------------------------------------------------- +//----------------------------------------------------------------------- // -// Company copyright tag. +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. // // fiedlchr -// 03.05.2013 -//----------------------------------------------------------------------------- +// 15.10.2013 +// Implements the abstract file class +//----------------------------------------------------------------------- namespace CampusAppWPortalLib8.Utility { - /// - /// File class. - /// + /// File class. + /// fiedlchr, 15.10.2013. public abstract class AbstractFile { #region Events - /// - /// Delegation of the write callback function prototype. - /// + /// Delegation of the write callback function prototype. + /// fiedlchr, 15.10.2013. public delegate void WriteCallbackFunc(); #endregion @@ -25,28 +24,25 @@ namespace CampusAppWPortalLib8.Utility #region public - /// Read data from file to a string. - /// Stubbfel, 03.09.2013. - /// data string. + /// Read data from file to a string. + /// fiedlchr, 03.09.2013. + /// data string. public abstract byte[] ReadFile(); - /// Write bytes to the file. - /// Stubbfel, 03.09.2013. - /// data byte array. - /// callback function, called after writing is done. - /// callback function, called when writing failed. + /// Write bytes to the file. + /// fiedlchr, 03.09.2013. + /// data byte array. + /// callback function, called after writing is done. + /// callback function, called when writing failed. public abstract void WriteFile(byte[] data, WriteCallbackFunc onSavedCallback, WriteCallbackFunc onFailedCallback); - /// - /// Check if a file is existing. - /// - /// true, if file exists, otherwise false + /// Check if a file is existing. + /// fiedlchr, 15.10.2013. + /// true, if file exists, otherwise false. public abstract bool Exist(); - #endregion - #endregion } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs index e52f9b50..8645f09d 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/AbstractHttpRequest.cs @@ -1,36 +1,32 @@ //----------------------------------------------------------------------- // -// Company copyright tag. +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. // -// stubbfel -// 10.06.2013 -//---------------------------------------------------------------------- +// Stubbfel +// 15.10.2013 +// Implements the abstract HTTP request class +//----------------------------------------------------------------------- namespace CampusAppWPortalLib8.Utility -{ +{ using System; using System.Collections.Generic; - using System.Net; using CampusAppWPortalLib8.Model.Utility; - /// - /// abstract Class provides some methods and member for HttpRequest - /// + /// abstract Class provides some methods and member for HttpRequest. + /// Stubbfel, 15.10.2013. public abstract class AbstractHttpRequest { #region Member - /// - /// BaseAddress of the webClient - /// + /// BaseAddress of the webClient. private string baseAddress; #endregion #region property - /// - /// Gets or sets BaseAddress of the webClient - /// + /// Gets or sets BaseAddress of the webClient. + /// The base address. protected string BaseAddress { get @@ -50,11 +46,10 @@ namespace CampusAppWPortalLib8.Utility #region Methods - /// - /// Method create the Url for the http-get-method - /// - /// list of parameters - /// absolute API-Url include GetParameter + /// Method create the Url for the http-get-method. + /// Stubbfel, 15.10.2013. + /// list of parameters. + /// absolute API-Url include GetParameter. public Uri CreateGetUrl(List parameters) { string paramterStr = string.Empty; diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs index 8f931d3a..37a2d796 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/DefaultStringManager.cs @@ -1,68 +1,64 @@ //----------------------------------------------------------------------- // -// Company copyright tag. +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. // -// stubbfel -// 06.06.2013 -//---------------------------------------------------------------------- +// Stubbfel +// 15.10.2013 +// Implements the default string manager class +//----------------------------------------------------------------------- namespace CampusAppWPortalLib8.Utility { using System; using System.Text.RegularExpressions; using CampusAppWPortalLib8.Resources; - /// - /// Class provides some special StringMethods - /// + /// Class provides some special StringMethods. + /// Stubbfel, 15.10.2013. public class DefaultStringManager { #region Members - /// - /// Patter for Html-Tags - /// + /// Patter for Html-Tags. private static readonly string HtmlTagPattern = "<.*?>"; - /// The mail valid regular expression. + /// The mail valid regular expression. private static readonly string EMailValidRegex = @"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$"; #endregion #region Methods - /// - /// Method removes Html-Tag of a String - /// - /// String with Html-Tags - /// String without Html-Tags + /// Method removes Html-Tag of a String. + /// Stubbfel, 15.10.2013. + /// String with Html-Tags. + /// String without Html-Tags. public static string StripHTML(string inputString) { return Regex.Replace(inputString, DefaultStringManager.HtmlTagPattern, string.Empty); } - /// - /// Method add an Newline to a string - /// - /// input string - /// input string + newline + /// Method add an Newline to a string. + /// Stubbfel, 15.10.2013. + /// input string. + /// input string + newline. public static string AddNewLine(string str) { return str.ToString() + "\n"; } - /// Method remove(TrimEND!) an Newline to a string. - /// Stubbfel, 12.09.2013. - /// input string. - /// input string - newline. + /// Method remove(TrimEND!) an Newline to a string. + /// Stubbfel, 12.09.2013. + /// input string. + /// input string - newline. public static string RemoveNewLine(string str) { return str.TrimEnd('\n'); } - /// Query if 'strIn' is valid email. - /// Stubbfel, 04.09.2013. - /// The in. - /// true if valid email, false if not. + /// Query if 'strIn' is valid email. + /// Stubbfel, 04.09.2013. + /// The in. + /// true if valid email, false if not. public static bool IsValidEmail(string strIn) { // Return true if strIn is in valid e-mail format. @@ -79,10 +75,10 @@ namespace CampusAppWPortalLib8.Utility } } - /// Creates uni telefon number. - /// Stubbfel, 04.09.2013. - /// The input. - /// The new uni telefon number. + /// Creates uni telefon number. + /// Stubbfel, 04.09.2013. + /// The input. + /// The new uni telefon number. public static string CreateUniTelefonNumber(string input) { string result = null; @@ -101,13 +97,14 @@ namespace CampusAppWPortalLib8.Utility return result; } - /// - /// Method create from a long string a short string - /// - /// the long input String - /// max length of the short string - /// (optional) suffix which added to the short string, when long string has to be cut - /// the shorted string + /// Method create from a long string a short string. + /// Stubbfel, 15.10.2013. + /// the long input String. + /// max length of the short string. + /// + /// (optional) suffix which added to the short string, when long string has to be cut. + /// + /// the shorted string. public static string ToShortString(string longStr, int maxLenght, string suffix = "") { string shortStr = longStr; @@ -124,17 +121,15 @@ namespace CampusAppWPortalLib8.Utility return shortStr; } - /// - /// Method gets the placeId of the result string for an qrCode string - /// - /// input qrCode string - /// the id if it was found it in the string otherwise null + /// Method gets the placeId of the result string for an qrCode string. + /// Stubbfel, 15.10.2013. + /// input qrCode string. + /// the id if it was found it in the string otherwise null. public static string FilterPlaceIdinQRResultString(string qrcodeResult) { if (qrcodeResult == null) { return null; - } string[] lines = qrcodeResult.Split('\n'); @@ -152,11 +147,10 @@ namespace CampusAppWPortalLib8.Utility return null; } - /// - /// Method check if the string contains only digit - /// - /// input string - /// true if the string contains only digit, otherwise false + /// Method check if the string contains only digit. + /// Stubbfel, 15.10.2013. + /// input string. + /// true if the string contains only digit, otherwise false. public static bool IsDigitsOnly(string str) { if (str == null || str.Length < 1) @@ -175,11 +169,10 @@ namespace CampusAppWPortalLib8.Utility return true; } - /// - /// Method gets the placeId of the result string for an nfc string - /// - /// input nfc string - /// the id if it was found it in the string otherwise null + /// Method gets the placeId of the result string for an nfc string. + /// Stubbfel, 15.10.2013. + /// input nfc string. + /// the id if it was found it in the string otherwise null. public static string FilterPlaceIdinNFCResultString(string nfcResult) { string nfcResultTrim = nfcResult.Trim('{'); diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs index f12400bc..b70453bf 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/Logger.cs @@ -1,32 +1,30 @@ -//-------------------------------------------------------------------- +//----------------------------------------------------------------------- // -// Company copyright tag. +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. // -// stubbfel -// 03.05.2013 -//---------------------------------------------------------------------- +// Stubbfel +// 15.10.2013 +// Implements the logger class +//----------------------------------------------------------------------- namespace CampusAppWPortalLib8.Utility { using System; - /// - /// This Class creates logs for the app - /// + /// This Class creates logs for the app. + /// Stubbfel, 15.10.2013. public class Logger { - /// - /// Method log a Exception - /// - /// exception which has to log + /// Method log a Exception. + /// Stubbfel, 15.10.2013. + /// exception which has to log. public static void LogException(Exception exception) { // Console.WriteLine(exception); } - /// - /// Log a message. - /// - /// to be logged message + /// Log a message. + /// Stubbfel, 15.10.2013. + /// to be logged message. public static void LogMsg(string msg) { // Console.WriteLine(msg); diff --git a/CampusAppWP8/CampusAppWPortalLib8/Utility/XmlManager.cs b/CampusAppWP8/CampusAppWPortalLib8/Utility/XmlManager.cs index 95a622de..60e67935 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Utility/XmlManager.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Utility/XmlManager.cs @@ -1,28 +1,27 @@ //----------------------------------------------------------------------- // -// Company copyright tag. +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. // -// stubbfel -// 18.06.2013 -//---------------------------------------------------------------------- +// Stubbfel +// 15.10.2013 +// Implements the XML manager class +//----------------------------------------------------------------------- namespace CampusAppWPortalLib8.Utility { using System.IO; using System.Xml.Linq; using System.Xml.Serialization; - /// - /// Class provides some Xml-methods - /// + /// Class provides some Xml-methods. + /// Stubbfel, 15.10.2013. public class XmlManager { - /// - /// Method deserialization a string to a Model - /// - /// the model - /// the XmlString - /// name of the RootTag - /// return the deserialization of the model + /// Method deserialization a string to a Model. + /// Stubbfel, 15.10.2013. + /// the model. + /// the XmlString. + /// name of the RootTag. + /// return the deserialization of the model. public static T DeserializationToModel(string xmlString, string validRootName) { XmlSerializer serializer = new XmlSerializer(typeof(T)); @@ -38,11 +37,11 @@ namespace CampusAppWPortalLib8.Utility return model; } - /// Deserialization a xml file to a model. - /// Stubbfel, 20.08.2013. - /// Generic type parameter. - /// Path to the a XmlFile. - /// model of the XmlFile. + /// Deserialization a xml file to a model. + /// Stubbfel, 20.08.2013. + /// Generic type parameter. + /// Path to the a XmlFile. + /// model of the XmlFile. public static T DeserializationFileToModel(string xmlFilePath) { XmlSerializer serializer = new XmlSerializer(typeof(T)); @@ -51,12 +50,11 @@ namespace CampusAppWPortalLib8.Utility return model; } - /// - /// Method serializes a model to a string. - /// - /// type of the model - /// model object - /// serialized string + /// Method serializes a model to a string. + /// Stubbfel, 15.10.2013. + /// type of the model. + /// model object. + /// serialized string. public static string SerializationToString(T model) { string retValue = string.Empty;