Exemple #1
0
        /// <summary>
        /// Generates the model from user input.
        /// </summary>
        /// <param name="model">This is null since the instance doesn't exist yet</param>
        /// <returns>The generated model from user input</returns>
        protected override IEnumerable <Model.AzureSqlManagedInstanceModel> ApplyUserInputToModel(IEnumerable <Model.AzureSqlManagedInstanceModel> model)
        {
            List <Model.AzureSqlManagedInstanceModel> newEntity = new List <Model.AzureSqlManagedInstanceModel>();

            Management.Internal.Resources.Models.Sku Sku = new Management.Internal.Resources.Models.Sku();

            if (string.Equals(this.ParameterSetName, NewBySkuNameParameterSet, System.StringComparison.OrdinalIgnoreCase))
            {
                Sku.Name = SkuName;
            }
            else if (string.Equals(this.ParameterSetName, NewByEditionAndComputeGenerationParameterSet, System.StringComparison.OrdinalIgnoreCase))
            {
                string editionShort = Edition.Equals(Constants.GeneralPurposeEdition) ? "GP" : Edition.Equals(Constants.BusinessCriticalEdition) ? "BC" : "Unknown";
                Sku.Name = editionShort + "_" + ComputeGeneration;
            }

            newEntity.Add(new Model.AzureSqlManagedInstanceModel()
            {
                Location                 = this.Location,
                ResourceGroupName        = this.ResourceGroupName,
                FullyQualifiedDomainName = this.Name,
                AdministratorLogin       = this.AdministratorCredential.UserName,
                AdministratorPassword    = this.AdministratorCredential.Password,
                Tags            = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
                Identity        = ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent),
                LicenseType     = this.LicenseType,
                StorageSizeInGB = this.StorageSizeInGB,
                SubnetId        = this.SubnetId,
                VCores          = this.VCore,
                Sku             = Sku,
                Collation       = this.Collation
            });
            return(newEntity);
        }
Exemple #2
0
        /// <summary>
        /// Generates the model from user input.
        /// </summary>
        /// <param name="model">This is null since the instance pool doesn't exist yet</param>
        /// <returns>The generated model from user input</returns>
        protected override IEnumerable <AzureSqlInstancePoolModel> ApplyUserInputToModel
            (IEnumerable <AzureSqlInstancePoolModel> model)
        {
            string editionShort = Edition.Equals(Constants.GeneralPurposeEdition) ? "GP" :
                                  Edition.Equals(Constants.BusinessCriticalEdition) ? "BC" : "Unknown";
            string skuName = editionShort + "_" + ComputeGeneration;

            AzureSqlInstancePoolModel newEntity = new AzureSqlInstancePoolModel
            {
                Location          = this.Location,
                ResourceGroupName = this.ResourceGroupName,
                InstancePoolName  = this.Name,
                Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
                Sku  = new Sku()
                {
                    Name   = skuName,
                    Tier   = Edition,
                    Family = ComputeGeneration
                },
                SubnetId    = SubnetId,
                VCores      = VCore,
                LicenseType = LicenseType,
            };

            return(new List <AzureSqlInstancePoolModel> {
                newEntity
            });
        }
        public void EqualsShouldBeTrue()
        {
            Edition actual = new Edition()
            {
                PageNumber   = 100,
                Year         = 2019,
                BookType     = EBookType.EHardCover,
                Publisher    = "Humanitas",
                NoTotal      = 10,
                NoForLibrary = 2,
                NoForLoan    = 8,
            };

            Assert.IsTrue(actual.Equals(edition));
        }
        public void EqualsShouldBeFalse()
        {
            Edition expected = new Edition()
            {
                Id           = 6,
                PageNumber   = 10,
                Year         = 2000,
                BookType     = EBookType.EHardCover,
                Publisher    = "All",
                NoTotal      = 4,
                NoForLibrary = 2,
                NoForLoan    = 2,
            };

            Assert.IsFalse(expected.Equals(edition));
        }
        public override bool Equals(object obj)
        {
            CongressComunication other = obj as CongressComunication;

            if (other == null)
            {
                return(false);
            }

            bool a = Congress == null ? other.Congress == null : Congress.Equals(other.Congress);
            bool b = Edition == null ? other.Edition == null : Edition.Equals(other.Edition);
            bool c = Place == null ? other.Place == null : Place.Equals(other.Place);
            bool d = InitialPage == null ? other.InitialPage == null : InitialPage.Equals(other.InitialPage);
            bool e = FinalPage == null ? other.FinalPage == null : FinalPage.Equals(other.FinalPage);
            bool f = base.Equals(obj);

            return(a && b && c && d && e && f);
        }
