Exemplo n.º 1
0
			internal static extern void GetSystemInfo(ref WorkflowRuntimeCompilation.NativeMethods.SYSTEM_INFO lpSystemInfo);
Exemplo n.º 2
0
        internal static string CompileDependentWorkflowsToAssembly(string[] dependentWorkflows, Dictionary<string, string> requiredAssemblies)
        {
            Debug.Assert(dependentWorkflows.Length > 0, "There should be atleast one dependent workflow.");
            Debug.Assert((PSWorkflowRuntime.Instance.Configuration).GetType() == typeof(PSWorkflowConfigurationProvider), "type mismatch error.");

            PSWorkflowConfigurationProvider config = (PSWorkflowConfigurationProvider)PSWorkflowRuntime.Instance.Configuration;
            
            // Calculating Hashcode
            string hashcode = string.Empty;

            List<int> codes = new List<int>();
            foreach (string dependentWorkflow in dependentWorkflows)
            {
                codes.Add(dependentWorkflow.GetHashCode());
            }
            codes.Sort();
            
            foreach (int code in codes)
            {
                hashcode += code.ToString(CultureInfo.InvariantCulture);
            }

            Debug.Assert(string.IsNullOrEmpty(hashcode) == false, "Hash code should not be null or empty");

            WorkflowRuntimeCompilation compiler = null;

            // check if the hashcode already exist in cache
            if (compiledAssemblyCache.ContainsKey(hashcode))
            {
                compiledAssemblyCache.TryGetValue(hashcode, out compiler);
            }

            if (compiler == null)
            {
                try
                {
                    compiler = new WorkflowRuntimeCompilation();

                    compiler.Compile(new List<string>(dependentWorkflows), requiredAssemblies);
                }
                catch (Exception e)
                {
                    Tracer.TraceException(e);
                    throw;
                }

                // sanity check to block the unbounded increase in the cache size
                if (compiledAssemblyCache.Keys.Count >= config.CompiledAssemblyCacheLimit)
                {
                    compiledAssemblyCache.Clear();
                }

                compiledAssemblyCache.TryAdd(hashcode, compiler);
            }
            
            // Throw an error if there was a compilation problem
            if (!compiler.BuildReturnedCode || !File.Exists(compiler.AssemblyPath))
            {
                string message = string.Format(CultureInfo.CurrentUICulture,
                                               Resources.CompilationErrorWhileBuildingWorkflows,
                                               compiler.BuildLogPath);
                throw new InvalidDataException(message);
            }

            return compiler.AssemblyPath;
        }
Exemplo n.º 3
0
		internal static string CompileDependentWorkflowsToAssembly(string[] dependentWorkflows, Dictionary<string, string> requiredAssemblies)
		{
			PSWorkflowConfigurationProvider configuration = PSWorkflowRuntime.Instance.Configuration;
			string empty = string.Empty;
			List<int> nums = new List<int>();
			string[] strArrays = dependentWorkflows;
			for (int i = 0; i < (int)strArrays.Length; i++)
			{
				string str = strArrays[i];
				nums.Add(str.GetHashCode());
			}
			nums.Sort();
			foreach (int num in nums)
			{
				empty = string.Concat(empty, num.ToString(CultureInfo.InvariantCulture));
			}
			WorkflowRuntimeCompilation workflowRuntimeCompilation = null;
			if (ImportWorkflowCommand.compiledAssemblyCache.ContainsKey(empty))
			{
				ImportWorkflowCommand.compiledAssemblyCache.TryGetValue(empty, out workflowRuntimeCompilation);
			}
			if (workflowRuntimeCompilation == null)
			{
				try
				{
					workflowRuntimeCompilation = new WorkflowRuntimeCompilation();
					workflowRuntimeCompilation.Compile(new List<string>(dependentWorkflows), requiredAssemblies);
				}
				catch (Exception exception1)
				{
					Exception exception = exception1;
					ImportWorkflowCommand.Tracer.TraceException(exception);
					throw;
				}
				if (ImportWorkflowCommand.compiledAssemblyCache.Keys.Count >= configuration.CompiledAssemblyCacheLimit)
				{
					ImportWorkflowCommand.compiledAssemblyCache.Clear();
				}
				ImportWorkflowCommand.compiledAssemblyCache.TryAdd(empty, workflowRuntimeCompilation);
			}
			if (!workflowRuntimeCompilation.BuildReturnedCode || !File.Exists(workflowRuntimeCompilation.AssemblyPath))
			{
				object[] buildLogPath = new object[1];
				buildLogPath[0] = workflowRuntimeCompilation.BuildLogPath;
				string str1 = string.Format(CultureInfo.CurrentUICulture, Resources.CompilationErrorWhileBuildingWorkflows, buildLogPath);
				throw new InvalidDataException(str1);
			}
			else
			{
				return workflowRuntimeCompilation.AssemblyPath;
			}
		}