private void CheckGetByImmediateParentSupport() { if (this.FluentMethodGroup.Level > 0) { foreach (MethodJvaf innerMethod in FluentMethodGroup.InnerMethods.Where(method => method.HttpMethod == HttpMethod.Get)) { IFluentMethodGroup parentMethodGroup = this.FluentMethodGroup.ParentFluentMethodGroup; if (parentMethodGroup != null) { bool isResponseCompositeType = innerMethod.ReturnTypeJva.BodyClientType is CompositeTypeJv; if (!isResponseCompositeType) { // In order to be able to map response to standard model T where T is class/interface type // it need to be composite type. If the return type is primitive type (e.g. void), sequence type // dict type then mapping cannot be done. Skip get methods returning such types they will be appear // as other methods continue; } else { var armUri = new ARMUri(innerMethod); Segment lastSegment = armUri.LastOrDefault(); if (lastSegment != null && lastSegment is ParentSegment) { ParentSegment resourceSegment = (ParentSegment)lastSegment; if (resourceSegment.Name.EqualsIgnoreCase(FluentMethodGroup.LocalNameInPascalCase)) { Segment secondLastSegment = armUri.SkipLast(1).LastOrDefault(); if (secondLastSegment != null && secondLastSegment is ParentSegment) { ParentSegment parentSegment = (ParentSegment)secondLastSegment; if (parentSegment.Name.EqualsIgnoreCase(parentMethodGroup.LocalNameInPascalCase)) { if (StandardFluentMethod.CanWrap(innerMethod)) { this.supportsGet = true; this.getMethod = new StandardFluentMethod(innerMethod, this.FluentMethodGroup); break; } } } } } } } } } else { this.supportsGet = false; this.getMethod = null; } }
/// <summary> /// Check can support list by immediate parent. /// </summary> private void CheckListByImmediateParentSupport() { if (this.FluentMethodGroup.Level > 0) { foreach (MethodJvaf innerMethod in FluentMethodGroup.InnerMethods.Where(method => method.HttpMethod == HttpMethod.Get)) { IFluentMethodGroup parentMethodGroup = this.FluentMethodGroup.ParentFluentMethodGroup; if (parentMethodGroup != null) { var armUri = new ARMUri(innerMethod); Segment lastSegment = armUri.LastOrDefault(); if (lastSegment != null && lastSegment is TerminalSegment) { TerminalSegment terminalSegment = (TerminalSegment)lastSegment; if (terminalSegment.Name.EqualsIgnoreCase(FluentMethodGroup.LocalNameInPascalCase)) { Segment secondLastSegment = armUri.SkipLast(1).LastOrDefault(); if (secondLastSegment != null && secondLastSegment is ParentSegment) { ParentSegment parentSegment = (ParentSegment)secondLastSegment; if (parentSegment.Name.EqualsIgnoreCase(parentMethodGroup.LocalNameInPascalCase)) { if (innerMethod.ReturnTypeResponseName.StartsWith("PagedList<") || innerMethod.ReturnTypeResponseName.StartsWith("List<")) { if (StandardFluentMethod.CanWrap(innerMethod)) { this.supportsListing = true; this.listMethod = new StandardFluentMethod(innerMethod, this.FluentMethodGroup); break; } } } } } } } } } else { this.supportsListing = false; this.listMethod = null; } }
private void CheckGetByImmediateParentSupport() { if (this.fluentMethodGroup.Level > 0) { foreach (MethodJvaf innerMethod in fluentMethodGroup.InnerMethods.Where(method => method.HttpMethod == HttpMethod.Get)) { FluentMethodGroup parentMethodGroup = this.fluentMethodGroup.ParentFluentMethodGroup; if (parentMethodGroup != null) { var armUri = new ARMUri(innerMethod); Segment lastSegment = armUri.LastOrDefault(); if (lastSegment != null && lastSegment is ParentSegment) { ParentSegment resourceSegment = (ParentSegment)lastSegment; if (resourceSegment.Name.EqualsIgnoreCase(fluentMethodGroup.LocalNameInPascalCase)) { Segment secondLastSegment = armUri.SkipLast(1).LastOrDefault(); if (secondLastSegment != null && secondLastSegment is ParentSegment) { ParentSegment parentSegment = (ParentSegment)secondLastSegment; if (parentSegment.Name.EqualsIgnoreCase(parentMethodGroup.LocalNameInPascalCase)) { this.supportsGetByImmediateParent = true; this.getByImmediateParentMethod = new FluentMethod(true, innerMethod, this.fluentMethodGroup); break; } } } } } } } else { this.supportsGetByImmediateParent = false; this.getByImmediateParentMethod = null; } }