This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class WinForms | |
{ | |
public static Form FindMainForm() | |
{ | |
return Form.FromHandle(Process.GetCurrentProcess().MainWindowHandle) as Form; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <devdoc> | |
/// Based on Andrey Markeev's example http://sharepoint.stackexchange.com/a/28522 | |
/// </devdoc> | |
public static class SPFieldMultiChoiceExtensions | |
{ | |
public const string MultiValueSeparator = ";#"; | |
private const string ValueAttributeName = "Value"; | |
private const string MappingsElementName = "MAPPINGS"; | |
private const string MappingElementName = "MAPPING"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// On your page with SaveButton you could do the following trick | |
// (in my case save button is added in DataFormWebPart's XSL markup): | |
SPContext itemContext; | |
DataFormWebPart dataForm; // from designer's code behind | |
void Page_Init(object sender, EventArgs e) | |
{ | |
// NOTE: by some reason ItemContexts of controls in DFWP are differ, | |
// so only SaveButton's OnSaveHandler is invoked |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class LinqExtensions | |
{ | |
/// <summary> | |
/// Final method, instructing to iterate through sequence elements immediately. | |
/// </summary> | |
/// <typeparam name="T">Type of sequence element.</typeparam> | |
/// <param name="source">Processed sequence.</param> | |
public static void Do<T>(this IEnumerable<T> source) | |
{ | |
using (var e = source.GetEnumerator()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
/* | |
COPYRIGHT | |
Character transliteration tables: | |
Copyright 2001, Sean M. Burke <sburke@cpan.org>, all rights reserved. | |
Python code: | |
Copyright 2009, Tomaz Solc <tomaz@zemanta.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class StringExtensions | |
{ | |
static readonly WeakLazy<char[]> InvalidFileNameChars = new WeakLazy<char[]>(Path.GetInvalidFileNameChars); | |
static readonly WeakLazy<char[]> InvalidPathChars = new WeakLazy<char[]>(Path.GetInvalidPathChars); | |
[Pure] | |
public static bool IsValidFileName(this string name) | |
{ | |
return !string.IsNullOrEmpty(name) && name.IndexOfAny(InvalidFileNameChars.Value) == -1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class BytesHelper | |
{ | |
public static bool Equals(byte[] arrayA, byte[] arrayB) | |
{ | |
Contract.Requires<ArgumentNullException>(arrayA != null); | |
Contract.Requires<ArgumentNullException>(arrayB != null); | |
var length = arrayA.Length; | |
return length == arrayB.Length && UnsafeEquals(arrayA, 0, arrayB, 0, length); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class WeakLazy<T> where T : class | |
{ | |
protected readonly Func<T> valueFactory; | |
internal protected WeakLazy(Func<T> valueFactory) | |
{ | |
Contract.Requires<ArgumentNullException>(valueFactory != null); | |
this.valueFactory = valueFactory; | |
} | |
public abstract T Value { get; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class InterlockedFactory | |
{ | |
public static T GetOrCreate<T>(ref T value, Func<T> valueFactory) where T : class | |
{ | |
if (ReferenceEquals(value, null)) | |
{ | |
if (valueFactory == null) | |
{ | |
throw new ArgumentNullException("valueFactory"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<!-- USAGE EXAMPLE | |
<PropertyGroup> | |
<MyScript><![CDATA[ | |
function Foo() | |
{ | |
$targetFileName = args[0] | |
$targetPdbName = args[1] | |
$targetPath = args[2] |
OlderNewer