Skip to content

feat(dynamicModel): add dynamic model and meta files #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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