Skip to content

Commit

Permalink
Fix ToLinkedServiceEntity extension method to retrieve the type of th…
Browse files Browse the repository at this point in the history
…e linked service
  • Loading branch information
mnicolescu authored and mnicolescu committed Dec 26, 2018
1 parent b9f8399 commit 693511e
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ProcessMyMedia.Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static void Main(string[] args)

IConfigurationRoot configuration = builder.Build();

new Samples.PublicStreamAsset(configuration).Execute();
new Samples.CopyWithGenericPath(configuration).Execute();
}
}
}
103 changes: 101 additions & 2 deletions ProcessMyMedia/Extensions/Data/LinkedServiceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,109 @@ public static Model.LinkedServiceEntity ToEntity(this LinkedServiceResource sou
return new Model.LinkedServiceEntity()
{
Name = source.Name,
Type = source?.Properties?.AdditionalProperties?.ContainsKey("type") == true ?
source.Properties.AdditionalProperties["type"].ToString() : Model.LinkedServiceType.Unknown.ToString(),
Type = source.Properties.GetLinkedServiceType().ToString(),
Description = source.Properties.Description
};
}

/// <summary>
/// Gets the type of the linked service.
/// </summary>
/// <param name="source">The source.</param>
/// <returns></returns>
public static Model.LinkedServiceType GetLinkedServiceType(this LinkedService source)
{
if (source == null)
{
return Model.LinkedServiceType.Unknown;
}

if (source is FtpServerLinkedService)
{
return Model.LinkedServiceType.FtpServer;
}
else if (source is FileServerLinkedService)
{
return Model.LinkedServiceType.FileServer;
}
else if (source is HttpLinkedService)
{
return Model.LinkedServiceType.HttpServer;
}
else if (source is AzureBlobStorageLinkedService)
{
return Model.LinkedServiceType.AzureBlobStorage;
}
else if (source is AmazonS3LinkedService)
{
return Model.LinkedServiceType.AmazonS3;
}
else if (source is HdfsLinkedService)
{
return Model.LinkedServiceType.Hdfs;
}
else if (source is SftpServerLinkedService)
{
return Model.LinkedServiceType.Sftp;
}
else if (source is AzureTableStorageLinkedService)
{
return Model.LinkedServiceType.AzureTableStorage;
}
else if (source is MongoDbLinkedService)
{
return Model.LinkedServiceType.MongoDb;
}
else if (source is ODataLinkedService)
{
return Model.LinkedServiceType.OData;
}
else if (source is OracleLinkedService)
{
return Model.LinkedServiceType.Oracle;
}
else if (source is SqlServerLinkedService)
{
return Model.LinkedServiceType.SqlServer;
}
else if (source is AzureMySqlLinkedService)
{
return Model.LinkedServiceType.AzureMySql;
}
else if (source is AzureSqlDatabaseLinkedService)
{
return Model.LinkedServiceType.AzureSqlDatabase;
}
else if (source is AzurePostgreSqlLinkedService)
{
return Model.LinkedServiceType.AzurePostgreSql;
}
else if (source is SalesforceLinkedService)
{
return Model.LinkedServiceType.Salesforce;
}
else if (source is Db2LinkedService)
{
return Model.LinkedServiceType.Db2;
}
else if (source is CosmosDbLinkedService)
{
return Model.LinkedServiceType.CosmosDb;
}
else if (source is CouchbaseLinkedService)
{
return Model.LinkedServiceType.Couchbase;
}
else if (source is CassandraLinkedService)
{
return Model.LinkedServiceType.Cassandra;
}
else if (source is OdbcLinkedService)
{
return Model.LinkedServiceType.Odbc;
}

return Model.LinkedServiceType.Unknown;
}
}
}

0 comments on commit 693511e

Please sign in to comment.