当前位置: 首页>>代码示例>>C#>>正文


C# Property.LoadFrom方法代码示例

本文整理汇总了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;
        }
开发者ID:jhancock93,项目名称:autorest,代码行数:84,代码来源:SwaggerModeler.cs

示例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;
 }
开发者ID:Ranjana1996,项目名称:autorest,代码行数:12,代码来源:Property.cs

示例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;
        }
开发者ID:BretJohnson,项目名称:autorest,代码行数:68,代码来源:SwaggerModeler.cs


注:本文中的Property.LoadFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。