ADP GUID to .NET GUID Converter

ADP GUID to .NET GUID Converter

Below is a link to download a quick and dirty hack to automatically convert ADP GUIDs to .NET GUIDs. Copy GUID from ADP site and paste into the top field...then click convert. Thank you to Prashanth Reddy for creating the logic code and making it available for all. I just packaged and compiled it. Written in C#; needs .NET 3.0 to run. Will catch invalid input with alert to keep CLR from crashing. Push Enter key to convert or Esc key to exit. IT'S BARE ESSENTIALS ONLY. Best to all. http://southside-solutions.com/data_storage/ADP_GUID_Converter.zip -CCK
4 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

Thanks for the contribution CCK

You are very welcome. I appreciate the thanks. Figured I would help solve a common problem a lot of us have - GUID conversion.

-CCK

Your excellent example had me thinking about the code implementation. I wrote a simple method that converts a standard ATOM SDK Guid to a .NET Guid type.

I have demonstrated the ToGuid method in the form of a simple .NET Console Project. Feel free to Download the project or see the pertinent portion below

Download URL 1: http://WWW.400KB.COM/go.php?ref=vHAYJuWpYfadbN6
Download URL 2: http://www.quickfilepost.com/download.do?get=2d87158d3532516cc349d580f7cfba37

///
/// Convert a native ATOM SDK GUID to a .NET Guid type
///
/// ATOM SDK GUID
/// .NET Guid equivalent
private static Guid ToGuid(string nativeGuid)
{
// Check for null/empty guid string
if (String.IsNullOrEmpty(nativeGuid))
{
throw new ApplicationException("Empty or null guid string");
}

// Sanitize input by removing unwanted characters
string[] strReplaceStrings = new string[] { "0x", " ", ",", "\r", "\n" };
for (int i = 0; i < strReplaceStrings.Length; i++)
{
nativeGuid = nativeGuid.Replace(strReplaceStrings[i], String.Empty);
}

// Ensure we have a viable result to convert
if (nativeGuid.Length != 32)
{
throw new ApplicationException("Invalid guid string");
}

// Byte conversion
byte[] baBytes = new byte[nativeGuid.Length / 2];
for (int i = 0; i < baBytes.Length; i++)
{
bool bRes = byte.TryParse(nativeGuid.Substring(i * 2, 2),
NumberStyles.HexNumber,
(IFormatProvider)null,
out baBytes[(3 - (i % 4)) + ((i / 4) * 4)]);

// Ensure we could parse the string
if (!bRes)
{
throw new ApplicationException("Unable to parse guid string");
}
}

// New Guid
Guid guidResult = new Guid(baBytes);
return guidResult;
}

Laisser un commentaire

Veuillez ouvrir une session pour ajouter un commentaire. Pas encore membre ? Rejoignez-nous dès aujourd’hui