예제 #1
0
 public ResourceGetDescription(ISegmentFluentMethodGroup fluentMethodGroup)
 {
     this.FluentMethodGroup        = fluentMethodGroup;
     this.getByResourceGroup       = new GetByResourceGroupDescription(fluentMethodGroup, this.GetInnerAsyncFuncFactory);
     this.getBySubscription        = new GetBySubscriptionDescription(fluentMethodGroup, this.GetInnerAsyncFuncFactory);
     this.getByImmediateParent     = new GetByImmediateParentDescription(fluentMethodGroup, this.GetInnerAsyncFuncFactory);
     this.getByParameterizedParent = new GetByParameterizedParentDescription(fluentMethodGroup, this.GetInnerAsyncFuncFactory);
 }
예제 #2
0
 public StandardFluentMethod(MethodJvaf innerMethod, ISegmentFluentMethodGroup methodGroup)
 {
     if (!CanWrap(innerMethod))
     {
         throw new ArgumentException($"StandardFluentMethod can wrap only inner methods that return wrappable return type, received inner method '{innerMethod.ReturnTypeResponseName} {innerMethod.Name}(..)'");
     }
     //
     this.InnerMethod       = innerMethod;
     this.FluentMethodGroup = methodGroup;
 }
예제 #3
0
 private void CheckGetByImmediateParentSupport()
 {
     if (this.FluentMethodGroup.Level > 0)
     {
         foreach (MethodJvaf innerMethod in FluentMethodGroup.InnerMethods.Where(method => method.HttpMethod == HttpMethod.Get))
         {
             ISegmentFluentMethodGroup 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;
     }
 }
예제 #4
0
 /// <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))
         {
             ISegmentFluentMethodGroup 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;
     }
 }