Exemple #6
0
        /// <summary>
        /// Constructs the model to send to the update API
        /// </summary>
        /// <param name="model">The result of the get operation</param>
        /// <returns>The model to send to the update</returns>
        protected override IEnumerable <Model.AzureSqlManagedInstanceModel> ApplyUserInputToModel(IEnumerable <Model.AzureSqlManagedInstanceModel> model)
        {
            AzureSqlManagedInstanceModel existingInstance = ModelAdapter.GetManagedInstance(this.ResourceGroupName, this.Name);

            Management.Internal.Resources.Models.Sku Sku = new Management.Internal.Resources.Models.Sku();

            if (Edition != null)
            {
                string computeGeneration = existingInstance.Sku.Name.Contains(Constants.ComputeGenerationGen4) ? Constants.ComputeGenerationGen4 : Constants.ComputeGenerationGen5;
                string editionShort      = Edition.Equals(Constants.GeneralPurposeEdition) ? "GP" : Edition.Equals(Constants.BusinessCriticalEdition) ? "BC" : "Unknown";
                Sku.Name = editionShort + "_" + computeGeneration;
                Sku.Tier = Edition;
            }
            else
            {
                Sku = null;
            }

            // Construct a new entity so we only send the relevant data to the Managed instance
            List <Model.AzureSqlManagedInstanceModel> updateData = new List <Model.AzureSqlManagedInstanceModel>();

            updateData.Add(new Model.AzureSqlManagedInstanceModel()
            {
                ResourceGroupName        = this.ResourceGroupName,
                ManagedInstanceName      = this.Name,
                FullyQualifiedDomainName = this.Name,
                Location = model.FirstOrDefault().Location,
                Sku      = Sku,
                AdministratorPassword = this.AdministratorPassword,
                LicenseType           = this.LicenseType,
                StorageSizeInGB       = this.StorageSizeInGB ?? model.FirstOrDefault().StorageSizeInGB,
                VCores   = this.VCore,
                Tags     = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
                Identity = model.FirstOrDefault().Identity ?? ResourceIdentityHelper.GetIdentityObjectFromType(this.AssignIdentity.IsPresent),
            });
            return(updateData);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            //===============================lab1=================================
            /*Magazine magazine = 
                new Magazine("How to find...", Frequency.Yearly, new DateTime(2016, 11, 12), 1, new Article[] {new Article()});


            Console.WriteLine("Yarly: " + magazine[Frequency.Yearly]);
            Console.WriteLine("Monthly: " + magazine[Frequency.Montly]);
            Console.WriteLine("Weekly: " + magazine[Frequency.Weekly]);

            magazine.Shedule = Frequency.Yearly;
            magazine.Articles = new Article[] {new Article(new Person("Poll", "Tripp", new DateTime(1,1,1)), "Word's war", 6.7)};
            magazine.Edition = 500;
            magazine.Release = DateTime.Now;
            magazine.Title = "Last hope";
            
            Console.WriteLine(magazine);

            Article[] articles = new Article[]
            {
                new Article(new Person("Poll", "Tripp", new DateTime(1,1,1)), "Word's war", 6.7),
                new Article(new Person("Mia", "Ogliche", new DateTime(1,1,1)), "Girl with lovely heart", 4.3),
                new Article(new Person("Stiv", "Nesh", new DateTime(1,1,1)), "Evangelism", 9.1)
           
            };

            magazine.AddArticles(articles);

            Console.WriteLine(magazine);

            Method();
       
            Console.ReadLine();*/

            //================================Lab2=====================
            Edition ed1 = new Edition();
            Edition ed2 = new Edition();
            Console.WriteLine("ed1 equals ed2 {0}\n{1} - reference equals.", ed1.Equals(ed2), Object.ReferenceEquals(ed1, ed2));
            try
            {
                ed1.Edition = -1;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Circulation can not be negative!\n" + ex.Message);
            }

            Article[] arts3 = new Article[2];
            arts3[0] = new Article(p1, "Title 1", 99.9);
            arts3[1] = new Article();
            Article[] arts4 = new Article[2];
            arts4[0] = new Article(p1, "Title 2", 59.9);
            arts4[1] = new Article(p2, "Title 4", 66.4);
            Person[] edtrs = new Person[3];
            edtrs[0] = new Person("Name1", "LastName1", new DateTime(1966, 10, 10));
            edtrs[1] = new Person("Name2", "LastName2", new DateTime(1982, 12, 31));
            edtrs[2] = new Person();

            Magazine m4 = new Magazine("Magazine 1", Frequency.Monthly, new DateTime(2000, 1, 1), 1000);
            m4.AddEditors(edtrs);
            m4.AddArticles(arts3);
            Console.WriteLine("{0},\n{1}", m4.ToString(), m4.EditionProp);

            var deepCopy = (Magazine)m4.DeepCopy();
            m4.Edition = 2000;
            m4.Release = new DateTime(1999, 12, 12);
            m4.AddArticles(arts4);

            Console.WriteLine("m4:\n{0}\nDeep copy:\n{1}", m4.ToString(), deepCopy.ToString());
            Console.WriteLine("Top articles:");
            foreach (Article m in m4.TopArticles(60))
                Console.WriteLine(m.ToString());
            Console.WriteLine("Similar articles:");
            foreach (Article m in m4.SimilarArticles("title"))
                Console.WriteLine(m.ToString());



            Console.WriteLine("\nMagazineEnumerator:");
            foreach (Article art in m4.ArticlesList)
            {
                Console.WriteLine("{0}", art.ToString());
            }

            Console.WriteLine("\nArticles by editors:");
            foreach (Article art in m4.ArticlesByEditors())
                Console.WriteLine(art.ToString());

            Console.WriteLine("\nEditors without articles:");
            foreach (Person p in m4.EditorsWithoutArticles())
                Console.WriteLine(p.ToString());

            //=====================================lab3=================================
          
            MagazineCollection mc = new MagazineCollection();
            mc.AddDefaults();
            //Console.WriteLine("\nMagazines:");
            //mc.ToString();
            Console.WriteLine("\nBy title:");
            mc.SortByTitle();
            Console.WriteLine(mc.ToString());
            Console.WriteLine("By release date:");
            mc.SortByReleaseDate();
            Console.WriteLine(mc.ToString());
            Console.WriteLine("By circulation:");
            mc.SortByCiculation(true);
            Console.WriteLine(mc.ToString());

            Console.WriteLine(mc.maxAverageRating);
            IEnumerable monthly = mc.GetMonthly;
            foreach (Magazine m in monthly)
                Console.WriteLine(m.ToString());
            double minrate = 70;
            Console.WriteLine("rating more than {0}:", minrate);
            List<Magazine> l = mc.RatingGroup(minrate);
            foreach (Magazine m in l)
                Console.WriteLine(m.ToString());
            int quantity = 1000;
            TestCollections collections = new TestCollections(quantity);
            Edition e1 = new Edition();
            e1.Title = e1.Title + "-0";
            Edition e2 = new Edition();
            e2.Title = e2.Title + "-" + (quantity - 1);
            Edition e3 = new Edition();
            e3.Title = e3.Title + "-" + quantity / 2;
            Edition e4 = new Edition();
            e4.Title = e4.Title + "10";

            /*Console.WriteLine("The first: {0}",collections.SearchingTime(e1));
			Console.WriteLine("The last: {0}", collections.SearchingTime(e2));
			Console.WriteLine("The middle: {0}", collections.SearchingTime(e3));
			Console.WriteLine("Not belongs to list: {0}", collections.SearchingTime(e4));*/
            Console.WriteLine("///////////////////////////Lab 4////////////////////");
      
            //==============================lab4=============================================

            MagazineCollection col1 = new MagazineCollection();
            MagazineCollection col2 = new MagazineCollection();

            Listener l1 = new Listener();
            Listener l2 = new Listener();
            col1.MagazineAdded += l1.EventHandler;
            col1.MagazineReplaced += l1.EventHandler;

            col2.MagazineAdded += l2.EventHandler;
            col2.MagazineReplaced += l2.EventHandler;
            col1.MagazineAdded += l2.EventHandler;
            col1.MagazineReplaced += l2.EventHandler;

            col1.collectionName = "Collection 1";
            col2.collectionName = "Collection 2";

            col1.AddDefaults();
            col2.AddDefaults();
            col2[1] = new Magazine();
            col1[3] = new Magazine();
            col1.Replace(2, new Magazine());
            Console.WriteLine("First listener:\n{0}", l1.ToString());

            Console.WriteLine("Second listener:\n{0}", l2.ToString());


            Console.WriteLine("///////////////////////////Lab 5////////////////////");
          
            //=================================lab5=========================

            Magazine mag1 = new Magazine();

            mag1.AddEditors(edtrs);
            mag1.AddArticles(arts3);
            mag1.Title = "Magazine to save";
            mag1.Circulation = 100500;
            mag1.Rate = Frequency.Monthly;
            Magazine mag1Copy = Magazine.DeepCopy(mag1);
            Console.WriteLine("Original object: {0}", mag1.ToString());
            Console.WriteLine("Deepcopy object: {0}", mag1Copy.ToString());
            Console.WriteLine("Type in a name of the file:");
            string file = Console.ReadLine();
            mag1.Load(file);
            Console.WriteLine(mag1.ToString());
            mag1.AddFromConsole();
            mag1.Save(file);
            Console.WriteLine(mag1.ToString());
            Magazine.Load(file, mag1);
            mag1.AddFromConsole();
            Magazine.Save(file, mag1);
            //mag1.Save("mag1.txt");
            /*Magazine mag2 = new Magazine();
			mag2.Load("mag1.txt");
			
			
			Console.WriteLine("Saved object: {0}", mag1.ToString());
			Console.WriteLine("Object from file: {0}", mag2.ToString());

			Magazine mag3 = new Magazine();
			mag3.AddFromConsole();
			*/

            Console.ReadLine();
        }