private void constructOrderedList(ModelTemplateModel model, List<ModelTemplateModel> orderedList)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            // BaseResource and CloudError are specified in the ClientRuntime. 
            // They are required explicitly in a different way. Hence, they
            // are not included in the ordered list.
            if (model.BaseModelType == null ||
                (model.BaseModelType != null && 
                 (model.BaseModelType.Name == "BaseResource" || 
                  model.BaseModelType.Name == "CloudError")))
            {
                if (!orderedList.Contains(model))
                {
                    orderedList.Add(model);
                }
                return;
            }

            var baseModel = ModelTemplateModels.FirstOrDefault(m => m.Name == model.BaseModelType.Name);
            if (baseModel != null)
            {
                constructOrderedList(baseModel, orderedList);
            }
            // Add the child type after the parent type has been added.
            if (!orderedList.Contains(model))
            {
                orderedList.Add(model);
            }
        }
Beispiel #2
0
        private void constructOrderedList(ModelTemplateModel model, List <ModelTemplateModel> orderedList)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            // BaseResource and CloudError are specified in the ClientRuntime.
            // They are required explicitly in a different way. Hence, they
            // are not included in the ordered list.
            if (model.BaseModelType == null ||
                (model.BaseModelType != null &&
                 (model.BaseModelType.Name == "BaseResource" ||
                  model.BaseModelType.Name == "CloudError")))
            {
                if (!orderedList.Contains(model))
                {
                    orderedList.Add(model);
                }
                return;
            }

            var baseModel = ModelTemplateModels.FirstOrDefault(m => m.Name == model.BaseModelType.Name);

            if (baseModel != null)
            {
                constructOrderedList(baseModel, orderedList);
            }
            // Add the child type after the parent type has been added.
            if (!orderedList.Contains(model))
            {
                orderedList.Add(model);
            }
        }
 public ModelTemplateModel(CompositeType source, ServiceClient serviceClient)
 {
     this.LoadFrom(source);
     ServiceClient = serviceClient;
     if (source.BaseModelType != null)
     {
         _parent = new ModelTemplateModel(source.BaseModelType, serviceClient);
     }
 }
Beispiel #4
0
 public ModelTemplateModel(CompositeType source, ServiceClient serviceClient)
 {
     this.LoadFrom(source);
     ServiceClient = serviceClient;
     if(source.BaseModelType != null)
     {
         _parent = new ModelTemplateModel(source.BaseModelType, serviceClient);
     }
 }
 public ModelTemplateModel(CompositeType source, ServiceClient serviceClient)
 {
     if (!string.IsNullOrEmpty(source.PolymorphicDiscriminator))
     {
         if (!source.Properties.Any(p => p.Name == source.PolymorphicDiscriminator))
         {
             var polymorphicProperty = new Property
             {
                 IsRequired = true,
                 Name = source.PolymorphicDiscriminator,
                 SerializedName = source.PolymorphicDiscriminator,
                 Documentation = "Polymorhpic Discriminator",
                 Type = PrimaryType.String
             };
             source.Properties.Add(polymorphicProperty);
         }
     }
     this.LoadFrom(source);
     ServiceClient = serviceClient;
     if (source.BaseModelType != null)
     {
         _parent = new ModelTemplateModel(source.BaseModelType, serviceClient);
     }
 }
 public ModelTemplateModel(CompositeType source, ServiceClient serviceClient)
 {
     if (!string.IsNullOrEmpty(source.PolymorphicDiscriminator))
     {
         if (!source.Properties.Any(p => p.Name == source.PolymorphicDiscriminator))
         {
             var polymorphicProperty = new Property
             {
                 IsRequired     = true,
                 Name           = source.PolymorphicDiscriminator,
                 SerializedName = source.PolymorphicDiscriminator,
                 Documentation  = "Polymorhpic Discriminator",
                 Type           = PrimaryType.String
             };
             source.Properties.Add(polymorphicProperty);
         }
     }
     this.LoadFrom(source);
     ServiceClient = serviceClient;
     if (source.BaseModelType != null)
     {
         _parent = new ModelTemplateModel(source.BaseModelType, serviceClient);
     }
 }