![]() ![]() PSMDTAG:FAQ: How do I base64 encode/decode a string? TrimStart Method System.String TrimStart(Params Char trimChars)Ĭhars ParameterizedProperty System.Char Chars(Int32 index) TrimEnd Method System.String TrimEnd(Params Char trimChars) Trim Method System.String Trim(Params Char trimChars), System.String Trim() Once I do that, these properties are available to any STRING and can be discovered via Get-Member:ĬompareTo Method System.Int32 CompareTo(Object value), System.Int32 CompareTo(String strB)Ĭontains Method System.Boolean Contains(String value)ĬopyTo Method System.Void CopyTo(Int32 sourceIndex, Char destination, Int32 destinationIndex, Int32 count)ĮndsWith Method System.Boolean EndsWith(String value), System.Boolean EndsWith(String value, StringComparison comparisonType), System.Boolean EndsWith(String value, Boolean ignoreCase, CultureInfo culture) In my profile I load this file via the command: ::UNICODE.GetString(::FromBase64String($this)) ::ToBase64String(::UNICODE.GetBytes($this)) I then encoded the following in a file called My.Types.Mshxml In this case, I decided that I would extend SYSTEM.STRING as that was the most general purpose type for this function. When doing a type extension, you first need to decide what TYPE you are going to extend. Let me show you how to do this function as a type-extension and highlight the benefits of this approach. ![]() One of the huge benefits of type extensions is discoverability. Whenever you are adding some functions, you should make a conscious decision about whether those functions are best exposed as a “function” or as a “type extension”.īoth of these mechanisms are great and have their purpose but my observation is that people are not using type-extensions as much as they should. I was about to include it as-is into my profile and decided that there was a better way to do this. This is something that I need occassionally and I can never remember how to do it. I particularly liked their entry on how to Base64 encode a file. You should visit their site and let them know what type of scripts would be useful to you. This sight is focused on Monad and MSH and is starting a collection of scripts at: .
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |