Skip to content

Commit

Permalink
Merge pull request #18 from IBM/feat/dynamic-model
Browse files Browse the repository at this point in the history
feat(dynamicModel): add dynamic model and meta files
  • Loading branch information
mamoonraja authored Sep 18, 2019
2 parents 91fa51c + 2b471aa commit 06abd1d
Show file tree
Hide file tree
Showing 69 changed files with 965 additions and 84 deletions.
8 changes: 8 additions & 0 deletions Authentication.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Authentication/Authenticator.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Authentication/BasicAuthenticator.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Authentication/BearerTokenAuthenticator.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Authentication/CloudPakForData.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Authentication/CloudPakForData/CloudPakForDataToken.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Authentication/ConfigBasedAuthenticatorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ private static Authenticator CreateAuthenticator(Dictionary<string, string> prop
{
authenticator = new BearerTokenAuthenticator(props);
}
else
{
throw new ArgumentException(string.Format(ErrorMessageAuthTypeUnknown, authType));
}

return authenticator;
}
Expand Down
11 changes: 11 additions & 0 deletions Authentication/ConfigBasedAuthenticatorFactory.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Authentication/Iam.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Authentication/Iam/IamAuthenticator.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Authentication/Iam/IamToken.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Authentication/Iam/IamTokenResponse.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Authentication/NoAuthAuthenticator.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Model.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

108 changes: 108 additions & 0 deletions Model/DynamicModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* Copyright 2019 IBM Corp. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;

namespace IBM.Cloud.SDK.Model
{
/// <summary>
/// This class is the base class for generated models with restricted additional properties.
/// </summary>
/// <typeparam name="T"></typeparam>
public class DynamicModel<T>
{
/// <summary>
/// A Dictionary to keep restricted additional properties.
/// </summary>
[JsonExtensionData]
public Dictionary<string, JToken> AdditionalProperties { get; } = new Dictionary<string, JToken>();

/// <summary>
/// Add a property to the AdditionalProperties dictionary.
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public void Add(string key, T value)
{
AdditionalProperties.Add(key, JToken.FromObject(value));
}

/// <summary>
/// Remove a property from the AdditionalProperties dictionary.
/// </summary>
/// <param name="key"></param>
public void Remove(string key)
{
AdditionalProperties.Remove(key);
}

/// <summary>
/// Get a single property from the AdditionalProperties dictionary.
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public T Get(string key)
{
AdditionalProperties.TryGetValue(key, out JToken value);
return value.ToObject<T>();
}
}

/// <summary>
/// This class is the base class for generated models with arbitrary additional properties.
/// </summary>
public class DynamicModel
{
/// <summary>
/// A Dictionary to keep arbitrary additional properties.
/// </summary>
[JsonExtensionData]
public Dictionary<string, JToken> AdditionalProperties { get; } = new Dictionary<string, JToken>();

/// <summary>
/// Add a property to the AdditionalProperties dictionary.
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public void Add(string key, object value)
{
AdditionalProperties.Add(key, JToken.FromObject(value));
}

/// <summary>
/// Remove a property from the AdditionalProperties dictionary.
/// </summary>
/// <param name="key"></param>
public void Remove(string key)
{
AdditionalProperties.Remove(key);
}

/// <summary>
/// Get a single property from the AdditionalProperties dictionary.
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public JToken Get(string key)
{
AdditionalProperties.TryGetValue(key, out JToken value);
return value;
}
}
}
11 changes: 11 additions & 0 deletions Model/DynamicModel.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Plugins/websocket-sharp.dll.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 06abd1d

Please sign in to comment.