private static FunctionInfo CreateFunction(string name, ScriptBlock function, FunctionInfo originalFunction, ScopedItemOptions options, ExecutionContext context, string helpFile) { FunctionInfo newValue = null; if (options == ScopedItemOptions.Unspecified) { options = ScopedItemOptions.None; } // First use the copy constructors if (originalFunction is FilterInfo) { newValue = new FilterInfo(name, (FilterInfo)originalFunction); } else if (originalFunction is WorkflowInfo) { newValue = new WorkflowInfo(name, (WorkflowInfo)originalFunction); } else if (originalFunction is ConfigurationInfo) { newValue = new ConfigurationInfo(name, (ConfigurationInfo)originalFunction); } else if (originalFunction != null) { newValue = new FunctionInfo(name, originalFunction); } // Then use the creation constructors - workflows don't get here because the workflow info // is created during compilation. else if (function.IsFilter) { newValue = new FilterInfo(name, function, options, context, helpFile); } else if (function.IsConfiguration) { newValue = new ConfigurationInfo(name, function, options, context, helpFile, function.IsMetaConfiguration()); } else newValue = new FunctionInfo(name, function, options, context, helpFile); return newValue; }