Skip to content

Instantly share code, notes, and snippets.

@controlflow
Created December 2, 2019 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save controlflow/0d7231612d3c8c531d178730476a4070 to your computer and use it in GitHub Desktop.
Save controlflow/0d7231612d3c8c531d178730476a4070 to your computer and use it in GitHub Desktop.
[NotNull, Pure]
public static IPattern UnwrapFromSandbox([NotNull] this IPattern pattern)
{
if (pattern.Parent is ISandBox sandBox
&& sandBox.ContextType == SandBoxContextType.Replace
&& sandBox.ContextNode is IPattern replacedPattern)
{
return replacedPattern;
}
return pattern;
}
[NotNull, Pure]
public static IPattern UnwrapFromSandbox([NotNull] this IPattern pattern)
{
if (pattern.Parent is ISandBox {
ContextType: SandBoxContextType.Replace,
ContextNode: IPattern replacedPattern })
{
return replacedPattern;
}
return pattern;
}
[NotNull, Pure]
public static IPattern UnwrapFromSandbox([NotNull] this IPattern pattern)
{
if (pattern is {
Parent: ISandBox {
ContextType: SandBoxContextType.Replace,
ContextNode: IPattern replacedPattern } })
{
return replacedPattern;
}
return pattern;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment