Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
fuss:libopenmetaverse [2015/01/09 05:34]
127.0.0.1 external edit
fuss:libopenmetaverse [2017/02/22 18:30] (current)
Line 1: Line 1:
 +====== Extract Full Avatar Name ======
  
 +libopenmetaverse uses different possible avatar name formats when passing avatar names. For example, an avatar name can be in one of the following formats:
 +  * ''​FirstName LastName''​
 +  * ''​FirstName.LastName''​
 +  * ''​FirstName''​ - in which case, the last name is ''​Resident''​
 +
 +
 +The following brief LINQ query will help you resolve all these names to a list of two elements:
 +<code csharp>
 +string avatarName = "​Snooky Smexy";​
 +// ...
 +List<​string>​ name =
 +    new List<​string>​(Regex.Matches(avatarName,​ @"​^(?<​first>​.*?​)([\s\.]|$)(?<​last>​.*?​)$"​)
 +        .Cast<​Match>​()
 +        .ToDictionary(o => new[]
 +        {
 +            o.Groups["​first"​].Value,​
 +            o.Groups["​last"​].Value
 +        }).SelectMany(o => new[] {o.Key[0], !string.IsNullOrEmpty(o.Key[1]) ? o.Key[1] : "​Resident"​}));​
 +Console.WriteLine(name.First());​
 +Console.WriteLine(name.Last());​
 +Console.ReadKey();​
 +</​code>​
 +
 +where the list ''​name''​ will have the first element set to the first name of the avatar and the last name set to the last name of the avatar (or ''​Resident''​) if no last name was found.

fuss/libopenmetaverse.txt ยท Last modified: 2017/02/22 18:30 (external edit)

Access website using Tor Access website using i2p


For the copyright, license, warranty and privacy terms for the usage of this website please see the license, privacy and plagiarism pages.