Ejemplo n.º 1
0
        internal void Transform(CodeModelSwift cmg)
        {
            var originalName = Name.Value;

            Name = Name.Value.TrimPackageName(cmg.Namespace);
            if (Name != originalName)
            {
                // fix up the method group names
                cmg.Methods.Where(m => m.Group.Value == originalName)
                .ForEach(m =>
                {
                    m.Group = Name;
                });
            }

            ClientName = string.IsNullOrEmpty(Name)
                            ? cmg.BaseClient
                            : TypeName.Value.IsNamePlural(cmg.Namespace)
                                             ? Name.Value
                                             : (Name.Value).TrimPackageName(cmg.Namespace);

            Documentation = string.Format("{0} is the {1} ", ClientName,
                                          string.IsNullOrEmpty(cmg.Documentation)
                                        ? string.Format("client for the {0} methods of the {1} service.", TypeName, cmg.ServiceName)
                                        : cmg.Documentation.ToSentence());

            PackageName      = cmg.Namespace;
            BaseClient       = cmg.BaseClient;
            GlobalParameters = cmg.GlobalParameters;

            //Imports
            var imports = new HashSet <string>();

            imports.UnionWith(CodeNamerSwift.Instance.AutorestImports);
        }
Ejemplo n.º 2
0
        internal void Transform(CodeModelSwift cmg)
        {
            Owner              = (MethodGroup as MethodGroupSwift).ClientName;
            PackageName        = cmg.Namespace;
            NextAlreadyDefined = NextMethodExists(cmg.Methods.Cast <MethodSwift>());

            var apiVersionParam =
                from p in Parameters
                let name = p.SerializedName
                           where name != null && name.IsApiVersion()
                           select p.DefaultValue.Value?.Trim(new[] { '"' });

            // When APIVersion is blank, it means that it was unavailable at the method level
            // and we should default back to whatever is present at the client level. However,
            // we will continue embedding that in each method to have broader support.
            APIVersion = apiVersionParam.SingleOrDefault();
            if (APIVersion == default(string))
            {
                APIVersion = cmg.ApiVersion;
            }

            var parameter = Parameters.ToList().Find(p => p.ModelType.PrimaryType(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.", Name.ToString().ToPhrase());
            }

            if (IsLongRunningOperation())
            {
                Description += lroDescription;
            }
        }