kamagra how much to take

Creating SecurityElement Objects from FileStream’s

When developing security tooling it is frequent that you will want to create new SecurityElement‘s for security object encoding.

To do this, you can use the below CreateSecurityElementSegment method, which simple takes a string parameter representing the path to the file for the FileStream object hydration.

private static SecurityElement CreateSecurityElementSegment(string path)
FileStream stream = null;
stream = new FileStream(path, FileMode.Open, FileAccess.Read);
catch (Exception exception)
// Do stuff
var encodingArray = new[] { Encoding.UTF8, Encoding.ASCII, Encoding.Unicode };
bool flag = false;
SecurityElement element = null;
for (int i = 0; !flag && (i < encodingArray.Length); i++) { try { if (stream != null) { stream.Position = 0L; element = SecurityElement.FromString(new StreamReader(stream, encodingArray[i], true).ReadToEnd()); } flag = true; } catch (Exception exception) { // do stuff } } if (stream != null) { stream.Close(); } if (!flag) { throw new Exception(“Security Exception”); } return element; } [/csharp]


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>