private IFunctionData UpdateToVersion1(IFunctionData data) { bool isText = data.Properties[FileOpenShared.IsTextPropertyName].GetValue <bool>(); var updatedExecutionPath = new ExecutionPath { Key = FileOpenShared.ExecutionPathName, Name = FileOpenShared.ExecutionPathName, Output = TypeReference.CreateGeneratedType( new TypeProperty(FileOpenShared.OutputFilePathPropertyName, typeof(string), AccessType.Read), new TypeProperty(FileOpenShared.OutputFileHandlePropertyName, TypeReference.CreateResource(isText ? typeof(TextFileHandle) : typeof(BinaryFileHandle)), AccessType.Read)), IterationHint = Plugin.Common.IterationHint.Once }; IExecutionPathData existingExecutionPath; if (data.TryFindExecutionPathByKey(FileOpenShared.ExecutionPathName, out existingExecutionPath)) { data = data.ReplaceExecutionPath(existingExecutionPath, updatedExecutionPath); } else { data = data.AddExecutionPath(updatedExecutionPath); } return(data.UpdateVersion("1")); }
private IFunctionData UpdateToVersion3(IFunctionData data) { var resultTypeProperty = data.Properties[ExecuteSQLShared.ResultTypePropertyName]; var resultTypeValue = resultTypeProperty.GetValue <ResultType>(); var requireUpdate = false; foreach (var field in resultTypeValue.Fields) { if (field.Type == typeof(Int32)) { field.Type = typeof(Int64); requireUpdate = true; } } if (requireUpdate) { data = data.UpdateProperty(resultTypeProperty, resultTypeProperty.Id, resultTypeProperty.Name, resultTypeProperty.TypeReference, resultTypeValue, resultTypeProperty.IsVisible, resultTypeProperty.ValueUsage); var returnTypeValue = resultTypeValue.BuildRowTypeFromFields(); if (returnTypeValue != null) { if (data.Output != null) { if (data.Output.IsList) { data = data.UpdateOutput(TypeReference.CreateList(returnTypeValue)); } else { data = data.UpdateOutput(returnTypeValue); } } IExecutionPathData executionPath; if (data.TryFindExecutionPathByKey("ForEachRow", out executionPath) && executionPath.Output != null) { data = data.UpdateExecutionPath(executionPath, executionPath.Key, executionPath.Name, returnTypeValue, executionPath.IterationHint); } } } return(data.UpdateVersion("3")); }