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
/// <summary> | |
/// A simple wrapper of a <see cref="Lazy"/> type that require a <see cref="IDisposable"/> object | |
/// to evaluate its value. The resulting object is also disposable. | |
/// | |
/// Note: provides only 3 constructors. The 3 of <see cref="Lazy"/> that depends on the default | |
/// constructure does not make sense here. | |
/// </summary> | |
/// <typeparam name="T">The type of the disposable object</typeparam> | |
/// <typeparam name="R">The type of the lazily evaluated value</typeparam> | |
public class DisposableLazy<T, R> : IDisposable where T:IDisposable |
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
class CPSExpressionVisitor : ExpressionVisitor | |
{ | |
delegate R SFunc<T, R>(T v); | |
delegate SFunc<T2, R> SFunc<T1, T2, R>(T1 v); | |
delegate SFunc<T2, T3, R> SFunc<T1, T2, T3, R>(T1 v); | |
delegate SFunc<T2, T3, T4, R> SFunc<T1, T2, T3, T4, R>(T1 v); | |
delegate dynamic FDynamic(FDynamic s); | |
private static FDynamic ConstFDynamic<T>(T v) |
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
<UserControl x:Class="WPFZoomText.ZoomViewer" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | |
xmlns:local="clr-namespace:WPFZoomText" | |
mc:Ignorable="d" | |
d:DesignHeight="500" d:DesignWidth="500"> | |
<Grid Background="Black" MouseDown="Grid_MouseDown" MouseUp="Grid_MouseUp" MouseWheel="Grid_MouseWheel" | |
SizeChanged="Grid_SizeChanged"> |
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.Threading; | |
using System.Threading.Tasks; | |
using System.Windows; | |
using System.Windows.Input; | |
using System.Windows.Media; | |
using System.Windows.Threading; | |
namespace WPFZoomTest | |
{ |
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 class UIThreadDrawingCanvas : FrameworkElement, IZoomFit | |
{ | |
public static readonly DependencyProperty ContentDomainProperty = DependencyProperty.Register( | |
"ContentDomain", typeof(Rect), typeof(UIThreadDrawingCanvas)); | |
public static readonly DependencyProperty RenderRequestProperty = DependencyProperty.Register( | |
"RenderRequest", typeof(ContextDrawer), typeof(UIThreadDrawingCanvas), | |
new FrameworkPropertyMetadata(null, RenderRequestChanged)); | |
public static readonly DependencyProperty BackgroundProperty = DependencyProperty.Register( | |
"Background", typeof(Brush), typeof(UIThreadDrawingCanvas), | |
new FrameworkPropertyMetadata(Brushes.Transparent)); |
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 NotificationExtensions | |
{ | |
private static string PropertyFromMemberExpression(MemberExpression memberExpression) | |
{ | |
var pinfo = memberExpression.Member as PropertyInfo; | |
if (pinfo != null) | |
{ | |
return pinfo.Name; | |
} | |
var finfo = memberExpression.Member as FieldInfo; |
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 EmptyHandlers | |
{ | |
public static void EmptyHandler<T, U>(T s, U e) { } | |
} | |
public static class EntityExt | |
{ | |
private static string PropertyFromMemberExpression(MemberExpression memberExpression) | |
{ | |
var pinfo = memberExpression.Member as PropertyInfo; |
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
module PushParser where | |
import Data.Monoid | |
import Control.Applicative | |
import Control.Monad | |
{- | |
t is the type of tokens, r is the type of results. | |
Empty result set means the parsing do not have a result at the moment. |
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
Name | Call mode | State mutate | Copy | Other ability | Traits can be implemented | Traits implemented | |
---|---|---|---|---|---|---|---|
Function | Parallel/reentranted | No | Yes | Cast to fn | Fn + FnMut + FnOnce + Copy | Fn + FnMut + FnOnce + Copy | |
ClosureMutCopy | Parallel/reentranted | Yes | Yes | State snapshot | Fn + FnMut(multiple) + FnOnce + Copy | FnMut + FnOnce + Copy | |
ClosureCopy | Parallel/reentranted | No/Meaningless | Yes | N/A | Fn + FnMut + FnOnce + Copy | Fn + FnMut + FnOnce + Copy | |
ClosureRef | Parallel/reentranted | No | No | N/A | Fn + FnMut + FnOnce | Fn + FnMut + FnOnce | |
ClosureUniq | Sequencial | Yes | No | N/A | FnMut + FnOnce | FnMut + FnOnce | |
ClosureOnce | Once only | Meaningless | No | N/A | FnOnce | FnOnce |
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
move keyword | State access | State copiable | Closure type | |
---|---|---|---|---|
Yes | By val | No | ClosureOnce | |
Yes | By mut | No | ClosureUniq | |
Yes | By ref | No | ClosureRef | |
Yes | By mut* | Yes | ClosureMutCopy | |
Yes | By val* | Yes | ClosureCopy | |
Yes | By ref* | Yes | ClosureCopy | |
Yes | No state | N/A | Function | |
No | By val | No | ClosureOnce | |
No | By mut | No | ClosureUniq |