Esempio n. 1
0
        public MethodTemplateModel(Method source, string owner, string packageName, MethodScopeProvider methodScope)
        {
            this.LoadFrom(source);

            MethodScope = methodScope;
            Owner = owner;
            PackageName = packageName;

            var parameter = Parameters.Find(p => p.Type.IsPrimaryType(KnownPrimaryType.Stream)
                                                && !(p.Location == ParameterLocation.Body || p.Location == ParameterLocation.FormData));
            if (parameter != null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                    Resources.IllegalStreamingParameter, parameter.Name));
            }

            if (string.IsNullOrEmpty(Description))
            {
                Description = string.Format("sends the {0} request.", ScopedName.ToPhrase());
            }

            if (this.IsLongRunningOperation())
            {
                Description += lroDescription;
            }
        }
Esempio n. 2
0
        public MethodTemplateModel(Method source, string owner, string packageName, MethodScopeProvider methodScope, bool next)
        {
            this.LoadFrom(source);

            MethodScope        = methodScope;
            Owner              = owner;
            PackageName        = packageName;
            NextAlreadyDefined = next;

            var parameter = Parameters.Find(p => p.Type.IsPrimaryType(KnownPrimaryType.Stream) &&
                                            !(p.Location == ParameterLocation.Body || p.Location == ParameterLocation.FormData));

            if (parameter != null)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                          Resources.IllegalStreamingParameter, parameter.Name));
            }

            if (string.IsNullOrEmpty(Description))
            {
                Description = string.Format("sends the {0} request.", ScopedName.ToPhrase());
            }

            if (this.IsLongRunningOperation())
            {
                Description += lroDescription;
            }
        }
        public ServiceClientTemplateModel(ServiceClient serviceClient, string packageName, string methodGroupName = null)
        {
            this.LoadFrom(serviceClient);

            MethodGroupName = methodGroupName == null
                                ? string.Empty
                                : methodGroupName;
            PackageName = packageName == null
                            ? string.Empty
                            : packageName;

            BaseClient = "ManagementClient";
            ClientName = string.IsNullOrEmpty(MethodGroupName)
                            ? BaseClient
                            : MethodGroupName.IsNamePlural(PackageName)
                                             ? MethodGroupName + "Client"
                                             : (MethodGroupName + "Client").TrimPackageName(PackageName);
            MethodScope          = new MethodScopeProvider();
            MethodTemplateModels = new List <MethodTemplateModel>();

            Methods.Where(m => m.BelongsToGroup(MethodGroupName, PackageName))
            .OrderBy(m => m.Name)
            .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, ClientName, PackageName, new MethodScopeProvider())));

            Documentation = string.Format("Package {0} implements the Azure ARM {1} service API version {2}.\n\n{3}", PackageName, ServiceName, ApiVersion,
                                          !string.IsNullOrEmpty(Documentation) ? Documentation.UnwrapAnchorTags() : "");
            ClientDocumentation = string.Format("{0} is the base client for {1}.", ClientName, ServiceName);
        }
        public ServiceClientTemplateModel(ServiceClient serviceClient, string packageName, string methodGroupName = null)
        {
            this.LoadFrom(serviceClient);

            MethodGroupName = methodGroupName == null
                                ? string.Empty
                                : methodGroupName;
            PackageName = packageName == null
                            ? string.Empty
                            : packageName;

            BaseClient = "ManagementClient";
            ClientName = string.IsNullOrEmpty(MethodGroupName)
                            ? BaseClient
                            : MethodGroupName.IsNamePlural(PackageName)
                                             ? MethodGroupName + "Client"
                                             : (MethodGroupName + "Client").TrimPackageName(PackageName);
            MethodScope = new MethodScopeProvider();
            MethodTemplateModels = new List<MethodTemplateModel>();

            Methods.Where(m => m.BelongsToGroup(MethodGroupName, PackageName))
                    .OrderBy(m => m.Name)
                    .ForEach(m => MethodTemplateModels.Add(new MethodTemplateModel(m, ClientName, PackageName, new MethodScopeProvider())));

            Documentation = string.Format("Package {0} implements the Azure ARM {1} service API version {2}.\n\n{3}", PackageName, ServiceName, ApiVersion,
                                    !string.IsNullOrEmpty(Documentation) ? Documentation.UnwrapAnchorTags() : "");
            ClientDocumentation = string.Format("{0} is the base client for {1}.", ClientName, ServiceName);
        }