├── .cr └── user │ └── Editor │ └── Painting │ └── Code Metrics.xml ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .vssbe ├── LICENSE ├── README.md ├── SandCastle ├── Help │ └── Working │ │ ├── GenerateRefInfo.proj │ │ ├── MRefBuilder.config │ │ ├── PresentationStyleBuilderContent.xml │ │ ├── SharedBuilderContent.xml │ │ ├── StopWordList.txt │ │ ├── dotNetTips.Utility.Portable.Windows.xml │ │ ├── dotNetTips.Utility.xml │ │ └── reflection.org ├── Icons │ ├── dotNetTips-350-T.png │ └── dotNetTips-Logo-Header.jpg ├── Shortcut to SandCastle.lnk ├── dotNetTips.Utility.4.0.shfbproj └── dotNetTips.Utility.4.0.shfbproj_davidmccarter ├── buildspec.yaml ├── dotNetTips.Utility.EntityFramework ├── Data │ ├── DataContext.cs │ ├── DataEntity.cs │ └── IDataEntity.cs ├── Extensions │ └── EntityFrameworkExtensions.cs └── dotNetTips.Utility.EntityFramework.csproj ├── dotNetTips.Utility.Portable.Tests ├── DateTimeExtensionsTest.Intersects.g.cs ├── DateTimeExtensionsTest.ToFriendlyDateString.g.cs ├── DateTimeExtensionsTest.Tomorrow.g.cs ├── DateTimeExtensionsTest.cs ├── EncapsulationTest.TryValidateParam.g.cs ├── EncapsulationTest.cs ├── ExceptionExtensionTest.GetAllMessages.g.cs ├── ExceptionExtensionTest.cs ├── GlobalSuppressions.cs ├── Properties │ ├── AssemblyInfo.cs │ └── PexAssemblyInfo.cs ├── TypeHelperTest.Create.g.cs ├── TypeHelperTest.cs └── dotNetTips.Utility.Portable.Tests.csproj ├── dotNetTips.Utility.Portable.Windows ├── Collections │ └── SortedQueue.vb ├── Constants.vb ├── Counter.vb ├── CounterChangedEventArgs.vb ├── Data │ ├── CountriesCollection.vb │ ├── Country.vb │ ├── DataHelper.vb │ ├── DataLists.vb │ ├── State.vb │ └── UsStatesCollection.vb ├── Extensions │ ├── CollectionExtensions.vb │ ├── DecimalExtensions.vb │ ├── EnumerableExtensions.vb │ ├── MathExtensions.vb │ ├── NullableExtensions.vb │ ├── ObjectExtensions.vb │ ├── StringBuilderExtensions.vb │ ├── StringExtensions.vb │ ├── ValidationHelper.vb │ └── XElementExtensions.vb ├── General.vb ├── GlobalSuppressions.vb ├── Math │ └── MathHelper.vb ├── My Project │ ├── AssemblyInfo.vb │ ├── Resources.Designer.vb │ └── Resources.resx ├── Security │ └── SecurityHelper.vb ├── StringHelper.vb ├── ValidationHelper.vb ├── dotNetTips.Utility.Portable.Windows.vbproj ├── project.json └── project.lock.json ├── dotNetTips.Utility.Portable ├── ArgumentInvalidException.cs ├── ArgumentReadOnlyException.cs ├── ControlChars.cs ├── Data │ ├── DataContext.cs │ ├── DataEntity.cs │ └── IDataEntity.cs ├── DateFormat.cs ├── DateInterval.cs ├── Diagnostics │ └── PerformanceStopwatch.cs ├── DueDate.cs ├── Extensions │ ├── CollectionExtensions.cs │ ├── DateTimeExtensions.cs │ ├── ExceptionExtension.cs │ ├── HttpExtensions.cs │ ├── MathExtensions.cs │ ├── ObjectExtensions.cs │ ├── StringExtensions.cs │ └── TypeExtensions.cs ├── FileAttributes.cs ├── FirstDayOfWeek.cs ├── FirstWeekOfYear.cs ├── GlobalSuppressions.cs ├── ICloneable.cs ├── ISingleton.cs ├── IValid.cs ├── ImageExtensions.cs ├── OOP │ ├── Encapsulation.cs │ └── Validation.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── TriState.cs ├── TypeHelper.cs ├── Validation │ ├── IValid.cs │ └── IsValidResult.cs ├── dotNetTips.Utility.Portable.XML ├── dotNetTips.Utility.Portable.csproj ├── dotNetTips.Utility.Portable.csproj.CodeItRight.xml ├── package.nuspec ├── project.json └── project.lock.json ├── dotNetTips.Utility.Windows.Logger ├── CallingMethod.vb ├── Category.vb ├── EmailTraceListener.vb ├── EventLogTraceListener.vb ├── ExceptionFormatter.vb ├── GlobalSuppressions.vb ├── InfoItem.vb ├── InfoItemCollection.vb ├── InvalidEnumTypeException.vb ├── Listeners │ └── StackifyTraceListener.vb ├── LogEntry.vb ├── LogEntryFormatter.vb ├── LogItem.vb ├── LogManagement.vb ├── LogWriter.vb ├── LoggableException.vb ├── LoggingHelper.vb ├── LoggingKeys.vb ├── LoggingTraceListener.vb ├── My Project │ ├── Application.Designer.vb │ ├── Application.myapp │ ├── AssemblyInfo.vb │ ├── Resources.Designer.vb │ ├── Resources.resx │ ├── Settings.Designer.vb │ └── Settings.settings ├── StackifyTraceListener.vb ├── TcpTraceListener.vb ├── WebServiceTraceListener.vb ├── XmlTraceListener.vb ├── app.config ├── dotNetTips.Utility.Windows.Logger.vbproj └── packages.config ├── dotNetTips.Utility ├── ApplicationHelper.vb ├── AssemblyInfo.vb ├── ComputerHelper.vb ├── ComputerInfo.vb ├── ComputerMemory.vb ├── Config.vb ├── CriticalException.vb ├── Data │ └── DataContext.vb ├── DeviceInformation.vb ├── DirectoryInformation.vb ├── DirectoryServices │ ├── ActiveDirectoryHelper.vb │ └── UserInfo.vb ├── EnumHelper.vb ├── EnumValue.vb ├── Extensions │ ├── CollectionExtensions.vb │ ├── ColorExtensions.vb │ ├── DataContextExtensions.vb │ ├── DataReaderExtensions.vb │ ├── DataServicesExtensions.vb │ ├── DataTableExtensions.vb │ ├── DirectoryInfoExtensions.vb │ ├── EntityExtensions.vb │ ├── ImageExtensions.vb │ ├── ObjectExtensions.vb │ ├── ResponseExtensions.vb │ ├── StringExtensions.vb │ ├── ThreadExtensions.vb │ └── ValidationHelper.vb ├── FileInformation.vb ├── General.vb ├── GlobalSuppressions.vb ├── HelpersClassDiagram.cd ├── IO │ ├── CompressionAction.vb │ ├── Deflater.vb │ ├── DirectoryHelper.vb │ ├── DriveHelper.vb │ ├── FileHelper.vb │ ├── PathHelper.vb │ ├── Processor.vb │ ├── ProcessorEventArgs.vb │ ├── ProgressEventArgs.vb │ ├── ProgressState.vb │ └── TempFileManager.vb ├── InstalledProduct.vb ├── InvalidEnumTypeException.vb ├── My Project │ ├── Resources.Designer.vb │ ├── Resources.resx │ ├── Settings.Designer.vb │ └── Settings.settings ├── MyPowerExtension.vb ├── Net │ ├── EmailAddress.vb │ ├── EmailAddressType.vb │ ├── Mailer.vb │ └── NetworkHelper.vb ├── Resources │ ├── CommunityChampionsSmall.jpg │ ├── Countries.xml │ ├── DefaultGraphics.Designer.vb │ ├── DefaultGraphics.resx │ ├── Image1.bmp │ ├── Images │ │ └── Action_Apply.png │ ├── PopupNotifier.png │ ├── States.xml │ └── grip.png ├── Security │ ├── HashType.vb │ └── SecurityHelper.vb ├── ServerUptimeInformation.vb ├── ServiceAction.vb ├── ServiceActionRequest.vb ├── ServiceActionResult.vb ├── Services.vb ├── ServicesHelper.vb ├── Speech │ └── Synthesis.vb ├── StringHelper.vb ├── Threading │ ├── AbortableThreadPool.vb │ ├── ThreadHelper.vb │ ├── WorkItem.vb │ ├── WorkItemEventArgs.vb │ └── WorkItemStatus.vb ├── UI │ ├── Web │ │ └── TextBox.vb │ └── Windows │ │ ├── ComboBoxListType.vb │ │ ├── ControlsHelper.vb │ │ ├── FormHelper.vb │ │ └── TextBoxValidation.vb ├── UnsafeNativeMethods.vb ├── ValidationHelper.vb ├── Web │ ├── GeoLocationInfo.vb │ ├── IIsServerHelper.vb │ ├── UrlBuilder.vb │ ├── WebHelper.vb │ └── WebServiceAction.vb ├── Xml │ └── XmlHelper.vb ├── app.config ├── comments.xml ├── dotNetTips.Utility.vbproj ├── dotNetTips.Utility.vbproj.CodeItRight.xml ├── dotNetTips.Utility.vbproj.GhostDoc.xml ├── package.nuspec └── packages.config ├── dotNetTips.crdata ├── dotNetTips.sln ├── dotNetTips.sln.CodeItRight.xml └── dotNetTips.sln.GhostDoc.xml /.cr/user/Editor/Painting/Code Metrics.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CyclomaticComplexity 5 | 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | # Don't use tabs for indentation. 5 | [*] 6 | indent_style = space 7 | end_of_line = crlf 8 | 9 | [*.xml] 10 | indent_style = space 11 | 12 | [*.cs] 13 | # Prefer "var" everywhere 14 | csharp_style_var_for_built_in_types = true : suggestion 15 | csharp_style_var_when_type_is_apparent = true : warning 16 | csharp_style_var_elsewhere = true : suggestion 17 | csharp_style_inlined_variable_declaration = true : suggestion 18 | 19 | # Prefer method-like constructs to have a block body 20 | csharp_style_expression_bodied_methods = when_on_single_line : suggestion 21 | csharp_style_expression_bodied_constructors = when_on_single_line : suggestion 22 | csharp_style_expression_bodied_operators = when_on_single_line : suggestion 23 | 24 | # Prefer property-like constructs to have an expression-body 25 | csharp_style_expression_bodied_properties = true : none 26 | csharp_style_expression_bodied_indexers = true : none 27 | csharp_style_expression_bodied_accessors = true : none 28 | 29 | # Suggest more modern language features when available 30 | csharp_style_pattern_matching_over_is_with_cast_check = true : suggestion 31 | csharp_style_pattern_matching_over_as_with_null_check = true : suggestion 32 | csharp_style_inlined_variable_declaration = true : suggestion 33 | csharp_style_throw_expression = true : suggestion 34 | csharp_style_conditional_delegate_call = true : suggestion 35 | 36 | # Newline settings 37 | csharp_new_line_before_open_brace = all 38 | csharp_new_line_before_else = true 39 | csharp_new_line_before_catch = true 40 | csharp_new_line_before_finally = true 41 | csharp_new_line_before_members_in_object_initializers = true 42 | csharp_new_line_before_members_in_anonymous_types = true 43 | 44 | # Dotnet code style settings: 45 | [*.{cs, vb}] 46 | # Sort using and Import directives with System.* appearing first 47 | dotnet_sort_system_directives_first = true 48 | # Avoid "this." and "Me." if not necessary 49 | dotnet_style_qualification_for_field = true : warning 50 | dotnet_style_qualification_for_property = true : warning 51 | dotnet_style_qualification_for_method = true : warning 52 | dotnet_style_qualification_for_event = true : warning 53 | 54 | # Use language keywords instead of framework type names for type references 55 | dotnet_style_predefined_type_for_locals_parameters_members = true : suggestion 56 | dotnet_style_predefined_type_for_member_access = true : suggestion 57 | 58 | # Suggest more modern language features when available 59 | dotnet_style_object_initializer = true : suggestion 60 | dotnet_style_collection_initializer = true : suggestion 61 | dotnet_style_coalesce_expression = true : suggestion 62 | dotnet_style_null_propagation = true : suggestion 63 | dotnet_style_explicit_tuple_names = true : suggestion 64 | 65 | 66 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 David McCarter 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dotNetTips.Utility 2 | Common .NET code I’ve been writing since it was released that features C#, VB.NET, Portable Libraries, Logging, .NET Core. Please submit an issue on this site if you have any issues, suggestions or code you would like to contibute. 3 | 4 | For more info and examples go to: http://dotnettips.wordpress.com/category/dotnettips-utility/ 5 | 6 | Here are some of the classes and methods I use all the time: 7 | 1. TryDispose: Properly disposes of any object 8 | 2. DisposeFields: Disposes of ANY disposible field in an object 9 | 3. InitializeFields: Initializes any field in a type. 10 | 11 | David McCarter 12 | Microsoft MVP 13 | 14 | # Version 2018.1.15.0 15 | Added new collection types: ConcurrentHashSet, DistinctConcurrentBag. Added disposing of dispsable items in a collection to DisposeFields. 16 | -------------------------------------------------------------------------------- /SandCastle/Help/Working/GenerateRefInfo.proj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | .NETFramework 9 | v4.5 10 | false 11 | 12 | 13 | C:\Program Files (x86)\Sandcastle\ 14 | D:\Development\dotNetTips\dotNetTips.Utility\4.5.1\dotNetTips Utility 4.5.1\SandCastle\Help\Working\ 15 | 16 | 17 | 18 | 19 | 20 | ..\OutputBin\ 21 | 22 | 23 | 24 | 25 | 26 | 27 | ResolveReferences; 28 | BeforeGenerateRefInfo; 29 | GenerateRefInfo; 30 | AfterGenerateRefInfo 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 45 | 46 | 47 | 48 | 49 | 50 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /SandCastle/Help/Working/PresentationStyleBuilderContent.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 6 | 7 | 8 | Copytright 2014 dotNetTips.com - David McCarter (http://dotNetTips.com) 9 | http://dotNetTips.com 10 | Copytright 2014 dotNetTips.com - David McCarter 11 | 12 | dotNetTips.com 13 | David McCarter - Microsoft MVP 14 | 15 | dotnetdave@live.com 16 | dotNetTips.Utility 17 | {0} 18 | Send Feedback 19 | Feedback 20 | on this topic. 21 | on this topic to Feedback. 22 | Your feedback is used to improve the documentation and the product. Your e-mail address will not be used for any other purpose and is disposed of after the issue you report is resolved. While working to resolve the issue that you report, you may be contacted via e-mail to get further details or clarification on the feedback you sent. After the issue you report has been addressed, you may receive an e-mail to let you know that your feedback has been addressed. 23 | 24 | 25 | -------------------------------------------------------------------------------- /SandCastle/Help/Working/SharedBuilderContent.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 5 | 6 | 7 | Namespaces 8 | Namespaces 9 | dotNetTips.Utility 10 | dotNetTips.Utility 11 | 12 | 13 | en-us 14 | 15 |

[This is preliminary documentation and is subject to change.]

16 | 17 |

Send comments on this topic to 18 | Feedback 19 | 25 | 26 | 28 |

