int[] source = {0,1,2,3,4,5};
int[] result = ArrayProducer.Slice(source, 3);
// result is now: {3,4,5}
result = ArrayProducer.Slice(source, 6);
// result is now: {}
int[] source = {0,1,2,3,4,5};
int[] result = ArrayProducer.Slice(source, 3, 2);
// result is now: {3,4}
result = ArrayProducer.Slice(source, 5, 2);
// result is now: {5, 0} 0 is the default value for int
result = ArrayProducer.Slice(source, 0, 0);
// result is now: {}
if(null != ref AND ref.SomeProperty) {
Similarly, a true result on an OR will always result in an early exit.
EventHandler<EventArgs> threadSafeDelegateCopy = Click;
if(null != threadSafeDelegateCopy)
{
threadSafeDelegateCopy(this, EventArgs.Empty);
}
It can be invoked equivalently, but more simply using the DelegateCaller as:
DelegateCaller.Call(Click, this, EventArgs.Empty);
foreach(object myobject in new Enumerable<object>(myCustomEnumerator))...
class Ball : ExtendedEnum<Ball>
{
public static readonly Ball Golf = new Ball(1, 10);
public static readonly Ball Billiard = new Ball(2, 1);
public static readonly Ball Baseball = new Ball(3, 3);
public static readonly Ball Soccer = new Ball(8, 4);
public static readonly Ball Basketball = new Ball(10, 5);
// etc
public int Radius { get { return mRadius;} }
public int Bounciness { get { return mBounciness;} }
private Ball(int radius, int bounciness)
{
mRadius = radius;
mBounciness = bounciness;
}
private int mRadius;
private int mBounciness;
}
class Ball : ExtendedEnum<Ball> // Valid
{...}
class TennisRacket : ExtendedEnum <Ball> // Invalid
{...}
Note: This will add values to ExtendedEnum<Ball>
class SpecializedBall : Ball // Valid.
{...}
class Ball : ExtendedEnum<Ball, String>
{
public static readonly Ball Golf = new Ball("Golf", 1, 2);
public static readonly Ball Billiard = new Ball("Billiard", 3, 2);
public static readonly Ball Baseball = new Ball("Baseball", 4, 3);
public static readonly Ball Soccer = new Ball("Soccer", 10, 7);
public static readonly Ball Basketball = new Ball("Basketball", 12, 10);
// etc
public String Name {get { return mName;} }
public int Radius { get { return mRadius;} }
public int Bounciness { get { return mBounciness;} }
private Ball(String name, int radius, int bounciness) : base(name)
{
mName = name;
mRadius = radius;
mBounciness = bounciness;
}
private String name;
private int mRadius;
private int mBounciness;
}
class Ball : ExtendedEnum<Ball, String> // Valid
{...}
class TennisRacket : ExtendedEnum <Ball, String> // Invalid
{...}
class SpecializedBall : Ball // Valid
{...}
EventHandler oldHandlers = SomeEvent;
SomeEvent = null;
DoOperation(arg1, arg2); // arg1 and arg2 are local variables
SomeEvent = oldHandlers.
VariableGuard.Guard( SomeEvent, null, delegate { DoOperation(arg1, arg2); } );
class MyClass
{
public event EventHandler MyEvent
{
add { WeakMyEvent.AddHandler(value) };
remove { WeakMyEvent.RemoveHandler(value) };
}
protected virtual void OnMyEvent(EventArgs e)
{
WeakMyEvent.Raise(this, e);
}
private readonly WeakEvent WeakMyEvent = new WeakEvent();
}
<SomeControl
ToolTipService.PlacementTarget="{Binding ElementName=SomeOtherElement}"
CSharpWpf:BindableToolTip.DataContext="{Binding}"
>
<CSharpWpf:BindableToolTip.ToolTip>
<ToolTip Content={Binding SomeMVVMPath} />
</CSharpWpf:BindableToolTip.ToolTip>
</SomeControl>
The result of this will be a tooltip who's DataContext is set to the context of SomeControl, and not the DataContext of the element
named "SomeOtherElement". This allows you to bind Tooltip content or other properties relative to the logical context.