protected override object CoreGetModelObject(IDictionary <string, IList <string> > properties) { const string PROP_TOKEN_SOURCE_FILE_PATH = "SourceFilePath"; const string CMDLN_TOKEN_XML_SERIALIZED_AQTN = "XmlSerializedType"; string sourceFilePath = null; string xmlSerializedObjectAqtn; Type xmlSerializedObjectType = null; IList <string> values; object sourceObject; ICommonSerializationStrategy commonSerializationStrategy; if ((object)properties == null) { throw new ArgumentNullException(nameof(properties)); } if (properties.TryGetValue(PROP_TOKEN_SOURCE_FILE_PATH, out values)) { if ((object)values != null && values.Count == 1) { sourceFilePath = values[0]; } } if (SolderFascadeAccessor.DataTypeFascade.IsWhiteSpace(sourceFilePath)) { throw new InvalidOperationException(String.Format("The source file path cannot be null or whitespace.")); } sourceFilePath = Path.GetFullPath(sourceFilePath); xmlSerializedObjectAqtn = null; if (properties.TryGetValue(CMDLN_TOKEN_XML_SERIALIZED_AQTN, out values)) { if ((object)values != null && values.Count == 1) { xmlSerializedObjectAqtn = values[0]; xmlSerializedObjectType = Type.GetType(xmlSerializedObjectAqtn, false); } } if ((object)xmlSerializedObjectType == null) { throw new InvalidOperationException(string.Format("Failed to load the XML type '{0}' via Type.GetType(..).", xmlSerializedObjectAqtn)); } commonSerializationStrategy = new NativeXmlSerializationStrategy(); sourceObject = commonSerializationStrategy.DeserializeObjectFromFile(sourceFilePath, xmlSerializedObjectType); return(sourceObject); }
protected override object CoreGetModelObject(IDictionary <string, object> properties) { const string PROP_TOKEN_SOURCE_FILE_PATH = "SourceFilePath"; const string PROP_TOKEN_CONNECTION_AQTN = "ConnectionType"; const string PROP_TOKEN_CONNECTION_STRING = "ConnectionString"; const string PROP_TOKEN_GET_SCHEMA_ONLY = "GetSchemaOnly"; string sourceFilePath = null; string connectionAqtn; Type connectionType = null; string connectionString = null; bool getSchemaOnly = false; IList <string> values; dynamic sourceObject; SqlQuery sqlQuery; ICommonSerializationStrategy commonSerializationStrategy; if ((object)properties == null) { throw new ArgumentNullException(nameof(properties)); } if (properties.TryGetValue(PROP_TOKEN_SOURCE_FILE_PATH, out values)) { if ((object)values != null && values.Count == 1) { sourceFilePath = values[0]; } } if (SolderFascadeAccessor.DataTypeFascade.IsWhiteSpace(sourceFilePath)) { throw new InvalidOperationException(String.Format("The source file path cannot be null or whitespace.")); } sourceFilePath = Path.GetFullPath(sourceFilePath); connectionAqtn = null; if (properties.TryGetValue(PROP_TOKEN_CONNECTION_AQTN, out values)) { if ((object)values != null && values.Count == 1) { connectionAqtn = values[0]; connectionType = Type.GetType(connectionAqtn, false); } } if ((object)connectionType == null) { throw new InvalidOperationException(string.Format("Failed to load the connection type '{0}' via Type.GetType(..).", connectionAqtn)); } if (!typeof(DbConnection).IsAssignableFrom(connectionType)) { throw new InvalidOperationException(string.Format("The connection type is not assignable to type '{0}'.", typeof(DbConnection).FullName)); } if (properties.TryGetValue(PROP_TOKEN_CONNECTION_STRING, out values)) { if ((object)values != null && values.Count == 1) { connectionString = values[0]; } } if (SolderFascadeAccessor.DataTypeFascade.IsWhiteSpace(connectionString)) { throw new InvalidOperationException(string.Format("The connection string cannot be null or whitespace.")); } if (properties.TryGetValue(PROP_TOKEN_GET_SCHEMA_ONLY, out values)) { if ((object)values != null && values.Count == 1) { SolderFascadeAccessor.DataTypeFascade.TryParse <bool>(values[0], out getSchemaOnly); } } commonSerializationStrategy = new NativeXmlSerializationStrategy(); sqlQuery = commonSerializationStrategy.DeserializeObjectFromFile <SqlQuery>(sourceFilePath); sourceObject = new Dictionary <string, object>(); sourceObject.SourceFullPath = sourceFilePath; sourceObject.ConnectionType = connectionType; sourceObject.ConnectionString = connectionString; sourceObject.GetSchemaOnly = getSchemaOnly; WriteSqlQuery(new SqlQuery[] { sqlQuery }, sourceObject, connectionType, connectionString, getSchemaOnly); return(sourceObject); }