Copytright 2014 dotNetTips.com - David McCarter 29 | 30 | -------------------------------------------------------------------------------- /SandCastle/Help/Working/StopWordList.txt: -------------------------------------------------------------------------------- 1 | a 2 | about 3 | above 4 | across 5 | after 6 | afterwards 7 | again 8 | against 9 | all 10 | almost 11 | alone 12 | along 13 | already 14 | also 15 | although 16 | always 17 | am 18 | among 19 | amongst 20 | amount 21 | an 22 | and 23 | another 24 | any 25 | anyone 26 | anything 27 | anyway 28 | anywhere 29 | are 30 | around 31 | as 32 | at 33 | back 34 | be 35 | became 36 | because 37 | become 38 | becomes 39 | becoming 40 | been 41 | before 42 | beforehand 43 | behind 44 | being 45 | below 46 | beside 47 | besides 48 | between 49 | beyond 50 | both 51 | bottom 52 | but 53 | by 54 | can 55 | cannot 56 | come 57 | con 58 | could 59 | dec 60 | did 61 | do 62 | does 63 | doing 64 | done 65 | down 66 | due 67 | during 68 | each 69 | early 70 | either 71 | else 72 | elsewhere 73 | enough 74 | etc 75 | etcetera 76 | even 77 | ever 78 | every 79 | everyone 80 | everything 81 | everywhere 82 | except 83 | far 84 | few 85 | fill 86 | find 87 | fire 88 | for 89 | former 90 | formerly 91 | found 92 | from 93 | front 94 | full 95 | further 96 | get 97 | give 98 | had 99 | has 100 | have 101 | he 102 | hence 103 | her 104 | here 105 | hereafter 106 | hereby 107 | herein 108 | hereupon 109 | hers 110 | herself 111 | him 112 | himself 113 | his 114 | how 115 | however 116 | i 117 | if 118 | in 119 | inc 120 | indeed 121 | interest 122 | into 123 | is 124 | it 125 | its 126 | itself 127 | keep 128 | last 129 | late 130 | later 131 | latter 132 | latterly 133 | least 134 | less 135 | made 136 | many 137 | may 138 | me 139 | meanwhile 140 | med 141 | might 142 | mine 143 | more 144 | moreover 145 | most 146 | mostly 147 | move 148 | much 149 | must 150 | myself 151 | name 152 | namely 153 | near 154 | neither 155 | never 156 | nevertheless 157 | next 158 | no 159 | nobody 160 | non 161 | none 162 | noone 163 | nor 164 | not 165 | note 166 | nothing 167 | now 168 | nowhere 169 | of 170 | off 171 | often 172 | on 173 | once 174 | only 175 | onto 176 | or 177 | other 178 | others 179 | otherwise 180 | our 181 | ours 182 | ourselves 183 | out 184 | over 185 | own 186 | per 187 | perhaps 188 | please 189 | pre 190 | pro 191 | put 192 | raise 193 | rather 194 | run 195 | same 196 | saw 197 | see 198 | seem 199 | seemed 200 | seeming 201 | seems 202 | seen 203 | several 204 | she 205 | should 206 | show 207 | side 208 | since 209 | sincere 210 | so 211 | some 212 | somehow 213 | someone 214 | something 215 | sometime 216 | sometimes 217 | somewhere 218 | still 219 | such 220 | take 221 | tha 222 | than 223 | that 224 | the 225 | their 226 | them 227 | themselves 228 | then 229 | thence 230 | there 231 | thereafter 232 | thereby 233 | therefore 234 | therein 235 | thereupon 236 | these 237 | they 238 | thick 239 | thin 240 | this 241 | tho 242 | those 243 | though 244 | through 245 | throughout 246 | thru 247 | thus 248 | thy 249 | tip 250 | to 251 | together 252 | too 253 | toward 254 | towards 255 | under 256 | until 257 | up 258 | upon 259 | us 260 | use 261 | very 262 | via 263 | was 264 | we 265 | well 266 | were 267 | what 268 | whatever 269 | when 270 | whence 271 | whenever 272 | where 273 | whereafter 274 | whereas 275 | whereby 276 | wherein 277 | whereupon 278 | wherever 279 | whether 280 | which 281 | while 282 | whither 283 | who 284 | whoever 285 | whole 286 | whom 287 | whose 288 | why 289 | will 290 | with 291 | within 292 | without 293 | would 294 | yet 295 | you 296 | your 297 | yours 298 | yourself 299 | yourselves 300 | -------------------------------------------------------------------------------- /SandCastle/Help/Working/reflection.org: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/SandCastle/Help/Working/reflection.org -------------------------------------------------------------------------------- /SandCastle/Icons/dotNetTips-350-T.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/SandCastle/Icons/dotNetTips-350-T.png -------------------------------------------------------------------------------- /SandCastle/Icons/dotNetTips-Logo-Header.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/SandCastle/Icons/dotNetTips-Logo-Header.jpg -------------------------------------------------------------------------------- /SandCastle/Shortcut to SandCastle.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/SandCastle/Shortcut to SandCastle.lnk -------------------------------------------------------------------------------- /SandCastle/dotNetTips.Utility.4.0.shfbproj_davidmccarter: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/SandCastle/dotNetTips.Utility.4.0.shfbproj_davidmccarter -------------------------------------------------------------------------------- /buildspec.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/buildspec.yaml -------------------------------------------------------------------------------- /dotNetTips.Utility.EntityFramework/Data/IDataEntity.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : david 4 | // Created : 06-02-2017 5 | // 6 | // Last Modified By : david 7 | // Last Modified On : 07-07-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | //

