Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed XElementExtensions to use (prefix,name) arguments
- Loading branch information
1 parent
9079ed3
commit 0936737
Showing
22 changed files
with
502 additions
and
20 deletions.
There are no files selected for viewing
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<root xmlns:c="http://schemas.next.lib/tests"> | ||
<c:child> | ||
<c:sub>Foo</c:sub> | ||
</c:child> | ||
<c:child> | ||
<c:sub>Bar</c:sub> | ||
</c:child> | ||
</root> |
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
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
File renamed without changes.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace NExtLib.Async | ||
{ | ||
[Serializable] | ||
public class AsyncException : Exception | ||
{ | ||
public AsyncException() { } | ||
public AsyncException(string message) : base(message) { } | ||
public AsyncException(string message, Exception inner) : base(message, inner) { } | ||
protected AsyncException( | ||
System.Runtime.Serialization.SerializationInfo info, | ||
System.Runtime.Serialization.StreamingContext context) | ||
: base(info, context) { } | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace NExtLib.Async | ||
{ | ||
public static class Future | ||
{ | ||
/// <summary> | ||
/// Creates an instance of <see cref="Future`1"/>. | ||
/// </summary> | ||
/// <typeparam name="T">The type of value represented by the Future.</typeparam> | ||
/// <param name="func">The <see cref="Func`1"/> delegate that will return the value.</param> | ||
/// <returns>A new instance of <see cref="Future`1"/>.</returns> | ||
/// <remarks>This method exists only to provide type-inference convenience.</remarks> | ||
public static Future<T> Create<T>(Func<T> func) | ||
{ | ||
return new Future<T>(func); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace NExtLib.Async | ||
{ | ||
public class Future<T> | ||
{ | ||
private readonly Action _action; | ||
private readonly IAsyncResult _asyncResult; | ||
private readonly object _lock = new object(); | ||
private bool _ended; | ||
private T _value; | ||
private Exception _error; | ||
|
||
public Future(Func<T> func) | ||
{ | ||
if (func == null) throw new ArgumentNullException("func"); | ||
|
||
_action = () => Run(func); | ||
_asyncResult = _action.BeginInvoke(null, null); | ||
} | ||
|
||
public T Value | ||
{ | ||
get | ||
{ | ||
JoinAction(); | ||
|
||
if (_error != null) throw new AsyncException(Properties.Resources.Async_AsyncExceptionMessage, _error); | ||
return _value; | ||
} | ||
} | ||
|
||
private void Run(Func<T> func) | ||
{ | ||
try | ||
{ | ||
_value = func(); | ||
} | ||
catch (Exception ex) | ||
{ | ||
if (ex is SystemException) throw; | ||
|
||
_error = ex; | ||
_value = default(T); | ||
} | ||
} | ||
|
||
private void JoinAction() | ||
{ | ||
if (!_ended) | ||
{ | ||
lock (_lock) | ||
{ | ||
if (!_ended) | ||
{ | ||
_action.EndInvoke(_asyncResult); | ||
_ended = true; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace NExtLib | ||
{ | ||
public static class Func | ||
{ | ||
public static Func<TIn, TOut> NoOp<TIn, TOut>() | ||
where TIn : TOut | ||
{ | ||
return (x) => x; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace System.Linq | ||
{ | ||
public static class EnumerableOfKeyValuePairExtensions | ||
{ | ||
public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> source) | ||
{ | ||
Dictionary<TKey, TValue> dictionary; | ||
|
||
if ((dictionary = source as Dictionary<TKey, TValue>) == null) | ||
{ | ||
dictionary = source.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); | ||
} | ||
|
||
return dictionary; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.