public static bool VerifyGACDependencyXP(ReferenceIdentity refId, string tempDir)
 {
     if (!PlatformSpecific.OnXPOrAbove)
     {
         return false;
     }
     using (TempFile file = new TempFile(tempDir, ".manifest"))
     {
         ManifestGenerator.GenerateGACDetectionManifest(refId, file.Path);
         System.Deployment.Application.NativeMethods.ACTCTXW actCtx = new System.Deployment.Application.NativeMethods.ACTCTXW(file.Path);
         IntPtr hActCtx = System.Deployment.Application.NativeMethods.CreateActCtxW(actCtx);
         if (hActCtx != System.Deployment.Application.NativeMethods.INVALID_HANDLE_VALUE)
         {
             System.Deployment.Application.NativeMethods.ReleaseActCtx(hActCtx);
             return true;
         }
         return false;
     }
 }
        /// <summary>
        ///     This function handles unsupported features by <see cref="Regen.Flee"/> evaluator by creating temporary
        ///     variables or even changing the type of expression.
        /// </summary>
        /// <remarks>
        /// Because flee does not support arrays, we temporarly store any parsed array
        /// into a variable and then just pass the variable name, letting Regen just fetch it
        /// and pass it around.
        ///</remarks>
        public Expression HandleUnsupported(Expression expr, List <TemporaryVariable> temps, Type caller = null)
        {
            //todo after we support dictionaries, add support here
            switch (expr)
            {
            case NullIdentity _:
            case CharLiteral _:
            case NumberLiteral _:
            case StringLiteral _:
            case BooleanLiteral _:
            case StringIdentity _:
            case ReferenceIdentity _:
            case EmptyExpression _:
                return(expr);

            case ArgumentsExpression argumentsExpression: {
                for (var i = 0; i < argumentsExpression.Arguments.Length; i++)
                {
                    argumentsExpression.Arguments[i] = HandleUnsupported(argumentsExpression.Arguments[i], temps, typeof(ArgumentsExpression));
                }

                return(argumentsExpression);
            }

            case ArrayExpression arrayExpression: {
                for (var i = 0; i < arrayExpression.Values.Length; i++)
                {
                    arrayExpression.Values[i] = HandleUnsupported(arrayExpression.Values[i], temps, typeof(ArrayExpression));
                }

                var parsedArray = Compute(arrayExpression, temps, typeof(ArrayExpression));
                var temp        = new TemporaryVariable(Context, parsedArray);
                //todo this might lead to memory leaks!
                //temps.Add(temp);
                //if (caller == typeof(RegenCompiler)) { //if this is the first expression that is being parsed
                //    temp.MarkPermanent();
                //}
                return(IdentityExpression.WrapVariable(temp.Name));
            }

            case IndexerCallExpression indexerCallExpression: {
                indexerCallExpression.Left      = HandleUnsupported(indexerCallExpression.Left, temps, typeof(IndexerCallExpression));
                indexerCallExpression.Arguments = (ArgumentsExpression)HandleUnsupported(indexerCallExpression.Arguments, temps, typeof(IndexerCallExpression));
                return(indexerCallExpression);
            }

            case CallExpression callExpression: {
                callExpression.FunctionName = HandleUnsupported(callExpression.FunctionName, temps, typeof(CallExpression));
                callExpression.Arguments    = (ArgumentsExpression)HandleUnsupported(callExpression.Arguments, temps, typeof(CallExpression));
                return(callExpression);
            }

            case IdentityExpression identityExpression: {
                //here we turn any string literal into a reference to a variable.
                //if theres no such variable, we assume it is for a functionname of property.
                if (identityExpression.Identity is StringIdentity sr)
                {
                    if (Context.Variables.ContainsKey(sr.Name))
                    {
                        return(new IdentityExpression(ReferenceIdentity.Wrap(sr)));
                    }
                }

                identityExpression.Identity = HandleUnsupported(identityExpression.Identity, temps, caller ?? typeof(IdentityExpression));
                return(identityExpression);
            }

            case HashtagReferenceExpression hashtagReference: {
                var key = $"__{hashtagReference.Number}__";
                return(new IdentityExpression(new ReferenceIdentity(key, new RegexResult()
                    {
                        Value = key, Index = hashtagReference.Matches().First().Index, Length = 1 + hashtagReference.Number.Length
                    })));
            }

            case GroupExpression groupExpression:
                groupExpression.InnerExpression = HandleUnsupported(groupExpression.InnerExpression, temps, caller ?? typeof(GroupExpression));
                return(groupExpression);

            case PropertyIdentity propertyIdentity:
                //todo maybe here we parse Left, store and push? but first invalidate that it is not just a name.
                propertyIdentity.Left  = HandleUnsupported(propertyIdentity.Left, temps, caller ?? typeof(PropertyIdentity));
                propertyIdentity.Right = HandleUnsupported(propertyIdentity.Right, temps, caller ?? typeof(PropertyIdentity));
                return(propertyIdentity);

            case KeyValueExpression keyValueExpression:
                keyValueExpression.Key   = HandleUnsupported(keyValueExpression.Key, temps, typeof(KeyValueExpression));
                keyValueExpression.Value = HandleUnsupported(keyValueExpression.Value, temps, typeof(KeyValueExpression));
                return(keyValueExpression);

            case NewExpression newExpression:
                newExpression.Constructor = HandleUnsupported(newExpression.Constructor, temps, typeof(NewExpression));
                return(newExpression);

            case LeftOperatorExpression leftOperatorExpression:
                leftOperatorExpression.Right = HandleUnsupported(leftOperatorExpression.Right, temps, typeof(LeftOperatorExpression));
                return(leftOperatorExpression);

            case OperatorExpression operatorExpression:
                operatorExpression.Left  = HandleUnsupported(operatorExpression.Left, temps, typeof(OperatorExpression));
                operatorExpression.Right = HandleUnsupported(operatorExpression.Right, temps, typeof(OperatorExpression));
                return(operatorExpression);

            case RightOperatorExpression rightOperatorExpression:
                rightOperatorExpression.Left = HandleUnsupported(rightOperatorExpression.Left, temps, typeof(RightOperatorExpression));
                return(rightOperatorExpression);

            case ThrowExpression throwExpression:
                throwExpression.Right = HandleUnsupported(throwExpression.Right, temps, typeof(ThrowExpression));
                return(throwExpression);

            case ForeachExpression foreachExpression:
            case ImportExpression importExpression:
            case InteractableExpression interactableExpression:
            case VariableDeclarationExpression variableExpression:
                throw new NotSupportedException(); //todo support? this should be found in an expression. it is a higher level expression

            case Identity identity:                //this is an abstract class.
                throw new NotSupportedException();

            default:
                throw new NotImplementedException();
            }
        }
 public static bool VerifyGACDependencyWhidbey(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, bool targetOtherClr, System.Deployment.Application.NativeMethods.CCorRuntimeHost RuntimeHost, ReferenceIdentity refId)
 {
     ReferenceIdentity identity;
     System.Deployment.Application.NativeMethods.IAssemblyName name;
     System.Deployment.Application.NativeMethods.IAssemblyEnum enum2;
     string str = refId.ToString();
     string text = null;
     if (targetOtherClr)
     {
         try
         {
             text = RuntimeHost.ApplyPolicyInOtherRuntime(str);
             goto Label_0048;
         }
         catch (ArgumentException)
         {
             return false;
         }
         catch (COMException)
         {
             return false;
         }
     }
     try
     {
         text = AppDomain.CurrentDomain.ApplyPolicy(str);
     }
     catch (ArgumentException)
     {
         return false;
     }
     catch (COMException)
     {
         return false;
     }
 Label_0048:
     identity = new ReferenceIdentity(text);
     identity.ProcessorArchitecture = refId.ProcessorArchitecture;
     string assemblyName = identity.ToString();
     Logger.AddPhaseInformation(Resources.GetString("DetectingDependentAssembly"), new object[] { str, assemblyName });
     SystemUtils.AssemblyInfo info = null;
     info = SystemUtils.QueryAssemblyInfo(AssemblyCache, SystemUtils.QueryAssemblyInfoFlags.All, assemblyName);
     if ((info != null) || (identity.ProcessorArchitecture != null))
     {
         return (info != null);
     }
     System.Deployment.Application.NativeMethods.CreateAssemblyNameObject(out name, identity.ToString(), 1, IntPtr.Zero);
     System.Deployment.Application.NativeMethods.CreateAssemblyEnum(out enum2, null, name, 2, IntPtr.Zero);
     return (enum2.GetNextAssembly(null, out name, 0) == 0);
 }
 public static bool VerifyGACDependency(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, bool targetOtherClr, System.Deployment.Application.NativeMethods.CCorRuntimeHost RuntimeHost, ReferenceIdentity refId, string tempDir)
 {
     if (string.Compare(refId.ProcessorArchitecture, "msil", StringComparison.OrdinalIgnoreCase) == 0)
     {
         return VerifyGACDependencyWhidbey(AssemblyCache, targetOtherClr, RuntimeHost, refId);
     }
     if (!VerifyGACDependencyXP(refId, tempDir))
     {
         return VerifyGACDependencyWhidbey(AssemblyCache, targetOtherClr, RuntimeHost, refId);
     }
     return true;
 }
 private static bool IsNetFX35SP1FullSignatureAsm(ReferenceIdentity ra)
 {
     DefinitionIdentity identity = new DefinitionIdentity("System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089,processorArchitecture=msil");
     return identity.Matches(ra, true);
 }
 private static bool IsNetFX35SP1ClientSignatureAsm(ReferenceIdentity ra)
 {
     DefinitionIdentity identity = new DefinitionIdentity("Sentinel.v3.5Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,processorArchitecture=msil");
     return identity.Matches(ra, true);
 }
 private static NetFX35SP1SKU GetPlatformNetFx35SKU(System.Deployment.Application.NativeMethods.IAssemblyCache AssemblyCache, bool targetOtherCLR, System.Deployment.Application.NativeMethods.CCorRuntimeHost RuntimeHost, string tempDir)
 {
     ReferenceIdentity refId = new ReferenceIdentity("Sentinel.v3.5Client, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,processorArchitecture=msil");
     ReferenceIdentity identity2 = new ReferenceIdentity("System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089,processorArchitecture=msil");
     bool flag = false;
     bool flag2 = false;
     if (VerifyGACDependency(AssemblyCache, targetOtherCLR, RuntimeHost, refId, tempDir))
     {
         flag = true;
     }
     if (VerifyGACDependency(AssemblyCache, targetOtherCLR, RuntimeHost, identity2, tempDir))
     {
         flag2 = true;
     }
     if (flag && !flag2)
     {
         return NetFX35SP1SKU.Client35SP1;
     }
     if (flag && flag2)
     {
         return NetFX35SP1SKU.Full35SP1;
     }
     return NetFX35SP1SKU.No35SP1;
 }