13 | // *********************************************************************** 14 | using System; 15 | 16 | namespace dotNetTips.Utility.Portable.Data 17 | { 18 | /// 19 | /// Interface IDataEntity 20 | /// 21 | public interface IDataEntity: IValid 22 | { 23 | /// 24 | /// Gets or sets the created at date. 25 | /// 26 | /// The created at. 27 | DateTimeOffset CreatedAt { get; set; } 28 | /// 29 | /// Gets or sets a value indicating whether this is deleted. 30 | /// 31 | /// true if deleted; otherwise, false. 32 | bool Deleted { get; set; } 33 | /// 34 | /// Gets or sets the identifier. 35 | /// 36 | /// The identifier. 37 | int Id { get; set; } 38 | 39 | /// 40 | /// Gets or sets the public key. 41 | /// 42 | /// 43 | /// The public key. 44 | /// 45 | Guid PublicKey { get; set; } 46 | 47 | /// 48 | /// Gets or sets the updated at. 49 | /// 50 | /// The updated at. 51 | DateTimeOffset? UpdatedAt { get; set; } 52 | /// 53 | /// Gets or sets the version. 54 | /// 55 | /// The version. 56 | byte[] Version { get; set; } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /dotNetTips.Utility.EntityFramework/dotNetTips.Utility.EntityFramework.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 2018.10.10.34606 6 | 2018.10.10.34606 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/DateTimeExtensionsTest.Intersects.g.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Tests/DateTimeExtensionsTest.Intersects.g.cs -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/DateTimeExtensionsTest.ToFriendlyDateString.g.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Tests/DateTimeExtensionsTest.ToFriendlyDateString.g.cs -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/DateTimeExtensionsTest.Tomorrow.g.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Tests/DateTimeExtensionsTest.Tomorrow.g.cs -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/DateTimeExtensionsTest.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Tests/DateTimeExtensionsTest.cs -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/EncapsulationTest.TryValidateParam.g.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Tests/EncapsulationTest.TryValidateParam.g.cs -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/EncapsulationTest.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Tests/EncapsulationTest.cs -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/ExceptionExtensionTest.GetAllMessages.g.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Tests/ExceptionExtensionTest.GetAllMessages.g.cs -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/ExceptionExtensionTest.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Tests/ExceptionExtensionTest.cs -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 |  2 | // This file is used by Code Analysis to maintain SuppressMessage 3 | // attributes that are applied to this project. 4 | // Project-level suppressions either have no target or are given 5 | // a specific target and scoped to a namespace, type, member, etc. 6 | 7 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CC0091:Use static method", Justification = "", Scope = "member", Target = "~M:dotNetTips.Utility.Portable.Extensions.Tests.TypeExtensionsTest.Max``1(``0,``0)~``0")] 8 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1016:MarkAssembliesWithAssemblyVersion")] 9 | 10 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2015 2 | using System; 3 | using System.Reflection; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | using System.Security; 7 | 8 | // System.Security 9 | [assembly: SecurityRules(SecurityRuleSet.Level1)] 10 | 11 | // System.Reflection 12 | [assembly: AssemblyTitle("dotNetTips.Utility.Portable Pex Tests")] 13 | 14 | // System.Runtime.InteropServices 15 | [assembly: ComVisible(false)] 16 | [assembly: Guid("c86fa501-a589-487e-a1db-eb857fe71be3")] 17 | 18 | // System 19 | [assembly: CLSCompliant(false)] 20 | 21 | // System.Runtime.CompilerServices 22 | [assembly: InternalsVisibleTo("Microsoft.Pex, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] 23 | 24 | 25 | [assembly: AssemblyInformationalVersion("1.0.4")] -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/Properties/PexAssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Tests/Properties/PexAssemblyInfo.cs -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/TypeHelperTest.Create.g.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Tests/TypeHelperTest.Create.g.cs -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Tests/TypeHelperTest.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Tests/TypeHelperTest.cs -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Constants.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable.Windows 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 05-16-2014 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports dotNetTips.Utility.Portable 15 | ''' 16 | ''' General constants 17 | ''' 18 | ''' 19 | Public Module Constants 20 | 21 | ''' 22 | ''' Two letter country code for the United States. 23 | ''' 24 | Public Const CountryCodeUnitedStates As String = "US" 25 | Friend Const DotNetTipsNameSpace As String = "http://dotNetTips.com/2014/05" 26 | 27 | End Module -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/CounterChangedEventArgs.vb: -------------------------------------------------------------------------------- 1 | '*********************************************************************** 2 | ' Assembly : dotNetTips 3 | ' Author : David McCarter 4 | ' Created : 06-09-2009 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 06-09-2009 8 | ' Description : 9 | ' 10 | ' Copyright : (c) dotNetTips.com. All rights reserved. 11 | '*********************************************************************** 12 | 13 | ''' 14 | ''' Arguments for when the counter value is changed. 15 | ''' 16 | Public Class CounterChangedEventArgs 17 | Inherits System.EventArgs 18 | 19 | Private _newValue As Int32 20 | 21 | ''' 22 | ''' Initializes a new instance of the class. 23 | ''' 24 | Public Sub New() 25 | End Sub 26 | 27 | ''' 28 | ''' New Value of the Counter. 29 | ''' 30 | ''' 31 | ''' 32 | ''' 33 | Public Property NewValue() As Int32 34 | 35 | Get 36 | Return Me._newValue 37 | End Get 38 | 39 | Friend Set(ByVal value As Int32) 40 | Me._newValue = value 41 | End Set 42 | 43 | End Property 44 | 45 | Friend Sub New(ByVal value As Int32) 46 | Me.NewValue = value 47 | End Sub 48 | 49 | End Class -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Data/Country.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 01-23-2016 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' ************************************************************************* 14 | Namespace Data 15 | 16 | ''' 17 | ''' Country class. 18 | ''' 19 | Public Class Country 20 | 21 | ''' 22 | ''' Name of country. 23 | ''' 24 | ''' Country name. 25 | Public Property Name() As String 26 | 27 | ''' 28 | ''' Gets or sets the code. 29 | ''' 30 | ''' The code. 31 | Public Property Code() As String 32 | 33 | End Class 34 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Data/DataHelper.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 02-01-2014 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Globalization 15 | 16 | Namespace Data 17 | 18 | ''' 19 | ''' Common data helper methods. 20 | ''' 21 | ''' 22 | Public Module DataHelper 23 | 24 | ''' 25 | ''' Converts a date to a SQL Server int value. 26 | ''' 27 | ''' Date to convert. 28 | ''' Date as integer. 29 | ''' 30 | Public Function ConvertDateToSqlInt32(ByVal value As Date) As Int32 31 | Return Int32.Parse(value.Year.ToString(CultureInfo.InvariantCulture) + value.Month.ToString("00", CultureInfo.InvariantCulture) + value.Day.ToString("00", CultureInfo.InvariantCulture), CultureInfo.InvariantCulture) 32 | End Function 33 | 34 | ''' 35 | ''' Converts time to a SQL Server in value. 36 | ''' 37 | ''' Time to convert. 38 | ''' Time as integer. 39 | ''' 40 | Public Function ConvertTimeToSqlInt32(ByVal value As Date) As Int32 41 | Return Int32.Parse(value.Hour.ToString(CultureInfo.InvariantCulture) + value.Minute.ToString("00", CultureInfo.InvariantCulture) + value.Second.ToString("00", CultureInfo.InvariantCulture), CultureInfo.InvariantCulture) 42 | End Function 43 | 44 | ''' 45 | ''' Converts a SQL Server int date and time to a DateTime value. 46 | ''' 47 | ''' SQL Server date. 48 | ''' SQL Server time. 49 | ''' Date and Time. 50 | ''' 51 | Public Function ConvertSqlDateTime(ByVal sqlDate As Int32, ByVal sqlTime As Int32) As DateTime 52 | Dim tempDate As String = sqlDate.ToString(CultureInfo.InvariantCulture) 53 | Dim tempTime As String = sqlTime.ToString("000000", CultureInfo.InvariantCulture) 54 | 55 | Return New Date(Int32.Parse(tempDate.Substring(0, 4), CultureInfo.InvariantCulture), Int32.Parse(tempDate.Substring(4, 2), CultureInfo.InvariantCulture), Int32.Parse(tempDate.Substring(6, 2), CultureInfo.InvariantCulture), Int32.Parse(tempTime.Substring(0, 2), CultureInfo.InvariantCulture), Int32.Parse(tempTime.Substring(2, 2), CultureInfo.InvariantCulture), Int32.Parse(tempTime.Substring(4, 2), CultureInfo.InvariantCulture)) 56 | 57 | End Function 58 | 59 | End Module 60 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Data/DataLists.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 02-01-2014 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Xml.Linq 15 | 16 | Namespace Data 17 | 18 | ''' 19 | ''' Various data lists. 20 | ''' 21 | ''' 22 | Public Module DataLists 23 | 24 | ''' 25 | ''' List of states. 26 | ''' 27 | ''' UsStates. 28 | Public Function StatesList() As UsStatesCollection 29 | 30 | Dim reader = XElement.Parse(My.Resources.States) 31 | 32 | Static list As New System.Collections.Generic.List(Of State) 33 | 34 | Dim data = From s In reader.Elements(XName.Get("state")) 35 | Order By s.Attribute(XName.Get("name")).Value 36 | Select New State With {.Name = s.Attribute(XName.Get("name")).Value.ToUpper, 37 | .Code = s.Attribute(XName.Get("abbreviation")).Value.ToUpper} 38 | 39 | list = data.ToList 40 | 41 | Return New UsStatesCollection(list.AsEnumerable) 42 | 43 | End Function 44 | 45 | ''' 46 | ''' Loads countries. 47 | ''' 48 | ''' Countries. 49 | Public Function CountriesList() As CountriesCollection 50 | 51 | Dim reader = XElement.Parse(My.Resources.Countries) 52 | 53 | Static list As New System.Collections.Generic.List(Of Country) 54 | 55 | Dim data = From c In reader.Elements(XName.Get("ISO_3166-1_Entry")) 56 | Order By c.Element(XName.Get("ISO_3166-1_Country_name")).Value 57 | Select New Country With {.Name = c.Element(XName.Get("ISO_3166-1_Country_name")).Value.ToUpper, 58 | .Code = c.Element(XName.Get("ISO_3166-1_Alpha-2_Code_element")).Value.ToUpper} 59 | 60 | list = data.ToList 61 | 62 | Return New CountriesCollection(list.AsEnumerable) 63 | 64 | End Function 65 | 66 | End Module 67 | 68 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Data/State.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 02-01-2014 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Namespace Data 15 | 16 | ''' 17 | ''' State class. 18 | ''' 19 | ''' 20 | Public Class State 21 | 22 | ''' 23 | ''' State name. 24 | ''' 25 | ''' State name. 26 | ''' State name. 27 | ''' 28 | Public Property Name() As String 29 | 30 | ''' 31 | ''' State code. 32 | ''' 33 | ''' State code. 34 | ''' State code. 35 | ''' 36 | Public Property Code() As String 37 | 38 | End Class 39 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Data/UsStatesCollection.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 02-01-2014 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Linq.Expressions 15 | Imports dotNetTips.Utility.Portable.OOP 16 | 17 | Namespace Data 18 | ''' 19 | ''' List of US States 20 | ''' 21 | ''' 22 | Public NotInheritable Class UsStatesCollection 23 | Inherits EnumerableQuery(Of State) 24 | ''' 25 | ''' Constructor that auto loads the states list. 26 | ''' 27 | ''' 28 | Public Sub New() 29 | MyBase.New(DataLists.StatesList) 30 | End Sub 31 | ''' 32 | ''' Constructor that loads the states 33 | ''' 34 | ''' List of states. 35 | ''' 36 | Public Sub New(ByVal list As IEnumerable(Of State)) 37 | MyBase.New(list) 38 | End Sub 39 | ''' 40 | ''' Initializes a new instance of the class and associates the instance with an expression tree. 41 | ''' 42 | ''' An expression tree to associate with the new instance. 43 | Public Sub New(ByVal expression As Expression) 44 | MyBase.New(expression) 45 | End Sub 46 | 47 | ''' 48 | ''' Converts a state name to state code or state code to state name. 49 | ''' 50 | ''' State name or code. 51 | ''' State name or code. 52 | ''' 53 | Public Shared Function ConvertNameOrCode(ByVal nameOrCode As String) As String 54 | Encapsulation.TryValidateParam(Of ArgumentNullException)(String.IsNullOrEmpty(nameOrCode) = False) 55 | 56 | nameOrCode = nameOrCode.Trim 57 | Dim countryResult = String.Empty 58 | 59 | Return CountriesCollection.ParseCountryCodes(nameOrCode, countryResult) 60 | End Function 61 | End Class 62 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Extensions/CollectionExtensions.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 08-17-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 08-24-2013 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Runtime.CompilerServices 15 | 16 | Namespace Extensions 17 | ''' 18 | ''' 19 | ''' 20 | Public Module CollectionExtensions 21 | 22 | ''' 23 | ''' Splits the specified list. 24 | ''' 25 | ''' The list. 26 | ''' The group count. 27 | ''' 28 | ''' 29 | 30 | Public Function Split(list As IList, groupCount As Integer) As IEnumerable 31 | Return SplitList(Of IList)(CType(list, Global.System.Collections.Generic.List(Of Global.System.Collections.IList)), groupCount) 32 | End Function 33 | 34 | ''' 35 | ''' Determines whether the specified list is valid. 36 | ''' 37 | ''' The list. 38 | ''' 39 | ''' 40 | 41 | Public Function IsValid(list As IList) As Boolean 42 | Return list IsNot Nothing AndAlso list.Count > 0 43 | End Function 44 | 45 | ''' 46 | ''' Determines whether the specified list is valid. 47 | ''' 48 | ''' The list. 49 | ''' 50 | ''' 51 | 52 | Public Function IsValid(list As IEnumerable) As Boolean 53 | Return list.IsValid() 54 | End Function 55 | 56 | Private Function SplitList(Of T)(items As List(Of T), groupCount As Integer) As IEnumerable(Of IEnumerable(Of T)) 57 | 58 | Dim allGroups As New List(Of List(Of T))() 59 | 60 | 'split the list into equal groups 61 | Dim startIndex As Integer = 0 62 | Dim groupLength As Integer = CInt(System.Math.Round(CDbl(items.Count) / CDbl(groupCount), 0)) 63 | While startIndex < items.Count 64 | Dim group As New List(Of T)() 65 | group.AddRange(items.GetRange(startIndex, groupLength)) 66 | startIndex += groupLength 67 | 68 | 'adjust group-length for last group 69 | If startIndex + groupLength > items.Count Then 70 | groupLength = items.Count - startIndex 71 | End If 72 | 73 | allGroups.Add(group) 74 | End While 75 | 76 | 'merge last two groups, if more than required groups are formed 77 | If allGroups.Count > groupCount AndAlso allGroups.Count > 2 Then 78 | allGroups(allGroups.Count - 2).AddRange(allGroups.Last()) 79 | allGroups.RemoveAt(allGroups.Count - 1) 80 | End If 81 | 82 | Return (allGroups.AsEnumerable()) 83 | End Function 84 | End Module 85 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Extensions/DecimalExtensions.vb: -------------------------------------------------------------------------------- 1 | '*********************************************************************** 2 | ' Assembly : dotNetTips 3 | ' Author : David McCarter 4 | ' Created : 12-10-2008 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 09-27-2008 8 | ' Description : 9 | ' 10 | ' Copyright : (c) dotNetTips.com. All rights reserved. 11 | '*********************************************************************** 12 | Imports System.Runtime.CompilerServices 13 | 14 | Namespace Extensions 15 | 16 | ''' 17 | ''' Extensions for the Decimal type. 18 | ''' 19 | ''' 20 | Public Module DecimalExtensions 21 | 22 | ''' 23 | ''' Converts the decimal. 24 | ''' 25 | ''' The value. 26 | ''' The places after. 27 | ''' 28 | _ 29 | Public Function ConvertDecimal(ByVal value As Decimal, ByVal placesAfter As Int32) As Decimal 30 | Return Math.MathHelper.ConvertDecimal(value, placesAfter) 31 | End Function 32 | 33 | End Module 34 | 35 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Extensions/EnumerableExtensions.vb: -------------------------------------------------------------------------------- 1 | '*********************************************************************** 2 | ' Assembly : dotNetTips 3 | ' Author : David McCarter 4 | ' Created : 12-10-2008 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 06-09-2009 8 | ' Description : 9 | ' 10 | ' Copyright : (c) dotNetTips.com. All rights reserved. 11 | '*********************************************************************** 12 | Imports System 13 | Imports System.Collections.Generic 14 | Imports System.Runtime.CompilerServices 15 | Imports dotNetTips.Utility.Portable.OOP 16 | 17 | Namespace Extensions 18 | ''' 19 | ''' Extensions for enums. 20 | ''' 21 | ''' 22 | Public Module EnumerableExtensions 23 | 24 | ''' 25 | ''' Loops over the enum. 26 | ''' 27 | ''' 28 | ''' The values. 29 | ''' The action. 30 | ''' 31 | ''' Code by: Lucas 32 | ''' http://code.msdn.microsoft.com/LucasExtensions 33 | ''' 34 | 35 | Public Sub ForEach(Of T)(ByVal values As IEnumerable(Of T), ByVal action As Action(Of T)) 36 | Encapsulation.TryValidateParam(Of ArgumentNullException)(action IsNot Nothing) 37 | 38 | For Each value As T In values 39 | action(value) 40 | Next 41 | End Sub 42 | 43 | End Module 44 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Extensions/MathExtensions.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Runtime.CompilerServices 3 | 4 | Namespace Extensions 5 | ''' 6 | ''' Extensions for math functions. 7 | ''' 8 | ''' 9 | Public Module MathExtensions 10 | ''' 11 | ''' Rounds the specified value. 12 | ''' 13 | ''' The value. 14 | ''' 15 | ''' 16 | ''' Code by: Lucas 17 | ''' http://code.msdn.microsoft.com/LucasExtensions 18 | ''' 19 | _ 20 | Public Function Round(ByVal value As Double) As Integer 21 | Return CInt(System.Math.Round(value)) 22 | End Function 23 | 24 | ''' 25 | ''' Rounds the specified value. 26 | ''' 27 | ''' The value. 28 | ''' The digits. 29 | ''' 30 | ''' 31 | ''' Code by: Lucas 32 | ''' http://code.msdn.microsoft.com/LucasExtensions 33 | ''' 34 | _ 35 | Public Function Round(ByVal value As Double, ByVal digits As Integer) As Integer 36 | Return CInt(System.Math.Round(value, digits)) 37 | End Function 38 | 39 | ''' 40 | ''' Rounds the specified value. 41 | ''' 42 | ''' The value. 43 | ''' 44 | ''' 45 | ''' Code by: Lucas 46 | ''' http://code.msdn.microsoft.com/LucasExtensions 47 | ''' 48 | _ 49 | Public Function Round(ByVal value As Decimal) As Integer 50 | Return CInt(System.Math.Round(value)) 51 | End Function 52 | 53 | ''' 54 | ''' Rounds the specified value. 55 | ''' 56 | ''' The value. 57 | ''' The digits. 58 | ''' 59 | ''' 60 | ''' Code by: Lucas 61 | ''' http://code.msdn.microsoft.com/LucasExtensions 62 | ''' 63 | _ 64 | Public Function Round(ByVal value As Decimal, ByVal digits As Integer) As Integer 65 | Return CInt(System.Math.Round(value, digits)) 66 | End Function 67 | 68 | End Module 69 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Extensions/NullableExtensions.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 05-12-2014 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | 15 | Namespace Extensions 16 | ''' 17 | ''' 18 | ''' 19 | Public Module NullableExtensions 20 | ''' 21 | ''' Determines whether [has value and equals] [the specified source]. 22 | ''' 23 | ''' 24 | ''' The source. 25 | ''' The target. 26 | ''' 27 | ''' true if [has value and equals] [the specified source]; otherwise, false. 28 | ''' 29 | ''' Code By: MatteoSp 30 | _ 31 | Public Function HasValueAndEquals(Of T As Structure)(ByVal source As Nullable(Of T), ByVal target As T) As Boolean 32 | Return source.HasValue AndAlso source.Value.Equals(target) 33 | End Function 34 | 35 | ''' 36 | ''' Determines whether [has value and equals] [the specified source]. 37 | ''' 38 | ''' 39 | ''' The source. 40 | ''' The target. 41 | ''' 42 | ''' true if [has value and equals] [the specified source]; otherwise, false. 43 | ''' 44 | ''' Code By: MatteoSp 45 | _ 46 | Public Function HasValueAndEquals(Of T As Structure)(ByVal source As Nullable(Of T), ByVal target As Nullable(Of T)) As Boolean 47 | Return source.HasValue AndAlso source.Value.Equals(target) 48 | End Function 49 | 50 | ''' 51 | ''' Returns the nullable string. 52 | ''' 53 | ''' 54 | ''' The param. 55 | ''' 56 | ''' Code By: Chris Rock 57 | _ 58 | Public Function ToNullableString(Of T As Structure)(ByVal param As System.Nullable(Of T)) As String 59 | If param.HasValue Then 60 | Return param.Value.ToString() 61 | Else 62 | Return String.Empty 63 | End If 64 | End Function 65 | 66 | End Module 67 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Extensions/ObjectExtensions.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 08-03-2016 8 | ' *********************************************************************** 9 | ' 10 | ' ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' 14 | ' ************************************************************************* 15 | Imports System.Reflection 16 | Imports System.Globalization 17 | Imports System.Runtime.CompilerServices 18 | 19 | Namespace Extensions 20 | ''' 21 | ''' Extensions for objects. 22 | ''' 23 | Public Module ObjectExtensions 24 | 25 | ''' 26 | ''' Determines whether the specified list is valid. 27 | ''' 28 | ''' The list. 29 | ''' true if the specified list is valid; otherwise, false. 30 | 31 | Public Function IsValid(list As IEnumerable) As Boolean 32 | Return list.IsValid() 33 | End Function 34 | 35 | ''' 36 | ''' Orders the by. 37 | ''' 38 | ''' 39 | ''' The list. 40 | ''' The sort expression. 41 | ''' IEnumerable(Of T). 42 | ''' 43 | Public Function OrderBy(Of T)(ByVal list As IEnumerable(Of T), ByVal sortExpression As String) As IEnumerable(Of T) 44 | 45 | sortExpression += String.Empty 46 | Dim parts As String() = sortExpression.Split(" "c) 47 | Dim descending As Boolean = False 48 | Dim [property] As String = String.Empty 49 | 50 | If parts.Length > 0 AndAlso Not (Not parts(0) Is Nothing AndAlso String.IsNullOrEmpty(parts(0))) Then 51 | [property] = parts(0) 52 | 53 | If parts.Length > 1 Then 54 | descending = parts(1).ToLower().Contains("esc") 55 | End If 56 | 57 | Dim prop As PropertyInfo = GetType(T).GetRuntimeProperty([property]) 58 | 59 | If prop Is Nothing Then 60 | Throw New NullReferenceException(String.Format(CultureInfo.CurrentCulture, "{0}{1}'", ("No property '" & [property] & "' in + "), GetType(T).Name)) 61 | End If 62 | 63 | Return If(descending, list.OrderByDescending(Function(ByVal x) prop.GetValue(x, Nothing)), list.OrderBy(Function(ByVal x) prop.GetValue(x, Nothing))) 64 | End If 65 | 66 | Return list 67 | End Function 68 | 69 | End Module 70 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Extensions/StringBuilderExtensions.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 12-04-2013 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Runtime.CompilerServices 15 | Imports System.Text 16 | Imports System.Globalization 17 | 18 | Namespace Extensions 19 | ''' 20 | ''' StringBuilder Extensions 21 | ''' 22 | ''' 23 | Public Module StringBuilderExtensions 24 | 25 | ''' 26 | ''' Clears the specified StringBuilder text. 27 | ''' 28 | ''' The StringBuilder object. 29 | 30 | Public Sub Clear(ByVal sb As StringBuilder) 31 | sb.Remove(0, sb.ToString().Length) 32 | End Sub 33 | 34 | ''' 35 | ''' Appends the line format. 36 | ''' 37 | ''' The builder. 38 | ''' The format. 39 | ''' The arguments. 40 | ''' 41 | ''' Code by: Koen Rouwhorst 42 | 43 | Public Function AppendLineFormat(ByVal builder As StringBuilder, ByVal format As String, ByVal ParamArray args As Object()) As StringBuilder 44 | Dim value As String = String.Format(CultureInfo.CurrentCulture, format, args) 45 | 46 | builder.AppendLine(value) 47 | 48 | Return builder 49 | End Function 50 | 51 | End Module 52 | 53 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/General.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 02-03-2014 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Reflection 15 | Imports System.IO 16 | Imports dotNetTips.Utility.Portable.OOP 17 | 18 | ''' 19 | ''' General helper functions. 20 | ''' 21 | Public Module General 22 | 23 | ''' 24 | ''' Does the object equal instance. 25 | ''' 26 | ''' The object. 27 | ''' The instance. 28 | ''' 29 | ''' 30 | Public Function DoesObjectEqualInstance(ByVal value As [Object], ByVal instance As Object) As Boolean 31 | Encapsulation.TryValidateParam(Of ArgumentNullException)(value IsNot Nothing) 32 | Encapsulation.TryValidateParam(Of ArgumentNullException)(instance IsNot Nothing) 33 | 34 | Dim result = Object.ReferenceEquals(value, instance) 35 | 36 | Return result 37 | 38 | End Function 39 | 40 | ''' 41 | ''' Gets the instance hash code. 42 | ''' 43 | ''' The instance. 44 | ''' Int32. 45 | Public Function GetInstanceHashCode(ByVal instance As Object) As Int32 46 | Encapsulation.TryValidateParam(Of ArgumentNullException)(instance IsNot Nothing) 47 | 48 | Dim hash As Int32 49 | 50 | For Each prop As PropertyInfo In instance.GetType.GetRuntimeProperties().Where(Function(p) p IsNot Nothing).AsParallel 51 | Dim value = prop.GetValue(instance) 52 | If value IsNot Nothing Then 53 | hash = hash Xor value.GetHashCode 54 | End If 55 | Next 56 | 57 | Return hash 58 | End Function 59 | 60 | ''' 61 | ''' Modified IIf function that works properly! 62 | ''' 63 | ''' Type to return. 64 | ''' if set to true [expression]. 65 | ''' The true part. 66 | ''' The false part. 67 | ''' Defined type. 68 | Public Function IIf(Of T)(ByVal expression As Boolean, ByVal truePart As T, ByVal falsePart As T) As T 69 | Return If(expression, truePart, falsePart) 70 | End Function 71 | 72 | ''' 73 | ''' To the four digit year. 74 | ''' 75 | ''' The year. 76 | ''' 77 | ''' 78 | Public Function ToFourDigitYear(year As Int32) As Int32 79 | Encapsulation.TryValidateParam(Of ArgumentNullException)(year >= 0) 80 | 81 | Dim result As Int32 = If(year >= 100, year, (2 \ 100 - (If(year > 2 Mod 100, 1, 0))) * 100 + year) 82 | 83 | Return result 84 | 85 | End Function 86 | End Module -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/GlobalSuppressions.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Portable.Windows/GlobalSuppressions.vb -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/Math/MathHelper.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 12-04-2013 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Globalization 15 | Imports dotNetTips.Utility.Portable.OOP 16 | 17 | Namespace Math 18 | ''' 19 | ''' Math helper class. 20 | ''' 21 | ''' 22 | Public Module MathHelper 23 | 24 | ''' 25 | ''' Converts decimal and returns places after decimal point. 26 | ''' 27 | ''' Decimal value to convert. 28 | ''' Places after the decimal to return. 29 | ''' Converted decimal. 30 | ''' 31 | Public Function ConvertDecimal(ByVal d As Decimal, ByVal digits As Int32) As Decimal 32 | Dim convertedValue As System.Text.StringBuilder = New System.Text.StringBuilder() 33 | Dim tempValue As String = Convert.ToString(d, CultureInfo.CurrentCulture) 34 | Dim tempSplit() As String = tempValue.Split(Convert.ToChar(".", CultureInfo.CurrentCulture)) 35 | 36 | If (tempSplit.GetLowerBound(0) = 0) Then 37 | convertedValue.Append(tempSplit(0)) 38 | End If 39 | 40 | If (tempSplit.GetUpperBound(0) = 1) Then 41 | convertedValue.Append(".") 42 | convertedValue.Append(tempSplit(1).Substring(0, digits)) 43 | End If 44 | 45 | Return Convert.ToDecimal(convertedValue.ToString(), CultureInfo.CurrentCulture) 46 | 47 | End Function 48 | 49 | ''' 50 | ''' Calculates the kilobytes. 51 | ''' 52 | ''' Decimal number to be calculated. 53 | ''' 54 | ''' 55 | Public Function CalculateKilobytes(ByVal d As Decimal) As Decimal 56 | Return CalculateKilobytes(d, 0) 57 | End Function 58 | 59 | ''' 60 | ''' Calculates the kilobytes. 61 | ''' 62 | ''' Decimal number to be calculated. 63 | ''' The number of decimal places in the return value. 64 | ''' 65 | ''' 66 | Public Function CalculateKilobytes(ByVal d As Decimal, ByVal digits As Int32) As Decimal 67 | Encapsulation.TryValidateParam(Of ArgumentOutOfRangeException)(digits >= 0 AndAlso digits <= 15, "Must be in range 0-15") 68 | 69 | Return CDec(System.Math.Round(d / 1024.0, digits)) 70 | End Function 71 | End Module 72 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/My Project/AssemblyInfo.vb: -------------------------------------------------------------------------------- 1 | Imports System.Reflection 2 | Imports System.Runtime.InteropServices 3 | Imports System 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "supports": {}, 3 | "dependencies": {}, 4 | "frameworks": { 5 | ".NETPortable,Version=v4.6,Profile=Profile44": {} 6 | } 7 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable.Windows/project.lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "targets": { 4 | ".NETPortable,Version=v4.6,Profile=Profile44": { 5 | "dotNetTips.Utility.Portable/1.0.0": { 6 | "type": "project", 7 | "framework": ".NETPortable,Version=v4.5,Profile=Profile7" 8 | } 9 | } 10 | }, 11 | "libraries": { 12 | "dotNetTips.Utility.Portable/1.0.0": { 13 | "type": "project", 14 | "path": "../dotNetTips.Utility.Portable/project.json", 15 | "msbuildProject": "../dotNetTips.Utility.Portable/dotNetTips.Utility.Portable.csproj" 16 | } 17 | }, 18 | "projectFileDependencyGroups": { 19 | "": [], 20 | ".NETPortable,Version=v4.6,Profile=Profile44": [] 21 | }, 22 | "packageFolders": { 23 | "C:\\Users\\david\\.nuget\\packages\\": {} 24 | }, 25 | "project": { 26 | "restore": { 27 | "projectUniqueName": "C:\\src\\git\\dotNetTips.Utility\\dotNetTips.Utility.Portable.Windows\\dotNetTips.Utility.Portable.Windows.vbproj", 28 | "projectName": "dotNetTips.Utility.Portable.Windows", 29 | "projectPath": "C:\\src\\git\\dotNetTips.Utility\\dotNetTips.Utility.Portable.Windows\\dotNetTips.Utility.Portable.Windows.vbproj", 30 | "projectJsonPath": "C:\\src\\git\\dotNetTips.Utility\\dotNetTips.Utility.Portable.Windows\\project.json", 31 | "packagesPath": "C:\\Users\\david\\.nuget\\packages\\", 32 | "outputPath": "C:\\src\\git\\dotNetTips.Utility\\dotNetTips.Utility.Portable.Windows\\obj\\", 33 | "projectStyle": "ProjectJson", 34 | "configFilePaths": [ 35 | "C:\\Users\\david\\AppData\\Roaming\\NuGet\\NuGet.Config", 36 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" 37 | ], 38 | "sources": { 39 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, 40 | "C:\\dotNetTips.com\\NuGet": {}, 41 | "https://api.nuget.org/v3/index.json": {}, 42 | "https://ci.appveyor.com/nuget/benchmarkdotnet": {}, 43 | "https://www.nuget.org/api/v2/": {} 44 | }, 45 | "frameworks": { 46 | "portable46-net451+win81": { 47 | "projectReferences": { 48 | "C:\\src\\git\\dotNetTips.Utility\\dotNetTips.Utility.Portable\\dotNetTips.Utility.Portable.csproj": { 49 | "projectPath": "C:\\src\\git\\dotNetTips.Utility\\dotNetTips.Utility.Portable\\dotNetTips.Utility.Portable.csproj" 50 | } 51 | } 52 | } 53 | } 54 | }, 55 | "frameworks": { 56 | "portable46-net451+win81": {} 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/ArgumentInvalidException.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 12-07-2016 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 05-09-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // ********************************************************************** 14 | using System; 15 | 16 | namespace dotNetTips.Utility.Portable 17 | { 18 | /// 19 | /// Class ArgumentIsInvalidException. 20 | /// 21 | /// 22 | public class ArgumentInvalidException : ArgumentException 23 | { 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | public ArgumentInvalidException() 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of the class. 33 | /// 34 | /// The message that describes the error. 35 | public ArgumentInvalidException(string message) : base(message) 36 | { 37 | } 38 | 39 | /// 40 | /// Initializes a new instance of the class. 41 | /// 42 | /// The error message that explains the reason for the exception. 43 | /// The exception that is the cause of the current exception, or a null reference (Nothing in 44 | /// Visual Basic) if no inner exception is specified. 45 | public ArgumentInvalidException(string message, Exception innerException) : base(message, innerException) 46 | { 47 | } 48 | 49 | /// 50 | /// Initializes a new instance of the class. 51 | /// 52 | /// The error message that explains the reason for the exception. 53 | /// The name of the parameter that caused the current exception. 54 | public ArgumentInvalidException(string message, string paramName): base(message, paramName) 55 | { 56 | } 57 | 58 | /// 59 | /// Initializes a new instance of the class. 60 | /// 61 | /// The error message that explains the reason for the exception. 62 | /// The name of the parameter that caused the current exception. 63 | /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. 64 | public ArgumentInvalidException(string message, string paramName, Exception innerException) : base(message, paramName, innerException) 65 | { 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/ArgumentReadOnlyException.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 12-07-2016 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 05-10-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | using System; 15 | 16 | namespace dotNetTips.Utility.Portable 17 | { 18 | /// 19 | /// Class ArgumentIsReadOnlyException. 20 | /// 21 | /// 22 | /// 23 | public class ArgumentReadOnlyException : ArgumentException 24 | { 25 | /// 26 | /// Initializes a new instance of the class. 27 | /// 28 | public ArgumentReadOnlyException() 29 | { 30 | } 31 | 32 | /// 33 | /// Initializes a new instance of the class. 34 | /// 35 | /// The message that describes the error. 36 | public ArgumentReadOnlyException(string message) 37 | : base(message) 38 | { 39 | } 40 | 41 | /// 42 | /// Initializes a new instance of the class. 43 | /// 44 | /// The error message that explains the reason for the exception. 45 | /// The exception that is the cause of the current exception, or a null reference (Nothing in 46 | /// Visual Basic) if no inner exception is specified. 47 | public ArgumentReadOnlyException(string message, Exception innerException) : base(message, innerException) 48 | { 49 | } 50 | 51 | /// 52 | /// Initializes a new instance of the class. 53 | /// 54 | /// The error message that explains the reason for the exception. 55 | /// The name of the parameter that caused the current exception. 56 | public ArgumentReadOnlyException(string message, string paramName) : base(message, paramName) 57 | { 58 | } 59 | 60 | /// 61 | /// Initializes a new instance of the class. 62 | /// 63 | /// The error message that explains the reason for the exception. 64 | /// The name of the parameter that caused the current exception. 65 | /// The exception that is the cause of the current exception. If the parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. 66 | public ArgumentReadOnlyException(string message, string paramName, Exception innerException) : base(message, paramName, innerException) 67 | { 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/ControlChars.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 12-07-2016 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 03-13-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | 15 | namespace dotNetTips.Utility.Portable 16 | { 17 | /// 18 | /// Control Characters 19 | /// 20 | public static class ControlChars 21 | { 22 | /// 23 | /// Back char 24 | /// 25 | public const char Back = '\b'; 26 | 27 | /// 28 | /// Back Slash 29 | /// 30 | public const char BackSlash = '\\'; 31 | 32 | /// 33 | /// Comma 34 | /// 35 | public const char Comma = ','; 36 | 37 | /// 38 | /// CR 39 | /// 40 | public const char Cr = '\r'; 41 | 42 | /// 43 | /// CRLF 44 | /// 45 | public const string CRLF = "\r\n"; 46 | 47 | /// 48 | /// The double quote 49 | /// 50 | public const string DoubleQuote = "''"; 51 | 52 | /// 53 | /// Form feed 54 | /// 55 | public const char FormFeed = '\f'; 56 | 57 | /// 58 | /// Forward slash 59 | /// 60 | public const char ForwardSlash = '/'; 61 | 62 | /// 63 | /// LF 64 | /// 65 | public const char Lf = '\n'; 66 | 67 | /// 68 | /// New line 69 | /// 70 | public const string NewLine = "\r\n"; 71 | 72 | /// 73 | /// Null character 74 | /// 75 | public const char NullChar = '\0'; 76 | 77 | /// 78 | /// Quote 79 | /// 80 | public const char Quote = '"'; 81 | 82 | /// 83 | /// The single quote 84 | /// 85 | public const char SingleQuote = '\''; 86 | 87 | /// 88 | /// Space 89 | /// 90 | public const char Space = ' '; 91 | 92 | /// 93 | /// Tab 94 | /// 95 | public const char Tab = '\t'; 96 | 97 | /// 98 | /// Underscore 99 | /// 100 | public const char Underscore = '_'; 101 | 102 | /// 103 | /// Vertical tab 104 | /// 105 | public const char VerticalTab = '\v'; 106 | } 107 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/Data/IDataEntity.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : david 4 | // Created : 06-02-2017 5 | // 6 | // Last Modified By : david 7 | // Last Modified On : 07-07-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | using System; 15 | 16 | namespace dotNetTips.Utility.Portable.Data 17 | { 18 | /// 19 | /// Interface IDataEntity 20 | /// 21 | public interface IDataEntity: IValid 22 | { 23 | /// 24 | /// Gets or sets the created at date. 25 | /// 26 | /// The created at. 27 | DateTimeOffset CreatedAt { get; set; } 28 | /// 29 | /// Gets or sets a value indicating whether this is deleted. 30 | /// 31 | /// true if deleted; otherwise, false. 32 | bool Deleted { get; set; } 33 | /// 34 | /// Gets or sets the identifier. 35 | /// 36 | /// The identifier. 37 | int Id { get; set; } 38 | 39 | /// 40 | /// Gets or sets the public key. 41 | /// 42 | /// 43 | /// The public key. 44 | /// 45 | Guid PublicKey { get; set; } 46 | 47 | /// 48 | /// Gets or sets the updated at. 49 | /// 50 | /// The updated at. 51 | DateTimeOffset? UpdatedAt { get; set; } 52 | /// 53 | /// Gets or sets the version. 54 | /// 55 | /// The version. 56 | byte[] Version { get; set; } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/DateFormat.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 12-07-2016 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 03-13-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | 15 | namespace dotNetTips.Utility.Portable 16 | { 17 | /// 18 | /// Enum DateFormat 19 | /// 20 | public enum DateFormat 21 | { 22 | /// 23 | /// The general date 24 | /// 25 | GeneralDate, 26 | 27 | /// 28 | /// The long date 29 | /// 30 | LongDate, 31 | 32 | /// 33 | /// The short date 34 | /// 35 | ShortDate, 36 | 37 | /// 38 | /// The long time 39 | /// 40 | LongTime, 41 | 42 | /// 43 | /// The short time 44 | /// 45 | ShortTime 46 | } 47 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/DateInterval.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 12-07-2016 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 03-13-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | 15 | namespace dotNetTips.Utility.Portable 16 | { 17 | /// 18 | /// Enum DateInterval 19 | /// 20 | public enum DateInterval 21 | { 22 | /// 23 | /// Year 24 | /// 25 | Year, 26 | 27 | /// 28 | /// Quarter 29 | /// 30 | Quarter, 31 | 32 | /// 33 | /// Month 34 | /// 35 | Month, 36 | 37 | /// 38 | /// Day of year 39 | /// 40 | DayOfYear, 41 | 42 | /// 43 | /// Day 44 | /// 45 | Day, 46 | 47 | /// 48 | /// Week of year 49 | /// 50 | WeekOfYear, 51 | 52 | /// 53 | /// Weekday 54 | /// 55 | Weekday, 56 | 57 | /// 58 | /// Hour 59 | /// 60 | Hour, 61 | 62 | /// 63 | /// Minute 64 | /// 65 | Minute, 66 | 67 | /// 68 | /// Second 69 | /// 70 | Second 71 | } 72 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/Diagnostics/PerformanceStopwatch.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 02-02-2017 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 05-18-2017 8 | // *********************************************************************** 9 | // 10 | // Copyright © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | using System; 15 | using System.Diagnostics; 16 | 17 | namespace dotNetTips.Utility.Standard.Diagnostics 18 | { 19 | /// 20 | /// Class PerformanceStopwatch. 21 | /// 22 | /// 23 | [Obsolete("Use PerformanceStopwatch from dotNetTips.Utility.Standard.")] 24 | public class PerformanceStopwatch : Stopwatch 25 | { 26 | 27 | /// 28 | /// Starts the new. 29 | /// 30 | /// PerformanceStopwatch. 31 | public static new PerformanceStopwatch StartNew() 32 | { 33 | var sw = new PerformanceStopwatch(); 34 | sw.Start(); 35 | return sw; 36 | } 37 | 38 | /// 39 | /// Stops the reset. 40 | /// 41 | /// TimeSpan. 42 | public TimeSpan StopReset() 43 | { 44 | this.Stop(); 45 | 46 | var result = this.Elapsed; 47 | 48 | base.Reset(); 49 | 50 | return result; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/DueDate.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 12-07-2016 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 03-13-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | 15 | namespace dotNetTips.Utility.Portable 16 | { 17 | /// 18 | /// Enum DueDate 19 | /// 20 | public enum DueDate 21 | { 22 | /// 23 | /// The end of period 24 | /// 25 | EndOfPeriod, 26 | 27 | /// 28 | /// The begging of period 29 | /// 30 | BeggingOfPeriod 31 | } 32 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/Extensions/HttpExtensions.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 05-04-2017 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 05-04-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | using System.Net.Http; 15 | 16 | namespace dotNetTips.Utility.Portable.Extensions 17 | { 18 | /// 19 | /// Class HttpExtensions. 20 | /// 21 | public static class HttpExtensions 22 | { 23 | /// 24 | /// Determines whether [is XML or json] [the specified content]. 25 | /// 26 | /// The content. 27 | /// true if [is XML or json] [the specified content]; otherwise, false. 28 | private static bool IsXmlOrJson(this HttpContent content) 29 | { 30 | var type = content.Headers.ContentType?.MediaType; 31 | return type != null && (type.Contains("/xml") || type.Contains("/json")); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/FileAttributes.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 12-07-2016 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 03-13-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | using System; 15 | 16 | namespace dotNetTips.Utility.Portable 17 | { 18 | /// 19 | /// Enum FileAttributes 20 | /// 21 | [Flags] 22 | public enum FileAttributes 23 | { 24 | /// 25 | /// Archive 26 | /// 27 | Archive = 0x20, 28 | 29 | /// 30 | /// Directory 31 | /// 32 | Directory = 0x10, 33 | 34 | /// 35 | /// Hidden 36 | /// 37 | Hidden = 2, 38 | 39 | /// 40 | /// Normal 41 | /// 42 | Normal = 0, 43 | 44 | /// 45 | /// Read only 46 | /// 47 | ReadOnly = 1, 48 | 49 | /// 50 | /// System 51 | /// 52 | System = 4, 53 | 54 | /// 55 | /// Volume 56 | /// 57 | Volume = 8 58 | } 59 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/FirstDayOfWeek.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 06-26-2017 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 06-26-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | 15 | namespace dotNetTips.Utility.Portable 16 | { 17 | /// 18 | /// Enum FirstDayOfWeek 19 | /// 20 | public enum FirstDayOfWeek 21 | { 22 | /// 23 | /// The system date 24 | /// 25 | System, 26 | 27 | /// 28 | /// Sunday 29 | /// 30 | Sunday, 31 | 32 | /// 33 | /// Monday 34 | /// 35 | Monday, 36 | 37 | /// 38 | /// Tuesday 39 | /// 40 | Tuesday, 41 | 42 | /// 43 | /// Wednesday 44 | /// 45 | Wednesday, 46 | 47 | /// 48 | /// Thursday 49 | /// 50 | Thursday, 51 | 52 | /// 53 | /// Friday 54 | /// 55 | Friday, 56 | 57 | /// 58 | /// Saturday 59 | /// 60 | Saturday 61 | } 62 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/FirstWeekOfYear.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** Assembly : 2 | // dotNetTips.Utility.Portable Author : David McCarter Created : 06-01-2016 3 | // 4 | // Last Modified By : David McCarter Last Modified On : 06-02-2016 *********************************************************************** 5 | // 6 | // Copyright © 2015 7 | // 8 | // 9 | // 10 | // *********************************************************************** 11 | namespace dotNetTips.Utility.Portable 12 | { 13 | /// 14 | /// Enum FirstWeekOfYear 15 | /// 16 | public enum FirstWeekOfYear 17 | { 18 | /// 19 | /// The system 20 | /// 21 | System, 22 | 23 | /// 24 | /// The Janurary 1st 25 | /// 26 | Jan1, 27 | 28 | /// 29 | /// The first four days 30 | /// 31 | FirstFourDays, 32 | 33 | /// 34 | /// The first full week 35 | /// 36 | FirstFullWeek 37 | } 38 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CC0003:Your catch maybe include some Exception", Justification = "", Scope = "member", Target = "~M:dotNetTips.Utility.Portable.Extensions.ObjectExtensions.TryDispose(System.IDisposable,System.Boolean)")] 2 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CC0031:Check for null before calling a delegate", Justification = "", Scope = "member", Target = "~M:dotNetTips.Utility.Portable.Extensions.CollectionExtensions.Pivot``4(System.Collections.Generic.IEnumerable{``0},System.Func{``0,``1},System.Func{``0,``2},System.Func{System.Collections.Generic.IEnumerable{``0},``3})~System.Collections.Generic.Dictionary{``1,System.Collections.Generic.Dictionary{``2,``3}}")] 3 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0019:Use pattern matching", Justification = "", Scope = "member", Target = "~M:dotNetTips.Utility.Portable.Extensions.CollectionExtensions.Count(System.Collections.IEnumerable)~System.Int32")] 4 | 5 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/ICloneable.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 12-07-2016 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 03-16-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | 15 | 16 | namespace dotNetTips.Utility.Portable 17 | { 18 | /// 19 | /// Interface ICloneable 20 | /// 21 | /// 22 | public interface ICloneable where T : new() 23 | { 24 | /// 25 | /// Cones this instance. 26 | /// 27 | /// T. 28 | T Clone(); 29 | } 30 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/ISingleton.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** Assembly : 2 | // dotNetTips.Utility.Portable Author : David McCarter Created : 06-01-2016 3 | // 4 | // Last Modified By : David McCarter Last Modified On : 06-02-2016 *********************************************************************** 5 | // 6 | // Copyright © 2015 7 | // 8 | // 9 | // 10 | // *********************************************************************** 11 | namespace dotNetTips.Utility.Portable 12 | { 13 | /// 14 | /// Interface ISingleton 15 | /// 16 | /// 17 | public interface ISingleton where T : class 18 | { 19 | /// 20 | /// Gets the instance. 21 | /// 22 | /// The instance. 23 | T Instance(); 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/IValid.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 06-26-2017 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 06-26-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | 15 | namespace dotNetTips.Utility.Portable 16 | { 17 | /// 18 | /// Interface IValid 19 | /// 20 | public interface IValid 21 | { 22 | /// 23 | /// Returns true if type is valid. 24 | /// 25 | /// true if this instance is valid; otherwise, false. 26 | bool IsValid { get; } 27 | } 28 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/ImageExtensions.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 03-20-2017 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 03-20-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | namespace dotNetTips.Utility.Portable 15 | { 16 | /// 17 | /// Class ImageExtensions. 18 | /// 19 | public static class ImageExtensions 20 | { 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/OOP/Validation.cs: -------------------------------------------------------------------------------- 1 | namespace dotNetTips.Utility.Portable.OOP 2 | { 3 | 4 | } 5 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Resources; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | 7 | [assembly: ComVisible(false)] 8 | [assembly: CLSCompliant(true)] 9 | [assembly: AssemblyTitle("dotNetTips.Utility.Portable")] 10 | [assembly: AssemblyDescription("General .NET Utilities")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("dotNetTips.com")] 13 | [assembly: AssemblyProduct("dotNetTips.Utility.Portable")] 14 | [assembly: AssemblyCopyright("David McCarter - dotNetTips.com © 2017")] 15 | [assembly: AssemblyTrademark("David McCarter - dotNetTips.com")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: NeutralResourcesLanguage("en")] 18 | [assembly: AssemblyFileVersion("2019.8.23.34934")] 19 | [assembly: AssemblyVersion("2019.8.23.34934")] 20 | [assembly: InternalsVisibleTo("dotNetTips.Utility.Portable.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001006d7e7837df02533e361082524162d9c4e1fe95e00259418e060f934c05a1de5698dfa4c16d809b725ee416b581d5cf9b3025ae0309c84dd5cad92a924a9cad1b9d1a37567f4a9a4d7695606d6d4cd208e9ca248e1cf734d23800283ad281268bc9b849bba06738869457c05314b3de6de058c68d32ccb87732ef5324c0aeb5b4")] 21 | [assembly: InternalsVisibleTo("dotNetTips.Utility.Portable.Explorables, PublicKey=00240000048000009400000006020000002400005253413100040000010001006d7e7837df02533e361082524162d9c4e1fe95e00259418e060f934c05a1de5698dfa4c16d809b725ee416b581d5cf9b3025ae0309c84dd5cad92a924a9cad1b9d1a37567f4a9a4d7695606d6d4cd208e9ca248e1cf734d23800283ad281268bc9b849bba06738869457c05314b3de6de058c68d32ccb87732ef5324c0aeb5b4")] 22 | [assembly: InternalsVisibleTo("dotNetTips.Utility.Portable1.Tests")] 23 | 24 | 25 | [assembly: AssemblyInformationalVersion("2019.8.0")] -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/TriState.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 12-07-2016 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 03-13-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | 15 | namespace dotNetTips.Utility.Portable 16 | { 17 | /// 18 | /// Enum TriState 19 | /// 20 | public enum Tristate 21 | { 22 | /// 23 | /// False 24 | /// 25 | False = 0, 26 | 27 | /// 28 | /// True 29 | /// 30 | True = -1, 31 | 32 | /// 33 | /// Use default 34 | /// 35 | UseDefault = -2 36 | } 37 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/TypeHelper.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 12-07-2016 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 05-04-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | 15 | using System; 16 | using System.Linq.Expressions; 17 | using System.Linq; 18 | using System.Reflection; 19 | 20 | namespace dotNetTips.Utility.Portable 21 | { 22 | /// 23 | /// Class TypeHelper. 24 | /// 25 | public static class TypeHelper 26 | { 27 | /// 28 | /// Creates type instance. 29 | /// 30 | /// 31 | /// T. 32 | public static T Create() 33 | where T : class 34 | { 35 | var t = typeof(T); 36 | var result = Expression.Lambda>(Expression.Block(t, new Expression[] { Expression.New(t) })).Compile(); 37 | 38 | return result(); 39 | } 40 | 41 | private static T GetDefault() 42 | { 43 | var result = default(T); 44 | 45 | //TODO: FIGURE THIS OUT 46 | //if (typeof(System.Collections.IList).IsAssignableFrom(typeof(T))) 47 | //{ 48 | // if (typeof(T).GetGenericArguments().Length > 0) 49 | // { 50 | // result = (T)Activator.CreateInstance(typeof(T)); 51 | // } 52 | //} 53 | 54 | return result; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/Validation/IValid.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 06-26-2017 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 07-21-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | 15 | 16 | namespace dotNetTips.Utility.Standard.Validation 17 | { 18 | /// 19 | /// Class IValid. 20 | /// 21 | interface IValid 22 | { 23 | /// 24 | /// Returns true if data for the object is valid. 25 | /// 26 | /// The is valid. 27 | IsValidResult IsValid { get; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/Validation/IsValidResult.cs: -------------------------------------------------------------------------------- 1 | // *********************************************************************** 2 | // Assembly : dotNetTips.Utility.Portable 3 | // Author : David McCarter 4 | // Created : 06-26-2017 5 | // 6 | // Last Modified By : David McCarter 7 | // Last Modified On : 07-21-2017 8 | // *********************************************************************** 9 | // 10 | // David McCarter - dotNetTips.com © 2017 11 | // 12 | // 13 | // *********************************************************************** 14 | using System.Collections.Generic; 15 | 16 | namespace dotNetTips.Utility.Standard.Validation 17 | { 18 | /// 19 | /// Class IsValidResult. 20 | /// 21 | public class IsValidResult 22 | { 23 | /// 24 | /// Returns true if ... is valid. 25 | /// 26 | /// true if this instance is valid; otherwise, false. 27 | public bool IsValid { get; private set; } 28 | 29 | /// 30 | /// Gets the errors. 31 | /// 32 | /// The errors. 33 | public IEnumerable Errors { get; private set; } 34 | 35 | /// 36 | /// Initializes a new instance of the class. 37 | /// 38 | /// if set to true [valid]. 39 | /// The errors. 40 | public IsValidResult(bool valid, IEnumerable errors) 41 | { 42 | this.IsValid = valid; 43 | this.Errors = errors; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/dotNetTips.Utility.Portable.csproj.CodeItRight.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | *.min.js 4 | jquery*.js 5 | 6 | 7 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/package.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | $id$ 6 | 7 | $version$ 8 | 9 | 10 | $author$ 11 | $author$ 12 | 17 | false 18 | 19 | $description$ 20 | 21 | 22 | $copyright$ 23 | 24 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "supports": {}, 3 | "dependencies": {}, 4 | "frameworks": { 5 | ".NETPortable,Version=v4.5,Profile=Profile7": {} 6 | } 7 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Portable/project.lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "targets": { 4 | ".NETPortable,Version=v4.5,Profile=Profile7": {} 5 | }, 6 | "libraries": {}, 7 | "projectFileDependencyGroups": { 8 | "": [], 9 | ".NETPortable,Version=v4.5,Profile=Profile7": [] 10 | }, 11 | "packageFolders": { 12 | "C:\\Users\\david\\.nuget\\packages\\": {} 13 | }, 14 | "project": { 15 | "restore": { 16 | "projectUniqueName": "C:\\src\\git\\dotNetTips.Utility\\dotNetTips.Utility.Portable\\dotNetTips.Utility.Portable.csproj", 17 | "projectName": "dotNetTips.Utility.Portable", 18 | "projectPath": "C:\\src\\git\\dotNetTips.Utility\\dotNetTips.Utility.Portable\\dotNetTips.Utility.Portable.csproj", 19 | "projectJsonPath": "C:\\src\\git\\dotNetTips.Utility\\dotNetTips.Utility.Portable\\project.json", 20 | "packagesPath": "C:\\Users\\david\\.nuget\\packages\\", 21 | "outputPath": "C:\\src\\git\\dotNetTips.Utility\\dotNetTips.Utility.Portable\\obj\\", 22 | "projectStyle": "ProjectJson", 23 | "configFilePaths": [ 24 | "C:\\Users\\david\\AppData\\Roaming\\NuGet\\NuGet.Config", 25 | "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" 26 | ], 27 | "sources": { 28 | "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, 29 | "C:\\dotNetTips.com\\NuGet": {}, 30 | "https://api.nuget.org/v3/index.json": {}, 31 | "https://ci.appveyor.com/nuget/benchmarkdotnet": {}, 32 | "https://www.nuget.org/api/v2/": {} 33 | } 34 | }, 35 | "frameworks": { 36 | "portable45-net45+win8": {} 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/Category.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Windows.Logger/Category.vb -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/GlobalSuppressions.vb: -------------------------------------------------------------------------------- 1 | ' This file is used by Code Analysis to maintain SuppressMessage 2 | ' attributes that are applied to this project. 3 | ' Project-level suppressions either have no target or are given 4 | ' a specific target and scoped to a namespace, type, member, etc. 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/InfoItem.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Windows.Logger/InfoItem.vb -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/InvalidEnumTypeException.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 08-10-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 08-04-2013 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System 15 | Imports System.Runtime.Serialization 16 | 17 | ''' 18 | ''' 19 | ''' 20 | _ 21 | Public Class InvalidEnumTypeException 22 | Inherits Exception 23 | ''' 24 | ''' Initializes a new instance of the class. 25 | ''' 26 | ''' The error message. 27 | Public Sub New(message As String) 28 | MyBase.New(message) 29 | End Sub 30 | 31 | ''' 32 | ''' Initializes a new instance of the class. 33 | ''' 34 | Public Sub New() 35 | End Sub 36 | 37 | ''' 38 | ''' Initializes a new instance of the class. 39 | ''' 40 | ''' The message. 41 | ''' The inner exception. 42 | Public Sub New(message As String, innerException As Exception) 43 | MyBase.New(message, innerException) 44 | End Sub 45 | 46 | ''' 47 | ''' Initializes a new instance of the class. 48 | ''' 49 | ''' The 50 | ''' that holds the serialized object data about the exception being thrown. 51 | ''' The 52 | ''' that contains contextual information about the source or destination. 53 | ''' 54 | ''' The parameter is null. 55 | ''' 56 | ''' 57 | ''' The class name is null or is zero (0). 58 | ''' 59 | Protected Sub New(info As SerializationInfo, context As StreamingContext) 60 | MyBase.New(info, context) 61 | End Sub 62 | End Class -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/LogItem.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Windows.Logger/LogItem.vb -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/LoggingHelper.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility.Windows.Logger/LoggingHelper.vb -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/LoggingKeys.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 08-10-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 08-04-2013 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | ''' 15 | ''' 16 | ''' 17 | Public NotInheritable Class LoggingKeys 18 | Private Sub New() 19 | End Sub 20 | 21 | ''' 22 | ''' 23 | ''' 24 | ''' 25 | Public Const HttpRequestUrl As String = "Http.Request.Url" 26 | ''' 27 | ''' 28 | ''' 29 | ''' 30 | Public Const HttpRequestUserHostAddress As String = "Http.Request.UserHostAddress" 31 | ''' 32 | ''' 33 | ''' 34 | ''' 35 | Public Const HttpRequestUserHostName As String = "Http.Request.UserHostName" 36 | ''' 37 | ''' 38 | ''' 39 | ''' 40 | Public Const HttpRequestTotalBytes As String = "Http.Request.TotalBytes" 41 | ''' 42 | ''' 43 | ''' 44 | ''' 45 | Public Const HttpRequestHeaderPrefix As String = "Http.Request.Header." 46 | 47 | End Class -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/LoggingTraceListener.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Windows.Logger 3 | ' Author : David McCarter 4 | ' Created : 04-15-2016 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 04-08-2016 8 | ' *********************************************************************** 9 | ' 10 | ' NicheWare - dotNetTips.com. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Globalization 15 | ''' 16 | ''' Base class for trace listeners. 17 | ''' 18 | ''' 19 | Public MustInherit Class LoggingTraceListener 20 | Inherits TraceListener 21 | 22 | ''' 23 | ''' Initializes a new instance of the class. 24 | ''' 25 | Protected Sub New() 26 | MyBase.New() 27 | End Sub 28 | 29 | ''' 30 | ''' Initializes a new instance of the class. 31 | ''' 32 | ''' The name. 33 | Protected Sub New(ByVal name As String) 34 | MyBase.New(name) 35 | End Sub 36 | 37 | ''' 38 | ''' Determines whether the specified opts is enabled. 39 | ''' 40 | ''' The opts. 41 | ''' true if the specified opts is enabled; otherwise, false. 42 | Protected Function IsEnabled(ByVal opts As TraceOptions) As Boolean 43 | Return (opts And MyBase.TraceOutputOptions) <> TraceOptions.None 44 | End Function 45 | 46 | ''' 47 | ''' Retrieves the property values. 48 | ''' 49 | Protected Sub RetrievePropertyValues() 50 | Dim listenerAttributes = Me.GetSupportedAttributes() 51 | 52 | If listenerAttributes Is Nothing Then 53 | Exit Sub 54 | End If 55 | 56 | For Each attribute In listenerAttributes.AsParallel 57 | Dim prop = Me.[GetType]().GetProperty(attribute) 58 | 59 | If prop IsNot Nothing AndAlso Me.Attributes.ContainsKey(attribute) Then 60 | Dim ic As IConvertible = Me.Attributes(attribute) 61 | Dim targetType As Type = prop.PropertyType 62 | prop.SetValue(Me, (ic.ToType(targetType, CultureInfo.CurrentCulture)), Nothing) 63 | End If 64 | Next 65 | End Sub 66 | 67 | End Class -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/My Project/Application.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/My Project/Application.myapp: -------------------------------------------------------------------------------- 1 |  2 | 3 | false 4 | false 5 | 0 6 | true 7 | 0 8 | 1 9 | true 10 | 11 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/My Project/AssemblyInfo.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Reflection 3 | Imports System.Resources 4 | Imports System.Runtime.InteropServices 5 | 6 | ' General Information about an assembly is controlled through the following 7 | ' set of attributes. Change these attribute values to modify the information 8 | ' associated with an assembly. 9 | 10 | ' Review the values of the assembly attributes 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/My Project/Settings.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | 15 | Namespace My 16 | 17 | _ 20 | Partial Friend NotInheritable Class MySettings 21 | Inherits Global.System.Configuration.ApplicationSettingsBase 22 | 23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) 24 | 25 | #Region "My.Settings Auto-Save Functionality" 26 | #If _MyType = "WindowsForms" Then 27 | Private Shared addedHandler As Boolean 28 | 29 | Private Shared addedHandlerLockObject As New Object 30 | 31 | _ 32 | Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) 33 | If My.Application.SaveMySettingsOnExit Then 34 | My.Settings.Save() 35 | End If 36 | End Sub 37 | #End If 38 | #End Region 39 | 40 | Public Shared ReadOnly Property [Default]() As MySettings 41 | Get 42 | 43 | #If _MyType = "WindowsForms" Then 44 | If Not addedHandler Then 45 | SyncLock addedHandlerLockObject 46 | If Not addedHandler Then 47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings 48 | addedHandler = True 49 | End If 50 | End SyncLock 51 | End If 52 | #End If 53 | Return defaultInstance 54 | End Get 55 | End Property 56 | End Class 57 | End Namespace 58 | 59 | Namespace My 60 | 61 | _ 64 | Friend Module MySettingsProperty 65 | 66 | _ 67 | Friend ReadOnly Property Settings() As Global.dotNetTips.Utility.Windows.Logger.My.MySettings 68 | Get 69 | Return Global.dotNetTips.Utility.Windows.Logger.My.MySettings.Default 70 | End Get 71 | End Property 72 | End Module 73 | End Namespace 74 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/My Project/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /dotNetTips.Utility.Windows.Logger/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /dotNetTips.Utility/ApplicationHelper.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/ApplicationHelper.vb -------------------------------------------------------------------------------- /dotNetTips.Utility/AssemblyInfo.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/AssemblyInfo.vb -------------------------------------------------------------------------------- /dotNetTips.Utility/ComputerHelper.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/ComputerHelper.vb -------------------------------------------------------------------------------- /dotNetTips.Utility/Config.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 03-22-2017 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 06-24-2017 8 | ' *********************************************************************** 9 | ' 10 | ' NicheWare - David McCarter 11 | ' 12 | ' 13 | ' ************************************************************************* 14 | Imports dotNetTips.Utility.IO 15 | Imports dotNetTips.Utility.Portable 16 | Imports dotNetTips.Utility.Xml 17 | Imports System.IO 18 | ''' 19 | ''' Class Config. 20 | ''' 21 | ''' 22 | ''' 23 | Public Class Config(Of T As Class) 24 | Implements ISingleton(Of T) 25 | ''' 26 | ''' Initializes a new instance of the class. 27 | ''' 28 | Protected Sub New() 29 | Me.ConfigFileName = Path.Combine(DirectoryHelper.AppApplicationDataFolder, "dotNetTips.Dev.Cleaner.config") 30 | End Sub 31 | 32 | ''' 33 | ''' Saves this instance. 34 | ''' 35 | ''' true if XXXX, false otherwise. 36 | Public Overridable Function Save() As Boolean 37 | If File.Exists(Me.ConfigFileName) Then 38 | File.Delete(Me.ConfigFileName) 39 | End If 40 | 41 | XmlHelper.SerializeToXmlFile(_instance, Me.ConfigFileName) 42 | 43 | Return True 44 | End Function 45 | 46 | ''' 47 | ''' Loads this instance. 48 | ''' 49 | ''' true if XXXX, false otherwise. 50 | Public Overridable Function Load() As Boolean 51 | If File.Exists(Me.ConfigFileName) Then 52 | _instance = dotNetTips.Utility.Xml.DeserializeFromXmlFile(Of T)(Me.ConfigFileName) 53 | Return True 54 | End If 55 | 56 | Return False 57 | End Function 58 | 59 | ''' 60 | ''' Gets or sets the name of the configuration file. 61 | ''' 62 | ''' The name of the configuration file. 63 | Public Property ConfigFileName() As String 64 | Get 65 | Return _configFileName 66 | End Get 67 | Protected Set 68 | If _configFileName Is Value Then 69 | Return 70 | End If 71 | _configFileName = Value 72 | End Set 73 | End Property 74 | 75 | 76 | ''' 77 | ''' Gets the instance. 78 | ''' 79 | ''' 80 | Public Function Instance() As T Implements ISingleton(Of T).Instance 81 | If _instance Is Nothing Then 82 | _instance = TypeHelper.Create(Of T)() 83 | End If 84 | 85 | Return _instance 86 | End Function 87 | 88 | ''' 89 | ''' The instance 90 | ''' 91 | Private _instance As T 92 | 93 | ''' 94 | ''' The configuration file name 95 | ''' 96 | Private _configFileName As String 97 | 98 | 99 | End Class -------------------------------------------------------------------------------- /dotNetTips.Utility/CriticalException.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 12-04-2013 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Runtime.Serialization 15 | 16 | ''' 17 | ''' Custom critical Exception. Used to bubble up an un-handled Exception to the application level for logging and notifying the user. 18 | ''' 19 | 20 | _ 21 | Public Class CriticalException 22 | Inherits Exception 23 | ''' 24 | ''' Initializes a new instance of the class. 25 | ''' 26 | ''' The user message. 27 | Public Sub New(ByVal userMessage As String) 28 | MyBase.New(userMessage) 29 | End Sub 30 | 31 | ''' 32 | ''' Initializes a new instance of the class. 33 | ''' 34 | ''' The user message. 35 | ''' The original exception. 36 | Public Sub New(ByVal userMessage As String, ByVal originalException As Exception) 37 | MyBase.New(userMessage, originalException) 38 | End Sub 39 | 40 | ''' 41 | ''' Initializes a new instance of the class. 42 | ''' 43 | ''' The info. 44 | ''' The context. 45 | Protected Sub New(ByVal info As System.Runtime.Serialization.SerializationInfo, ByVal context As System.Runtime.Serialization.StreamingContext) 46 | MyBase.New(info, context) 47 | 48 | End Sub 49 | 50 | ''' 51 | ''' Initializes a new instance of the class. 52 | ''' 53 | Public Sub New() 54 | 55 | End Sub 56 | 57 | End Class -------------------------------------------------------------------------------- /dotNetTips.Utility/DirectoryServices/ActiveDirectoryHelper.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/DirectoryServices/ActiveDirectoryHelper.vb -------------------------------------------------------------------------------- /dotNetTips.Utility/DirectoryServices/UserInfo.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/DirectoryServices/UserInfo.vb -------------------------------------------------------------------------------- /dotNetTips.Utility/Extensions/CollectionExtensions.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 05-14-2014 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 03-10-2017 8 | ' *********************************************************************** 9 | ' 10 | ' ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' 14 | ' ************************************************************************* 15 | Imports System.Drawing 16 | Imports System.IO 17 | Imports System.Runtime.CompilerServices 18 | 19 | Namespace Extensions 20 | ''' 21 | ''' Class CollectionExtensions. 22 | ''' 23 | Public Module CollectionExtensions 24 | 25 | ''' 26 | ''' To the image. 27 | ''' 28 | ''' The value. 29 | ''' Image. 30 | 31 | Public Function ToImage(value As Byte()) As Image 32 | 33 | Dim image As Image 34 | 35 | Using stream As New MemoryStream(value) 36 | image = Image.FromStream(stream) 37 | End Using 38 | 39 | Return image 40 | 41 | End Function 42 | 43 | End Module 44 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/Extensions/ColorExtensions.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 03-29-2016 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 07-29-2018 8 | ' *********************************************************************** 9 | ' 10 | ' ' NicheWare - David McCarter 11 | ' 12 | ' 13 | ' 14 | ' ************************************************************************* 15 | Imports System.Collections.Generic 16 | Imports System.Drawing 17 | Imports System.Runtime.CompilerServices 18 | Imports dotNetTips.Utility.Portable.Extensions 19 | Imports dotNetTips.Utility.Portable.OOP 20 | 21 | Namespace Extensions 22 | ''' 23 | ''' Extension methods for color values. 24 | ''' 25 | Public Module ColorExtensions 26 | 27 | ''' 28 | ''' Converts color to HTML color. 29 | ''' 30 | ''' The color. 31 | ''' HTML string color representation. 32 | ''' Code by: Lucas 33 | ''' http://code.msdn.microsoft.com/LucasExtensions 34 | 35 | Public Function ToHtml(ByVal color As Color) As String 36 | Return ColorTranslator.ToHtml(color) 37 | End Function 38 | 39 | ''' 40 | ''' Converts the html color to Color. 41 | ''' 42 | ''' Color of the HTML. 43 | ''' CGI+ Color structure. 44 | ''' Code by: Lucas 45 | ''' http://code.msdn.microsoft.com/LucasExtensions 46 | 47 | Public Function ToHtmlColor(ByVal htmlColor As String) As Color 48 | Return ColorTranslator.FromHtml(htmlColor) 49 | End Function 50 | 51 | ''' 52 | ''' Averages the specified colors in the collection.. 53 | ''' 54 | ''' The colors. 55 | ''' CGI+ Color structure. 56 | ''' Code by: Lucas 57 | ''' http://code.msdn.microsoft.com/LucasExtensions 58 | 59 | Public Function Average(ByVal colors As IEnumerable(Of Color)) As Color 60 | 61 | Encapsulation.TryValidateParam(colors, NameOf(colors)) 62 | 63 | Dim r As Integer = colors.Average(Function(c) c.R).Round() 64 | Dim g As Integer = colors.Average(Function(c) c.G).Round() 65 | Dim b As Integer = colors.Average(Function(c) c.B).Round() 66 | 67 | Return Color.FromArgb(r, g, b) 68 | End Function 69 | End Module 70 | 71 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/Extensions/DataContextExtensions.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 08-03-2015 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 03-06-2017 8 | ' *********************************************************************** 9 | ' 10 | ' ' dotNetTips.com. All rights reserved. 11 | ' 12 | ' 13 | ' 14 | ' ************************************************************************* 15 | Imports System.Collections.Generic 16 | Imports System.Data.Linq 17 | Imports System.Reflection 18 | Imports System.Runtime.CompilerServices 19 | 20 | ''' 21 | ''' Class DataContextExtensions. 22 | ''' 23 | Public Module DataContextExtensions 24 | ''' 25 | ''' Gets the tracked objects. 26 | ''' 27 | ''' 28 | ''' The dc. 29 | ''' IList(Of Tuple(Of T, T)). 30 | 31 | Public Function GetTrackedObjects(Of T)(ByVal context As DataContext) As IList(Of Tuple(Of T, T)) 32 | Dim result As New List(Of Tuple(Of T, T)) 33 | Dim dcType = GetType(DataContext) 34 | 35 | ' Use reflection to get to the underlying items being tracked in the DataContext 36 | Const bindings = BindingFlags.NonPublic Or BindingFlags.Instance Or BindingFlags.GetField 37 | 38 | Dim services = dcType.GetField("services", bindings).GetValue(context) 39 | 40 | Dim tracker = services.GetType().GetField("tracker", bindings).GetValue(services) 41 | 42 | Dim trackerItems = DirectCast(tracker.GetType().GetField("items", bindings).GetValue(tracker), IDictionary) 43 | 44 | ' iterate through each update in context, adding only those that are of type T to the method's result variable 45 | For Each entry As DictionaryEntry In trackerItems.AsParallel() 46 | Dim original As Object = entry.Value.GetType().GetField(NameOf(original), bindings).GetValue(entry.Value) 47 | If TypeOf entry.Key Is T AndAlso TypeOf original Is T Then 48 | result.Add(New Tuple(Of T, T)(DirectCast(original, T), DirectCast(entry.Key, T))) 49 | End If 50 | Next 51 | 52 | Return result 53 | End Function 54 | End Module -------------------------------------------------------------------------------- /dotNetTips.Utility/Extensions/DataServicesExtensions.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 03-06-2017 8 | ' *********************************************************************** 9 | ' 10 | ' ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' 14 | ' ************************************************************************* 15 | Imports System.Collections.Generic 16 | Imports System.Data.Services 17 | Imports System.Runtime.CompilerServices 18 | 19 | Namespace Extensions 20 | ''' 21 | ''' Class DataServicesExtensions. 22 | ''' 23 | Public Module DataServicesExtensions 24 | ''' 25 | ''' Copies the request header values. 26 | ''' 27 | ''' The args. 28 | ''' SortedDictionary(Of System.String, System.String). 29 | 30 | Public Function CopyRequestHeaderValues(args As ProcessRequestArgs) As SortedDictionary(Of String, String) 31 | 32 | Dim requestHeaderValues As New SortedDictionary(Of String, String) 33 | 34 | If args.OperationContext.RequestHeaders IsNot Nothing AndAlso args.OperationContext.RequestHeaders.Count > 0 Then 35 | For Each key In args.OperationContext.RequestHeaders.AllKeys 36 | requestHeaderValues.Add(key, args.OperationContext.RequestHeaders.[Get](key)) 37 | Next 38 | End If 39 | 40 | Return requestHeaderValues 41 | 42 | End Function 43 | End Module 44 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/Extensions/ObjectExtensions.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/Extensions/ObjectExtensions.vb -------------------------------------------------------------------------------- /dotNetTips.Utility/Extensions/ResponseExtensions.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 03-29-2016 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 01-23-2016 8 | ' *********************************************************************** 9 | ' 10 | ' NicheWare - David McCarter 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Runtime.CompilerServices 15 | Imports System.Web 16 | Imports dotNetTips.Utility.Portable.OOP 17 | 18 | Namespace Extensions 19 | ''' 20 | ''' Extensions for HttpResponse objects. 21 | ''' 22 | Public Module ResponseExtensions 23 | ''' 24 | ''' Redirects the specified ref. 25 | ''' 26 | ''' The ref. 27 | ''' The page. 28 | 29 | Public Sub Redirect(ByVal value As System.Web.HttpResponse, ByVal page As String) 30 | Encapsulation.TryValidateParam(Of ArgumentNullException)(String.IsNullOrWhiteSpace(page) = False) 31 | 32 | value.Redirect(page, False) 33 | HttpContext.Current.ApplicationInstance.CompleteRequest() 34 | End Sub 35 | End Module 36 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/Extensions/ThreadExtensions.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 07-27-2017 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 07-27-2017 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter - dotNetTips.com © 2017 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Runtime.CompilerServices 15 | Imports System.Threading 16 | Imports System.Windows.Forms 17 | 18 | ''' 19 | ''' Class ThreadExtensions. 20 | ''' 21 | Public Module ThreadExtensions 22 | ''' 23 | ''' Waits the until the given date/ time. 24 | ''' 25 | ''' The current thread. 26 | ''' The stop on. 27 | 28 | Public Sub WaitUntil(currentThread As Thread, stopOn As DateTime) 29 | Do Until (DateTime.UtcNow >= stopOn.ToUniversalTime) OrElse currentThread.IsAlive = False 30 | Application.DoEvents() 31 | Loop 32 | End Sub 33 | 34 | ''' 35 | ''' Waits for period of time. 36 | ''' 37 | ''' The current thread. 38 | ''' The wait for. 39 | 40 | Public Sub WaitFor(currentThread As Thread, waitFor As TimeSpan) 41 | Dim stopOn = DateTime.UtcNow.Add(waitFor) 42 | currentThread.WaitUntil(stopOn) 43 | End Sub 44 | End Module 45 | -------------------------------------------------------------------------------- /dotNetTips.Utility/Extensions/ValidationHelper.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 12-04-2013 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Namespace Extensions 15 | ''' 16 | ''' Validation helper class. 17 | ''' 18 | ''' 19 | Public Module ValidationHelper 20 | ''' 21 | ''' Validates value is a number. 22 | ''' 23 | ''' Text to validate. 24 | ''' True if valid. 25 | ''' 26 | Public Function IsValidNumber(ByVal input As String) As Boolean 27 | 28 | Return If(String.IsNullOrEmpty(input), False, IsNumeric(input)) 29 | 30 | End Function 31 | End Module 32 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/HelpersClassDiagram.cd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | AAAABAAAAAAAAAAAAAAQAAAABAIAAAAAAAAAAACAAAA= 7 | ApplicationHelper.vb 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | ComputerHelper.vb 16 | 17 | 18 | 19 | 20 | ABEIAAIAAAEAAgAAAAAAAAAIAAABAABAAAAQwQAAAAA= 21 | ComputerHelper.vb 22 | 23 | 24 | 25 | 26 | 27 | AAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAIUAAAgAAAAA= 28 | EnumHelper.vb 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /dotNetTips.Utility/IO/CompressionAction.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 05-20-2016 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 05-20-2016 8 | ' *********************************************************************** 9 | ' 10 | ' NicheWare - David McCarter 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Namespace IO 15 | ''' 16 | ''' Compression Action 17 | ''' 18 | Public Enum CompressionAction 19 | ''' 20 | ''' Zip 21 | ''' 22 | Zip 23 | ''' 24 | ''' Un zip 25 | ''' 26 | UnZip 27 | End Enum 28 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/IO/DriveHelper.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips 3 | ' Author : David McCarter 4 | ' Created : 12-10-2008 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 05-11-2017 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter - dotNetTips.com © 2017 11 | ' 12 | ' 13 | ' ************************************************************************* 14 | Imports System.Management 15 | Imports dotNetTips.Utility.Portable.OOP 16 | 17 | Namespace IO 18 | ''' 19 | ''' Drive helper methods. 20 | ''' 21 | Public Module DriveHelper 22 | ''' 23 | ''' Finds the serial number of a drive. 24 | ''' 25 | ''' Drive name. 26 | ''' Serial number. 27 | ''' This call could take some time. Recommend multi-threading. 28 | Public Function GetDriveSerialNumber(ByVal drive As String) As String 29 | Encapsulation.TryValidateParam(drive, NameOf(drive)) 30 | 31 | Dim driveSerial = String.Empty 32 | 33 | 'No matter what is sent in, get just the drive letter 34 | Dim driveFixed = System.IO.Path.GetPathRoot(drive) 35 | driveFixed = Replace(driveFixed, "\", String.Empty) 36 | 37 | 'Perform Query 38 | Using querySearch As New ManagementObjectSearcher(String.Format("SELECT VolumeSerialNumber FROM Win32_LogicalDisk Where Name = '{0}'", driveFixed)) 39 | Using queryCollection As ManagementObjectCollection = querySearch.Get() 40 | 41 | For Each moItem In queryCollection.AsParallel() 42 | driveSerial = CStr(moItem.Item("VolumeSerialNumber")) 43 | Exit For 44 | Next 45 | 46 | End Using 47 | End Using 48 | 49 | Return driveSerial 50 | 51 | End Function 52 | 53 | End Module 54 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/IO/PathHelper.vb: -------------------------------------------------------------------------------- 1 | '*********************************************************************** 2 | ' Assembly : dotNetTips 3 | ' Author : David McCarter 4 | ' Created : 12-10-2008 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 06-16-2009 8 | ' Description : 9 | ' 10 | ' Copyright : (c) dotNetTips.com. All rights reserved. 11 | '*********************************************************************** 12 | Imports System.IO 13 | 14 | Namespace IO 15 | 16 | ''' 17 | ''' General path helper methods. 18 | ''' 19 | ''' 20 | Public Module PathHelper 21 | 22 | ''' 23 | ''' Converts a long path name into a short path name. 24 | ''' 25 | ''' Long path name to convert. 26 | ''' Short path name. 27 | ''' 28 | Public Function ConvertLongPathToShort(ByVal longPathName As String) As String 29 | 30 | If String.IsNullOrEmpty(longPathName) Then 31 | Throw New ArgumentNullException(NameOf(longPathName)) 32 | End If 33 | 34 | Dim shortNameBuffer As New System.Text.StringBuilder 35 | Dim size As Integer = UnsafeNativeMethods.GetShortPathName(longPathName, shortNameBuffer, shortNameBuffer.Capacity) 36 | 37 | If size < shortNameBuffer.Capacity Then 38 | Return shortNameBuffer.ToString() 39 | End If 40 | 41 | shortNameBuffer.Capacity = size + 1 42 | 43 | If UnsafeNativeMethods.GetShortPathName(longPathName, shortNameBuffer, shortNameBuffer.Capacity) = 0 Then 44 | shortNameBuffer.Remove(0, shortNameBuffer.Length) 45 | End If 46 | 47 | Return shortNameBuffer.ToString() 48 | 49 | End Function 50 | 51 | ''' 52 | ''' Finds a path on the computer. Checks all local drives only. 53 | ''' 54 | ''' Path to find, can include file name. 55 | ''' First path found. 56 | ''' 57 | Public Function FindPathOnDrives(ByVal path As String) As String 58 | 59 | Dim tempPath As String = String.Empty 60 | 61 | If Not File.Exists(System.IO.Path.GetFullPath(path)) Then 62 | Dim pathRoot As String 63 | pathRoot = System.IO.Path.GetPathRoot(path) 64 | 65 | Dim drives = From d In dotNetTips.Utility.ComputerHelper.ComputerReadyDrives 66 | Where d.IsReady 67 | Select Replace(path, pathRoot, d.Name) 68 | 69 | 'Search all local drives for the path/file 70 | For Each testPath As String In drives 71 | 72 | If File.Exists(testPath) Then 73 | tempPath = testPath 74 | Exit For 75 | End If 76 | 77 | Next 78 | 79 | Else 80 | tempPath = path 81 | End If 82 | 83 | Return tempPath 84 | 85 | End Function 86 | 87 | End Module 88 | 89 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/IO/ProcessorEventArgs.vb: -------------------------------------------------------------------------------- 1 | '*********************************************************************** 2 | ' Assembly : dotNetTips 3 | ' Author : David McCarter 4 | ' Created : 06-09-2009 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 06-16-2009 8 | ' Description : 9 | ' 10 | ' Copyright : (c) dotNetTips.com. All rights reserved. 11 | '*********************************************************************** 12 | Namespace IO 13 | ''' 14 | ''' Event arguments for file process. 15 | ''' 16 | Public Class ProcessorEventArgs 17 | Inherits System.EventArgs 18 | 19 | ''' 20 | ''' Initializes a new instance of the class. 21 | ''' 22 | Public Sub New() 23 | End Sub 24 | 25 | Private _totalLength As Long 26 | ''' 27 | ''' Total length of file. 28 | ''' 29 | ''' 30 | ''' 31 | ''' 32 | Public Property TotalLength() As Long 33 | Get 34 | Return _totalLength 35 | End Get 36 | Set(ByVal value As Long) 37 | _totalLength = value 38 | End Set 39 | End Property 40 | Private _lengthCopied As Long 41 | ''' 42 | ''' Total length copied. 43 | ''' 44 | ''' 45 | ''' 46 | ''' 47 | Public Property LengthCopied() As Long 48 | Get 49 | Return _lengthCopied 50 | End Get 51 | Set(ByVal value As Long) 52 | _lengthCopied = value 53 | End Set 54 | End Property 55 | Private _percent As Double 56 | ''' 57 | ''' Percent complete. 58 | ''' 59 | ''' 60 | ''' 61 | ''' 62 | Public Property Percent() As Double 63 | Get 64 | Return _percent 65 | End Get 66 | Set(ByVal value As Double) 67 | _percent = value 68 | End Set 69 | End Property 70 | Private _cancel As Boolean 71 | 72 | ''' 73 | ''' Cancels process. 74 | ''' 75 | ''' 76 | ''' 77 | ''' 78 | Public Property Cancel() As Boolean 79 | Get 80 | Return _cancel 81 | End Get 82 | Set(ByVal value As Boolean) 83 | _cancel = value 84 | End Set 85 | End Property 86 | 87 | End Class 88 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/IO/ProgressEventArgs.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 07-09-2017 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 07-09-2017 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter - dotNetTips.com © 2017 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System 15 | Namespace IO 16 | ''' 17 | ''' Class FileProgressEventArgs. 18 | ''' 19 | ''' 20 | Public Class ProgressEventArgs 21 | Inherits EventArgs 22 | ''' 23 | ''' The name 24 | ''' 25 | Public Name As String 26 | ''' 27 | ''' The size 28 | ''' 29 | Public Size As Long 30 | ''' 31 | ''' The progress state 32 | ''' 33 | Public ProgressState As ProgressState 34 | ''' 35 | ''' The message 36 | ''' 37 | Public Message As String = String.Empty 38 | End Class 39 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/IO/ProgressState.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 07-09-2017 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 07-09-2017 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter - dotNetTips.com © 2017 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System 15 | Namespace IO 16 | ''' 17 | ''' Enum ProgressState 18 | ''' 19 | Public Enum ProgressState 20 | ''' 21 | ''' The error 22 | ''' 23 | [Error] 24 | ''' 25 | ''' The deleted 26 | ''' 27 | Deleted 28 | ''' 29 | ''' The moved 30 | ''' 31 | Moved 32 | ''' 33 | ''' The copied 34 | ''' 35 | Copied 36 | End Enum 37 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/IO/TempFileManager.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/IO/TempFileManager.vb -------------------------------------------------------------------------------- /dotNetTips.Utility/InvalidEnumTypeException.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 07-16-2016 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 07-16-2016 8 | ' *********************************************************************** 9 | ' 10 | ' NicheWare - David McCarter 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Collections.Generic 15 | Imports System.Runtime.Serialization 16 | 17 | ''' 18 | ''' Class InvalidEnumTypeException. 19 | ''' 20 | ''' 21 | 22 | Public Class InvalidEnumTypeException 23 | Inherits Exception 24 | ''' 25 | ''' Initializes a new instance of the class. 26 | ''' 27 | ''' The message. 28 | Public Sub New(ByVal message As String) 29 | MyBase.New(message) 30 | End Sub 31 | 32 | ''' 33 | ''' Initializes a new instance of the class. 34 | ''' 35 | Public Sub New() 36 | End Sub 37 | 38 | ''' 39 | ''' Initializes a new instance of the class. 40 | ''' 41 | ''' The message. 42 | ''' The inner exception. 43 | Public Sub New(ByVal message As String, ByVal innerException As Exception) 44 | MyBase.New(message, innerException) 45 | End Sub 46 | 47 | ''' 48 | ''' Initializes a new instance of the class. 49 | ''' 50 | ''' The info. 51 | ''' The context. 52 | Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext) 53 | MyBase.New(info, context) 54 | End Sub 55 | 56 | End Class -------------------------------------------------------------------------------- /dotNetTips.Utility/My Project/Settings.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | 15 | Namespace My 16 | 17 | _ 20 | Partial Friend NotInheritable Class MySettings 21 | Inherits Global.System.Configuration.ApplicationSettingsBase 22 | 23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) 24 | 25 | #Region "My.Settings Auto-Save Functionality" 26 | #If _MyType = "WindowsForms" Then 27 | Private Shared addedHandler As Boolean 28 | 29 | Private Shared addedHandlerLockObject As New Object 30 | 31 | _ 32 | Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) 33 | If My.Application.SaveMySettingsOnExit Then 34 | My.Settings.Save() 35 | End If 36 | End Sub 37 | #End If 38 | #End Region 39 | 40 | Public Shared ReadOnly Property [Default]() As MySettings 41 | Get 42 | 43 | #If _MyType = "WindowsForms" Then 44 | If Not addedHandler Then 45 | SyncLock addedHandlerLockObject 46 | If Not addedHandler Then 47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings 48 | addedHandler = True 49 | End If 50 | End SyncLock 51 | End If 52 | #End If 53 | Return defaultInstance 54 | End Get 55 | End Property 56 | End Class 57 | End Namespace 58 | 59 | Namespace My 60 | 61 | _ 64 | Friend Module MySettingsProperty 65 | 66 | _ 67 | Friend ReadOnly Property Settings() As Global.dotNetTips.Utility.My.MySettings 68 | Get 69 | Return Global.dotNetTips.Utility.My.MySettings.Default 70 | End Get 71 | End Property 72 | End Module 73 | End Namespace 74 | -------------------------------------------------------------------------------- /dotNetTips.Utility/My Project/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /dotNetTips.Utility/Net/EmailAddressType.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : dotnetdave 4 | ' Created : 04-15-2016 5 | ' 6 | ' Last Modified By : dotnetdave 7 | ' Last Modified On : 04-08-2016 8 | ' *********************************************************************** 9 | ' 10 | ' . All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Namespace Net 15 | ''' 16 | ''' Type of the email address (where it gets used). 17 | ''' 18 | Public Enum EmailAddressType 19 | ''' 20 | ''' Used as Sent To address. 21 | ''' 22 | SendTo 23 | ''' 24 | ''' Used as Send From address. 25 | ''' 26 | SendFrom 27 | ''' 28 | ''' Used as Send Carbon Copy address. 29 | ''' 30 | SendCC 31 | ''' 32 | ''' Used as Send Bind Carbon Copy address. 33 | ''' 34 | SendBcc 35 | End Enum 36 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/Net/Mailer.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/Net/Mailer.vb -------------------------------------------------------------------------------- /dotNetTips.Utility/Net/NetworkHelper.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : dotnetdave 4 | ' Created : 04-15-2016 5 | ' 6 | ' Last Modified By : dotnetdave 7 | ' Last Modified On : 04-15-2016 8 | ' *********************************************************************** 9 | ' 10 | ' . All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Imports System.Net.NetworkInformation 15 | 16 | Namespace Net 17 | ''' 18 | ''' Various network helper methods. 19 | ''' 20 | Public Module NetworkHelper 21 | 22 | ''' 23 | ''' Determines there is an internet connection available. 24 | ''' 25 | ''' True if a internet site can be reached. 26 | Public Function IsInternetConnectionAvailable() As Boolean 27 | Dim success = False 28 | 29 | If My.Computer.Network.IsAvailable = False Then 30 | Return success 31 | End If 32 | 33 | Dim sitesList As String() = {"www.google.com", "www.microsoft.com", "www.yahoo.com"} 34 | 35 | For Each url As String In sitesList.AsParallel() 36 | If My.Computer.Network.Ping(url, 300) Then 37 | success = True 38 | Exit For 39 | End If 40 | Next 41 | 42 | Return success 43 | 44 | End Function 45 | 46 | End Module 47 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/Resources/CommunityChampionsSmall.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/Resources/CommunityChampionsSmall.jpg -------------------------------------------------------------------------------- /dotNetTips.Utility/Resources/Countries.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/Resources/Countries.xml -------------------------------------------------------------------------------- /dotNetTips.Utility/Resources/Image1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/Resources/Image1.bmp -------------------------------------------------------------------------------- /dotNetTips.Utility/Resources/Images/Action_Apply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/Resources/Images/Action_Apply.png -------------------------------------------------------------------------------- /dotNetTips.Utility/Resources/PopupNotifier.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/Resources/PopupNotifier.png -------------------------------------------------------------------------------- /dotNetTips.Utility/Resources/States.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /dotNetTips.Utility/Resources/grip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/Resources/grip.png -------------------------------------------------------------------------------- /dotNetTips.Utility/Security/HashType.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : dotnetdave 4 | ' Created : 05-16-2016 5 | ' 6 | ' Last Modified By : dotnetdave 7 | ' Last Modified On : 05-16-2016 8 | ' *********************************************************************** 9 | ' 10 | ' . All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Namespace Security 15 | ''' 16 | ''' Supported hash algorithms 17 | ''' 18 | Public Enum HashType 19 | ''' 20 | ''' The hmac 21 | ''' 22 | HMAC 23 | ''' 24 | ''' The hmacm d5 25 | ''' 26 | HMACMD5 27 | ''' 28 | ''' The hmacsh a1 29 | ''' 30 | HMACSHA1 31 | ''' 32 | ''' The hmacsh a256 33 | ''' 34 | HMACSHA256 35 | ''' 36 | ''' The hmacsh a384 37 | ''' 38 | HMACSHA384 39 | ''' 40 | ''' The hmacsh a512 41 | ''' 42 | HMACSHA512 43 | ''' 44 | ''' The mac triple DES 45 | ''' 46 | MACTripleDES 47 | ''' 48 | ''' The m d5 49 | ''' 50 | MD5 51 | ''' 52 | ''' The ripem D160 53 | ''' 54 | RIPEMD160 55 | ''' 56 | ''' The sh a1 57 | ''' 58 | SHA1 59 | ''' 60 | ''' The sh a256 61 | ''' 62 | SHA256 63 | ''' 64 | ''' The sh a384 65 | ''' 66 | SHA384 67 | ''' 68 | ''' The sh a512 69 | ''' 70 | SHA512 71 | End Enum 72 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/Security/SecurityHelper.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/Security/SecurityHelper.vb -------------------------------------------------------------------------------- /dotNetTips.Utility/ServiceAction.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : david 4 | ' Created : 05-05-2017 5 | ' 6 | ' Last Modified By : david 7 | ' Last Modified On : 05-13-2017 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter - dotNetTips.com © 2017 11 | ' 12 | ' 13 | ' ************************************************************************* 14 | 15 | ''' 16 | ''' Class ServiceAction. 17 | ''' 18 | Public Class ServiceAction 19 | ''' 20 | ''' Gets or sets the name of the service. 21 | ''' 22 | ''' The name of the service. 23 | Public Property ServiceName() As String 24 | ''' 25 | ''' Gets or sets the service action request. 26 | ''' 27 | ''' The service action request. 28 | Public Property ServiceActionRequest() As ServiceActionRequest 29 | ''' 30 | ''' Gets or sets the service action result. 31 | ''' 32 | ''' The service action result. 33 | Public Property ServiceActionResult() As ServiceActionResult 34 | End Class 35 | -------------------------------------------------------------------------------- /dotNetTips.Utility/ServiceActionRequest.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : david 4 | ' Created : 05-05-2017 5 | ' 6 | ' Last Modified By : david 7 | ' Last Modified On : 05-13-2017 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter - dotNetTips.com © 2017 11 | ' 12 | ' 13 | ' ************************************************************************* 14 | 15 | ''' 16 | ''' Enum ServiceActionRequest 17 | ''' 18 | Public Enum ServiceActionRequest 19 | ''' 20 | ''' The unknown 21 | ''' 22 | Unknown 23 | ''' 24 | ''' The start 25 | ''' 26 | Start 27 | ''' 28 | ''' The stop 29 | ''' 30 | [Stop] 31 | End Enum 32 | -------------------------------------------------------------------------------- /dotNetTips.Utility/ServiceActionResult.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : david 4 | ' Created : 05-05-2017 5 | ' 6 | ' Last Modified By : david 7 | ' Last Modified On : 05-13-2017 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter - dotNetTips.com © 2017 11 | ' 12 | ' 13 | ' ************************************************************************* 14 | 15 | ''' 16 | ''' Enum ServiceActionResult 17 | ''' 18 | Public Enum ServiceActionResult 19 | ''' 20 | ''' The not found 21 | ''' 22 | NotFound 23 | ''' 24 | ''' The running 25 | ''' 26 | Running 27 | ''' 28 | ''' The stopped 29 | ''' 30 | Stopped 31 | 32 | ''' 33 | ''' The error 34 | ''' 35 | [Error] 36 | End Enum 37 | -------------------------------------------------------------------------------- /dotNetTips.Utility/ServicesHelper.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 12-07-2016 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 03-13-2017 8 | ' *********************************************************************** 9 | ' 10 | ' ' NicheWare - David McCarter 11 | ' 12 | ' 13 | ' 14 | ' ************************************************************************* 15 | 16 | Imports System.ServiceProcess 17 | 18 | ''' 19 | ''' Class ServicesHelper. 20 | ''' 21 | Public Module ServicesHelper 22 | ''' 23 | ''' Stops the SQL server. 24 | ''' 25 | Public Sub StopSQLServer() 26 | 27 | Dim service = ServiceController.GetServices().Where(Function(p) p.ServiceName = "MSSQLSERVER").FirstOrDefault 28 | 29 | If (service IsNot Nothing AndAlso service.Status = ServiceControllerStatus.Running) Then 30 | service.Stop() 31 | End If 32 | 33 | End Sub 34 | 35 | ''' 36 | ''' Starts the SQL server. 37 | ''' 38 | Public Sub StartSqlServer() 39 | 40 | Dim service = ServiceController.GetServices().Where(Function(p) p.ServiceName = "MSSQLSERVER").FirstOrDefault 41 | 42 | If (service IsNot Nothing AndAlso service.Status = ServiceControllerStatus.Stopped) Then 43 | service.Start() 44 | End If 45 | 46 | End Sub 47 | End Module -------------------------------------------------------------------------------- /dotNetTips.Utility/Speech/Synthesis.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 05-31-2016 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 12-07-2016 8 | ' *********************************************************************** 9 | ' 10 | ' ' ' ' NicheWare - David McCarter 11 | ' 12 | ' 13 | ' 14 | ' ************************************************************************* 15 | Imports System.Threading.Tasks 16 | Namespace Speech 17 | ''' 18 | ''' Synthesis helper methods. 19 | ''' 20 | Public Module Synthesis 21 | ''' 22 | ''' _speech 23 | ''' 24 | Private ReadOnly _speech As New System.Speech.Synthesis.SpeechSynthesizer() 25 | 26 | ''' 27 | ''' Speaks the asynchronous. 28 | ''' 29 | ''' The text to speak. 30 | ''' Task(Of System.Speech.Synthesis.Prompt). 31 | Public Async Function SpeakAsync(ByVal textToSpeak As String) As Task(Of System.Speech.Synthesis.Prompt) 32 | If _speech.GetInstalledVoices.Count > 0 Then 33 | _speech.SpeakAsyncCancelAll() 34 | Return Await Task(Of System.Speech.Synthesis.Prompt).Factory.StartNew(Function() _speech.SpeakAsync(textToSpeak)) 35 | Else 36 | Return Nothing 37 | End If 38 | End Function 39 | 40 | ''' 41 | ''' Speaks the specified text to speak. 42 | ''' 43 | ''' The text to speak. 44 | Public Sub Speak(ByVal textToSpeak As String) 45 | If _speech.GetInstalledVoices.Count > 0 Then 46 | _speech.SpeakAsyncCancelAll() 47 | _speech.Speak(textToSpeak) 48 | End If 49 | End Sub 50 | End Module 51 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/StringHelper.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 05-16-2016 8 | ' *********************************************************************** 9 | ' 10 | ' ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' 14 | ' ************************************************************************* 15 | 16 | Imports System.Speech.Synthesis 17 | Imports System.Threading.Tasks 18 | Imports dotNetTips.Utility.Portable.OOP 19 | 20 | ''' 21 | ''' Text helper class. 22 | ''' 23 | Public Module StringHelper 24 | 25 | ''' 26 | ''' Converts RTF to text. 27 | ''' 28 | ''' RTF to convert. 29 | ''' Converted RTF as 30 | Public Function ConvertRtfToText(ByVal value As String) As String 31 | Encapsulation.TryValidateParam(Of ArgumentNullException)(String.IsNullOrEmpty(value) = False) 32 | 33 | Dim result As String 34 | 35 | Using converter As New System.Windows.Forms.RichTextBox() With {.Rtf = value} 36 | result = converter.Text 37 | End Using 38 | 39 | Return result 40 | 41 | End Function 42 | 43 | ''' 44 | ''' HTML encodes text. 45 | ''' 46 | ''' Text to html encode. 47 | ''' HTML encoded text. 48 | Public Function HtmlEncode(ByVal value As String) As String 49 | 'Encode using method from Web class 50 | Return Web.WebHelper.HtmlEncode(value) 51 | 52 | End Function 53 | 54 | ''' 55 | ''' Speak text as an asynchronous operation. 56 | ''' 57 | ''' The text. 58 | Public Async Sub SpeakAsync(ByVal text As String) 59 | 60 | If String.IsNullOrWhiteSpace(text) Then 61 | Exit Sub 62 | End If 63 | 64 | Await Speech.SpeakAsync(text) 65 | End Sub 66 | 67 | ''' 68 | ''' Url encodes text. 69 | ''' 70 | ''' Text to url encode. 71 | ''' Uri. 72 | Public Function UrlEncode(ByVal value As String) As Uri 73 | Encapsulation.TryValidateParam(Of ArgumentNullException)(String.IsNullOrEmpty(value) = False) 74 | 75 | Return New Uri(Web.UrlEncode(value)) 76 | 77 | End Function 78 | 79 | End Module -------------------------------------------------------------------------------- /dotNetTips.Utility/Threading/ThreadHelper.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 06-26-2017 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 07-27-2017 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter - dotNetTips.com © 2017 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | 15 | Imports System.Text 16 | 17 | Namespace Threading 18 | ''' 19 | ''' Threading methods. 20 | ''' 21 | Public Module ThreadHelper 22 | ''' 23 | ''' Gets the thread id. 24 | ''' 25 | ''' Thread id. 26 | Public Function GetThreadId() As Integer 27 | Return GetCurrentThreadId() 28 | End Function 29 | 30 | ''' 31 | ''' Gets the name of the current process. 32 | ''' 33 | ''' System.String. 34 | Public Function GetProcessName() As String 35 | Dim buffer As New StringBuilder(&H400) 36 | Return If(UnsafeNativeMethods.GetModuleFileName(UnsafeNativeMethods.GetModuleHandle(Nothing), buffer, buffer.Capacity) > 0, buffer.ToString(), String.Empty) 37 | End Function 38 | 39 | End Module 40 | 41 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/Threading/WorkItemEventArgs.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable.Windows 3 | ' Author : David McCarter 4 | ' Created : 04-15-2016 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 01-23-2016 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Namespace Threading 15 | ''' 16 | ''' Class WorkItemEventArgs. This class cannot be inherited. 17 | ''' 18 | ''' 19 | Public NotInheritable Class WorkItemEventArgs 20 | Inherits EventArgs 21 | ''' 22 | ''' Gets or sets the identifier. 23 | ''' 24 | ''' The identifier. 25 | Public Property Id As Guid 26 | End Class 27 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/Threading/WorkItemStatus.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility.Portable.Windows 3 | ' Author : David McCarter 4 | ' Created : 04-15-2016 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 01-23-2016 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Namespace Threading 15 | ''' 16 | ''' Enum WorkItemStatus 17 | ''' 18 | Public Enum WorkItemStatus 19 | ''' 20 | ''' Undetermined 21 | ''' 22 | Undetermined 23 | ''' 24 | ''' Completed 25 | ''' 26 | Completed 27 | ''' 28 | ''' Queued 29 | ''' 30 | Queued 31 | ''' 32 | ''' Executing 33 | ''' 34 | Executing 35 | ''' 36 | ''' Aborted 37 | ''' 38 | Aborted 39 | End Enum 40 | 41 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/UI/Web/TextBox.vb: -------------------------------------------------------------------------------- 1 | ' *********************************************************************** 2 | ' Assembly : dotNetTips.Utility 3 | ' Author : David McCarter 4 | ' Created : 12-04-2013 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 12-04-2013 8 | ' *********************************************************************** 9 | ' 10 | ' David McCarter Consulting. All rights reserved. 11 | ' 12 | ' 13 | ' *********************************************************************** 14 | Namespace UI.Web 15 | ''' 16 | ''' TextBox for ASP.NET 17 | ''' 18 | ''' Fixes the Max length issue. 19 | Public Class TextBox 20 | Inherits System.Web.UI.WebControls.TextBox 21 | 22 | ''' 23 | ''' Processes the post back data for the control. 24 | ''' 25 | ''' The index within the posted collection that references the content to load. 26 | ''' The collection posted to the server. 27 | ''' 28 | ''' true if the posted content is different from the last posting; otherwise, false. 29 | ''' 30 | Protected Overrides Function LoadPostData(ByVal postDataKey As String, ByVal postCollection As Specialized.NameValueCollection) As Boolean 31 | 'Encapsulation.TryValidateParam(Of ArgumentNullException)(String.IsNullOrWhiteSpace(postDataKey) = False) 32 | 'Encapsulation.TryValidateParam(Of ArgumentNullException)(postCollection IsNot Nothing) 33 | 34 | Page.ClientScript.ValidateEvent(Me.UniqueID, String.Empty) 35 | 36 | Dim oldText As String = Me.Text 37 | Dim newText As String = postCollection.Item(postDataKey) 38 | 39 | If (newText.Length > Me.MaxLength) Then 40 | newText = newText.Substring(0, Me.MaxLength) 41 | End If 42 | 43 | If (Not Me.ReadOnly AndAlso Not oldText.Equals(newText, StringComparison.Ordinal)) Then 44 | Me.Text = newText 45 | Return True 46 | End If 47 | 48 | Return False 49 | 50 | End Function 51 | 52 | End Class 53 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/UI/Windows/ComboBoxListType.vb: -------------------------------------------------------------------------------- 1 | '*********************************************************************** 2 | ' Assembly : dotNetTips 3 | ' Author : David McCarter 4 | ' Created : 06-09-2009 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 06-09-2009 8 | ' Description : 9 | ' 10 | ' Copyright : (c) dotNetTips.com. All rights reserved. 11 | '*********************************************************************** 12 | Imports System.Drawing 13 | Imports System.Windows.Forms 14 | 15 | Namespace UI.Windows 16 | ''' 17 | ''' Types for ComboBox list. 18 | ''' 19 | Public Enum ComboBoxListType 20 | ''' 21 | ''' Do not auto load date. 22 | ''' 23 | ''' 24 | None 25 | ''' 26 | ''' Auto load US States. 27 | ''' 28 | ''' 29 | UsStates 30 | ''' 31 | ''' Auto load Countries. 32 | ''' 33 | ''' 34 | Countries 35 | End Enum 36 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/UI/Windows/FormHelper.vb: -------------------------------------------------------------------------------- 1 | '*********************************************************************** 2 | ' Assembly : dotNetTips 3 | ' Author : David McCarter 4 | ' Created : 12-10-2008 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 02-26-2008 8 | ' Description : 9 | ' 10 | ' Copyright : (c) dotNetTips.com. All rights reserved. 11 | '*********************************************************************** 12 | Imports System.Windows.Forms 13 | Imports dotNetTips.Utility.Portable.OOP 14 | 15 | Namespace UI.Windows 16 | 17 | ''' 18 | ''' Form helper class. 19 | ''' 20 | Public NotInheritable Class FormHelper 21 | 22 | ''' 23 | ''' Clears the text boxes. 24 | ''' 25 | ''' The parent Control. 26 | Public Shared Sub ClearTextBoxes(ByVal parent As Control) 27 | Encapsulation.TryValidateParam(Of ArgumentNullException)(parent IsNot Nothing) 28 | 29 | For Each tempControl As Control In parent.Controls 30 | If tempControl.Controls.Count > 0 Then 31 | ClearTextBoxes(tempControl) 32 | ElseIf tempControl.GetType Is GetType(TextBox) Then 33 | DirectCast(tempControl, TextBox).Text = String.Empty 34 | End If 35 | Next 36 | End Sub 37 | 38 | ''' 39 | ''' Selects the text of a control. 40 | ''' 41 | ''' The control to select. 42 | Public Shared Sub SelectControlText(ByVal control As System.Windows.Forms.TextBox) 43 | Encapsulation.TryValidateParam(Of ArgumentNullException)(control IsNot Nothing) 44 | 45 | If control.Text.Length > 0 Then 46 | control.Select(0, control.Text.Length) 47 | End If 48 | 49 | End Sub 50 | 51 | Private Sub New() 52 | End Sub 53 | 54 | End Class 55 | 56 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/UI/Windows/TextBoxValidation.vb: -------------------------------------------------------------------------------- 1 | '*********************************************************************** 2 | ' Assembly : dotNetTips 3 | ' Author : David McCarter 4 | ' Created : 06-09-2009 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 06-09-2009 8 | ' Description : 9 | ' 10 | ' Copyright : (c) dotNetTips.com. All rights reserved. 11 | '*********************************************************************** 12 | Imports System.Drawing 13 | 14 | Namespace UI.Windows 15 | ''' 16 | ''' Type of auto validation for a TextBox. 17 | ''' 18 | Public Enum TextBoxValidation 19 | ''' 20 | ''' Turns off validation. 21 | ''' 22 | ''' 23 | None 24 | ''' 25 | ''' Validates credit card number. 26 | ''' 27 | ''' 28 | CreditCard 29 | ''' 30 | ''' Custom validation. 31 | ''' 32 | ''' 33 | Custom 34 | ''' 35 | ''' Validates date. 36 | ''' 37 | ''' 38 | [Date] 39 | ''' 40 | ''' Validates domain address. 41 | ''' 42 | ''' 43 | Domain 44 | ''' 45 | ''' Validates email address. 46 | ''' 47 | ''' 48 | Email 49 | ''' 50 | ''' Validates file path. 51 | ''' 52 | ''' 53 | FilePath 54 | ''' 55 | ''' Validates first and last name. 56 | ''' 57 | ''' 58 | FirstLastName 59 | ''' 60 | ''' Validates ISBN number. 61 | ''' 62 | ''' 63 | Isbn 64 | ''' 65 | ''' Validates number. 66 | ''' 67 | ''' 68 | Number 69 | ''' 70 | ''' Validates US phone number. 71 | ''' 72 | ''' 73 | Phone 74 | ''' 75 | ''' Validates scientific number. 76 | ''' 77 | ''' 78 | Scientific 79 | ''' 80 | ''' Validates US Social Security number. 81 | ''' 82 | ''' 83 | SocialSecurity 84 | ''' 85 | ''' Validates a string. 86 | ''' 87 | ''' 88 | [String] 89 | ''' 90 | ''' Validates a temperature. 91 | ''' 92 | ''' 93 | Temperature 94 | ''' 95 | ''' Validates a URL address. 96 | ''' 97 | ''' 98 | Url 99 | ''' 100 | ''' Validates a US zip code. 101 | ''' 102 | ''' 103 | ZipCode 104 | End Enum 105 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/UnsafeNativeMethods.vb: -------------------------------------------------------------------------------- 1 | '*********************************************************************** 2 | ' Assembly : dotNetTips 3 | ' Author : David McCarter 4 | ' Created : 12-10-2008 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 03-24-2008 8 | ' Description : 9 | ' 10 | ' Copyright : (c) dotNetTips.com. All rights reserved. 11 | '*********************************************************************** 12 | Imports System.Runtime.InteropServices 13 | 14 | Friend Module UnsafeNativeMethods 15 | 16 | Friend Const HwndTopmost As Int32 = -1 17 | Friend Const SwpNoactivate As Int32 = &H10 18 | Friend Const SwpShowwindow As Int32 = &H40 19 | Friend Const SWShownoactivate As Int32 = 4 20 | 21 | #Region "Task Bar Location Support Routines" 22 | 23 | _ 24 | Friend Structure RECT 25 | Public Left As Int32 26 | Public Top As Int32 27 | Public Right As Int32 28 | Public Bottom As Int32 29 | 30 | Public Overloads Overrides Function GetHashCode() As Integer 31 | Throw New NotImplementedException() 32 | End Function 33 | 34 | Public Overloads Overrides Function Equals(obj As [Object]) As Boolean 35 | Throw New NotImplementedException() 36 | End Function 37 | End Structure 38 | 39 | Friend Const AbmGettaskbarpos As Long = &H5 40 | Friend Const AbmGetstate As Long = &H4 41 | Friend Const AbeTop As Long = 1 42 | Friend Const AbeLeft As Long = 0 43 | Friend Const AbeRight As Long = 2 44 | Friend Const AbeBottom As Long = 3 45 | 46 | #End Region 47 | 48 | #Region "DPAPI Encryption" 49 | 50 | Friend Const CryptprotectUIForbidden As Integer = &H1 51 | Friend Const CryptprotectLocalMachine As Integer = &H4 52 | 53 | _ 54 | Friend Structure DataBlob 55 | Public CbData As Integer 56 | Public PBData As IntPtr 57 | 58 | Public Overloads Overrides Function GetHashCode() As Integer 59 | ' dotNetTips.Utility.Portable.Windows.General.GetInstanceHashCode(Me) 60 | End Function 61 | 62 | Public Overloads Overrides Function Equals(obj As [Object]) As Boolean 63 | ' dotNetTips.Utility.Portable.Windows.General.DoesObjectEqualInstance(obj, Me) 64 | End Function 65 | End Structure 66 | 67 | Friend Const SwpNosize As Integer = 1 68 | Friend Const WMCtlcolorlistbox As UInt32 = 308 69 | 70 | #End Region 71 | 72 | _ 73 | Friend Function GetCurrentThreadId() As Integer 74 | End Function 75 | 76 | _ 77 | Friend Function GetModuleHandle(ByVal moduleName As String) As IntPtr 78 | End Function 79 | 80 | 81 | Friend Function GetModuleFileName(<[In]()> ByVal hModule As IntPtr, ByVal lpFilename As System.Text.StringBuilder, <[In](), MarshalAs(UnmanagedType.U4)> ByVal nSize As Integer) As Integer 82 | End Function 83 | 84 | 85 | Friend Function GetShortPathName(ByVal lpszLongPath As String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal cchBuffer As Integer) As Integer 86 | End Function 87 | 88 | End Module -------------------------------------------------------------------------------- /dotNetTips.Utility/ValidationHelper.vb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealDotNetDave/dotNetTips.Utility/ddaa29e9fbe26578594071f7416ff55ae70d0568/dotNetTips.Utility/ValidationHelper.vb -------------------------------------------------------------------------------- /dotNetTips.Utility/Web/WebServiceAction.vb: -------------------------------------------------------------------------------- 1 | '*********************************************************************** 2 | ' Assembly : dotNetTips 3 | ' Author : David McCarter 4 | ' Created : 10-10-2008 5 | ' 6 | ' Last Modified By : David McCarter 7 | ' Last Modified On : 10-26-2008 8 | ' Description : 9 | ' 10 | ' Copyright : (c) dotNetTips.com. All rights reserved. 11 | '*********************************************************************** 12 | Namespace Web 13 | ''' 14 | ''' Determines what action to take on the web server. 15 | ''' 16 | ''' 17 | Public Enum WebServiceAction 18 | ''' 19 | ''' Gets the current mode. 20 | ''' 21 | GetCurrentMode 22 | ''' 23 | ''' Pauses the service. 24 | ''' 25 | PauseService 26 | ''' 27 | ''' Resumes the service 28 | ''' 29 | ResumeService 30 | ''' 31 | ''' Starts the service. 32 | ''' 33 | StartService 34 | ''' 35 | ''' Stops the service. 36 | ''' 37 | StopService 38 | End Enum 39 | End Namespace -------------------------------------------------------------------------------- /dotNetTips.Utility/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /dotNetTips.Utility/comments.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | dotNetTips.Utility.Portable 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /dotNetTips.Utility/dotNetTips.Utility.vbproj.CodeItRight.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | *.min.js 4 | jquery*.js 5 | 6 | 7 | -------------------------------------------------------------------------------- /dotNetTips.Utility/dotNetTips.Utility.vbproj.GhostDoc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | *.min.js 4 | jquery*.js 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | ..\OutputBin\Help 17 | true 18 | MemberName 19 | 20 | 21 | true 22 | false 23 | false 24 | false 25 | 26 | 27 | true 28 | false 29 | true 30 | false 31 | true 32 | true 33 | false 34 | 35 | 36 | 37 | true 38 | true 39 | true 40 | 41 | true 42 | dotNetTips.com 43 | David McCarter 44 | 45 | 46 | 47 | 48 | 49 | dotNetTips.Utility.Portable 50 | dotNetTips.Utility.Portable.Windows 51 | dotNetTips.Utility 52 | 53 | 54 | 55 | 56 | False 57 | True 58 | 59 | 60 | -------------------------------------------------------------------------------- /dotNetTips.Utility/package.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | $id$ 6 | 7 | $version$ 8 | 9 | 10 | $author$ 11 | $author$ 12 | 17 | false 18 | 19 | $description$ 20 | 21 | 22 | $copyright$ 23 | 24 | 25 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /dotNetTips.sln.CodeItRight.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | *.min.js 4 | jquery*.js 5 | 6 | 7 | -------------------------------------------------------------------------------- /dotNetTips.sln.GhostDoc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | *.min.js 4 | jquery*.js 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | ..\..\..\Help 17 | true 18 | MemberName 19 | 20 | 21 | true 22 | false 23 | false 24 | false 25 | false 26 | 27 | 28 | true 29 | false 30 | true 31 | false 32 | true 33 | true 34 | false 35 | 36 | 37 | 38 | true 39 | true 40 | true 41 | 42 | true 43 | dotNetTips.com 44 | David McCarter 45 | 46 | 47 | 48 | 49 | 50 | dotNetTips.Utility.Portable 51 | dotNetTips.Utility.Portable.Windows 52 | dotNetTips.Utility 53 | 54 | 55 | 56 | 57 | False 58 | 59 | 60 | --------------------------------------------------------------------------------