예제 #5
0
 private void CheckDeleteByImmediateParentSupport()
 {
     if (this.fluentMethodGroup.Level > 0)
     {
         foreach (MethodJvaf innerMethod in fluentMethodGroup.InnerMethods.Where(method => method.HttpMethod == HttpMethod.Delete))
         {
             ISegmentFluentMethodGroup 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.supportsDeleteByImmediateParent = true;
                                 this.deleteByImmediateParentMethod   = new StandardFluentMethod(innerMethod, this.fluentMethodGroup);
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
     else
     {
         this.supportsDeleteByImmediateParent = false;
         this.deleteByImmediateParentMethod   = null;
     }
 }
 public GetByResourceGroupDescription(ISegmentFluentMethodGroup fluentMethodGroup, IGetInnerAsyncFuncFactory getInnerAsyncFuncFactory)
 {
     this.FluentMethodGroup        = fluentMethodGroup;
     this.getInnerAsyncFuncFactory = getInnerAsyncFuncFactory;
 }
예제 #7
0
 public GetByParameterizedParentDescription(ISegmentFluentMethodGroup fluentMethodGroup, IGetInnerAsyncFuncFactory getInnerAsyncFuncFactory)
 {
     this.FluentMethodGroup        = fluentMethodGroup;
     this.getInnerAsyncFuncFactory = getInnerAsyncFuncFactory;
 }
 public void AddToChildFluentMethodGroup(ISegmentFluentMethodGroup fluentMethodGroup)
 {
     this.childFluentMethodGroups.Add(fluentMethodGroup);
 }
 public void SetParentFluentMethodGroup(ISegmentFluentMethodGroup fluentMethodGroup)
 {
     this.ParentFluentMethodGroup = fluentMethodGroup;
 }
예제 #10
0
        public static StandardMethodsInfo StandardMethodsInfo(this ISegmentFluentMethodGroup fluentMethodGroup)
        {
            StandardMethodsInfo standardMethods = new StandardMethodsInfo();
            //
            HashSet <string> knownMethodNames = new HashSet <string>();

            if (fluentMethodGroup.ResourceCreateDescription.SupportsCreating)
            {
                standardMethods.InnerMethodNames.Add(fluentMethodGroup.ResourceCreateDescription.CreateMethod.Name.ToLowerInvariant());
            }

            if (fluentMethodGroup.ResourceUpdateDescription.SupportsUpdating)
            {
                standardMethods.InnerMethodNames.Add(fluentMethodGroup.ResourceUpdateDescription.UpdateMethod.Name.ToLowerInvariant());
                //
                StandardFluentMethod updateMethod = fluentMethodGroup.ResourceUpdateDescription.UpdateMethod;
                if (updateMethod.InnerMethod.HttpMethod == HttpMethod.Put)
                {
                    // If PUT based update is supported then skip any PATCH based update method
                    // being treated as "Other methods".
                    //
                    var patchUpdateMethod = fluentMethodGroup.InnerMethods
                                            .Where(m => m.HttpMethod == HttpMethod.Patch)
                                            .Where(m => m.Url.EqualsIgnoreCase(updateMethod.InnerMethod.Url))
                                            .FirstOrDefault();
                    if (patchUpdateMethod != null)
                    {
                        standardMethods.InnerMethodNames.Add(patchUpdateMethod.Name.ToLowerInvariant());
                    }
                }
            }

            if (fluentMethodGroup.ResourceListingDescription.SupportsListByImmediateParent)
            {
                standardMethods.InnerMethodNames.Add(fluentMethodGroup.ResourceListingDescription.ListByImmediateParentMethod.Name.ToLowerInvariant());
            }

            if (fluentMethodGroup.ResourceListingDescription.SupportsListByResourceGroup)
            {
                standardMethods.InnerMethodNames.Add(fluentMethodGroup.ResourceListingDescription.ListByResourceGroupMethod.Name.ToLowerInvariant());
                standardMethods.FluentMethodNames.Add("listByResourceGroup".ToLowerInvariant());
            }

            if (fluentMethodGroup.ResourceListingDescription.SupportsListBySubscription)
            {
                standardMethods.InnerMethodNames.Add(fluentMethodGroup.ResourceListingDescription.ListBySubscriptionMethod.Name.ToLowerInvariant());
                standardMethods.FluentMethodNames.Add("list".ToLowerInvariant());
            }

            if (fluentMethodGroup.ResourceGetDescription.SupportsGetByImmediateParent)
            {
                standardMethods.InnerMethodNames.Add(fluentMethodGroup.ResourceGetDescription.GetByImmediateParentMethod.Name.ToLowerInvariant());
            }

            if (fluentMethodGroup.ResourceGetDescription.SupportsGetByResourceGroup)
            {
                standardMethods.InnerMethodNames.Add(fluentMethodGroup.ResourceGetDescription.GetByResourceGroupMethod.Name.ToLowerInvariant());
                standardMethods.FluentMethodNames.Add("getByResourceGroup".ToLowerInvariant());
            }

            if (fluentMethodGroup.ResourceDeleteDescription.SupportsDeleteByImmediateParent)
            {
                standardMethods.InnerMethodNames.Add(fluentMethodGroup.ResourceDeleteDescription.DeleteByImmediateParentMethod.Name.ToLowerInvariant());
            }

            if (fluentMethodGroup.ResourceDeleteDescription.SupportsDeleteByResourceGroup)
            {
                standardMethods.InnerMethodNames.Add(fluentMethodGroup.ResourceDeleteDescription.DeleteByResourceGroupMethod.Name.ToLowerInvariant());
                standardMethods.FluentMethodNames.Add("deleteByResourceGroup".ToLowerInvariant());
                standardMethods.FluentMethodNames.Add("deleteByIds".ToLowerInvariant());
            }
            //
            return(standardMethods);
        }
예제 #11
0
 public OtherMethod(MethodJvaf innerMethod, ISegmentFluentMethodGroup methodGroup)
 {
     this.InnerMethod       = innerMethod;
     this.FluentMethodGroup = methodGroup;
 }
예제 #12
0
 public DictionaryModel(DictionaryTypeJv rawModel, ISegmentFluentMethodGroup fluentMethodGroup)
 {
     this.RawModel          = rawModel;
     this.fluentMethodGroup = fluentMethodGroup;
 }