Skip to content

Instantly share code, notes, and snippets.

@LSTANCZYK
LSTANCZYK / code.cs
Last active November 21, 2017 20:26
Formats XML string with indentations for easier reading
private static String FormatXml(string xml)
{
String Result = "";
MemoryStream mStream = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(mStream, Encoding.Unicode);
XmlDocument document = new XmlDocument();
try
{
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.Serialization.Json;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.Text;
using System.Threading;

yUML Test On GitHub

yUML is a simple tool for embedding UML diagrams in wikis and blogs without needing any UML or diagramming tools.

Here's an idea of how it could be used in your repository readme.markdown or wiki.

View the RAW source to see how images are made.

Example

using System.Collections.Generic;
// ReSharper disable once CheckNamespace
namespace System.Diagnostics
{
/// <summary> A color console trace listener. </summary>
/// <seealso cref="T:System.Diagnostics.ConsoleTraceListener"/>
/// <remarks>
///
///
@LSTANCZYK
LSTANCZYK / AttributesHelper.cs
Created September 26, 2017 22:41
Runtime Creates derived type and adds attributes
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using FastDeepCloner;
namespace CHR.API.Provisioning.ATT.Web.Tests
{
[SuppressMessage("ReSharper", "UnusedMember.Global")]
@LSTANCZYK
LSTANCZYK / ValidXml.cs
Created September 25, 2017 02:16
Data annotation attribute to verify that string is a valid XML
using System.ComponentModel.DataAnnotations;
using System.Xml;
namespace CHR.API.Provisioning.ATT.BusinessLogic.DataValidation
{
/// <inheritdoc />
/// <summary>
/// Data annotation attribute to verify that string is a valid XML
/// </summary>
public class ValidXml : ValidationAttribute
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class RequiredIfEmptyAttribute : ValidationAttribute, IClientValidatable
{
private readonly string[] _dependentProperties;
public RequiredIfEmptyAttribute(params string[] dependentPropertieses)
{
_dependentProperties = dependentPropertieses;
}
@LSTANCZYK
LSTANCZYK / AllowedValuesAttribute.cs
Created September 25, 2017 01:55 — forked from Grinderofl/AllowedValuesAttribute.cs
String property allowed values with dropdown box and MVC model validation
// Usage:
// [AttributeUsage("Option1", "Option2", "Option3")]
// public string MyTestAttribute { get; set; }
//
// In view:
// @Html.DropDownListFor(x => x.MyTestAttribute)
//
// Result:
// Dropdown list with 3 options.
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class DateComparerAttribute : ValidationAttribute, IClientValidatable
{
/// <summary>
/// If set will use DateTime.AddDays to specify the Min Valid Date
/// </summary>
public double MinDateAddDaysFromNow
{
get { return _minDateAddDaysFromNow; }
set
@LSTANCZYK
LSTANCZYK / CreditCardAttribute.cs
Created September 25, 2017 01:55 — forked from bjcull/CreditCardAttribute.cs
Credit Card Validator Attribute for ASP.NET MVC 3
/// ASP.NET MVC 3 Credit Card Validator Attribute
/// by Ben Cull - 4 November 2010
///
/// With special thanks to:
/// Thomas @ Orb of Knowledge - http://orb-of-knowledge.blogspot.com/2009/08/extremely-fast-luhn-function-for-c.html
/// For the Extremely fast Luhn algorithm implementation
///
/// And Paul Ingles - http://www.codeproject.com/KB/validation/creditcardvalidator.aspx
/// For a timeless blog post on credit card validation