本文整理汇总了C#中Property.LoadFrom方法的典型用法代码示例。如果您正苦于以下问题:C# Property.LoadFrom方法的具体用法?C# Property.LoadFrom怎么用?C# Property.LoadFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Property
的用法示例。
在下文中一共展示了Property.LoadFrom方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public override ServiceClient Build(out IEnumerable<ValidationMessage> messages)
{
Logger.LogInfo(Resources.ParsingSwagger);
if (string.IsNullOrWhiteSpace(Settings.Input))
{
throw ErrorManager.CreateError(Resources.InputRequired);
}
ServiceDefinition = SwaggerParser.Load(Settings.Input, Settings.FileSystem);
// Look for semantic errors and warnings in the document.
var validator = new RecursiveObjectValidator(PropertyNameResolver.JsonName);
messages = validator.GetValidationExceptions(ServiceDefinition).ToList();
Logger.LogInfo(Resources.GeneratingClient);
// Update settings
UpdateSettings();
InitializeClientModel();
BuildCompositeTypes();
// Build client parameters
foreach (var swaggerParameter in ServiceDefinition.Parameters.Values)
{
var parameter = ((ParameterBuilder)swaggerParameter.GetBuilder(this)).Build();
var clientProperty = new Property();
clientProperty.LoadFrom(parameter);
ServiceClient.Properties.Add(clientProperty);
}
// Build methods
foreach (var path in ServiceDefinition.Paths.Concat(ServiceDefinition.CustomPaths))
{
foreach (var verb in path.Value.Keys)
{
var operation = path.Value[verb];
if (string.IsNullOrWhiteSpace(operation.OperationId))
{
throw ErrorManager.CreateError(
string.Format(CultureInfo.InvariantCulture,
Resources.OperationIdMissing,
verb,
path.Key));
}
var methodName = GetMethodName(operation);
var methodGroup = GetMethodGroup(operation);
if (verb.ToHttpMethod() != HttpMethod.Options)
{
string url = path.Key;
if (url.Contains("?"))
{
url = url.Substring(0, url.IndexOf('?'));
}
var method = BuildMethod(verb.ToHttpMethod(), url, methodName, operation);
method.Group = methodGroup;
ServiceClient.Methods.Add(method);
if (method.DefaultResponse.Body is CompositeType)
{
ServiceClient.ErrorTypes.Add((CompositeType)method.DefaultResponse.Body);
}
}
else
{
Logger.LogWarning(Resources.OptionsNotSupported);
}
}
}
// Set base type
foreach (var typeName in GeneratedTypes.Keys)
{
var objectType = GeneratedTypes[typeName];
if (ExtendedTypes.ContainsKey(typeName))
{
objectType.BaseModelType = GeneratedTypes[ExtendedTypes[typeName]];
}
ServiceClient.ModelTypes.Add(objectType);
}
return ServiceClient;
}
示例2: Clone
/// <summary>
/// Performs a deep clone of a property.
/// </summary>
/// <returns>A deep clone of current object.</returns>
public object Clone()
{
Property property = new Property();
property.LoadFrom(this);
property.Constraints = new Dictionary<Constraint, string>(this.Constraints);
property.Extensions = new Dictionary<string, object>(this.Extensions);
return property;
}
示例3: Build
/// <summary>
/// Builds service model from swagger file.
/// </summary>
/// <returns></returns>
public override ServiceClient Build()
{
PrimaryType.Reset();
Logger.LogInfo(Resources.ParsingSwagger);
ServiceDefinition = SwaggerParser.Load(Settings.Input, Settings.FileSystem);
Logger.LogInfo(Resources.GeneratingClient);
InitializeClientModel();
BuildCompositeTypes();
// Build client parameters
foreach (var swaggerParameter in ServiceDefinition.Parameters.Values)
{
var parameter = ((ParameterBuilder)swaggerParameter.GetBuilder(this)).Build();
var clientProperty = new Property();
clientProperty.LoadFrom(parameter);
ServiceClient.Properties.Add(clientProperty);
}
// Build methods
foreach (var path in ServiceDefinition.Paths)
{
foreach (var verb in path.Value.Keys)
{
var operation = path.Value[verb];
if (string.IsNullOrWhiteSpace(operation.OperationId))
{
throw ErrorManager.CreateError(
string.Format(CultureInfo.InvariantCulture,
Resources.OperationIdMissing,
verb,
path.Key));
}
var methodName = GetMethodName(operation);
var methodGroup = GetMethodGroup(operation);
if (verb.ToHttpMethod() != HttpMethod.Options)
{
var method = BuildMethod(verb.ToHttpMethod(), path.Key, methodName, operation);
method.Group = methodGroup;
ServiceClient.Methods.Add(method);
}
else
{
Logger.LogWarning(Resources.OptionsNotSupported);
}
}
}
// Set base type
foreach (var typeName in GeneratedTypes.Keys)
{
var objectType = GeneratedTypes[typeName];
if (ExtendedTypes.ContainsKey(typeName))
{
objectType.BaseModelType = GeneratedTypes[ExtendedTypes[typeName]];
}
ServiceClient.ModelTypes.Add(objectType);
}
return ServiceClient;
}