예제 #1
0
파일: AddressDTO.cs 프로젝트: ooleoole/Ros
        private void ValidateCity(string city)
        {
            NullCheck.ThrowArgumentNullEx(city);
            if (city.Any(char.IsDigit))
            {
                throw new ArgumentException($"{nameof(city)} cannot contain digits.");
            }
            if (CityMinLength > city.Length || city.Length > CityMaxLength)
            {
                throw new ArgumentException($"{nameof(city)} must have a length between {CityMinLength} and {CityMaxLength}.");
            }
            if (CityStartsWithWhiteSpace())
            {
                throw new ArgumentException($"{nameof(city)} cannot start with a white-space character.");
            }
            if (CityEndsWithWhiteSpace())
            {
                throw new ArgumentException($"{nameof(city)} cannot end with a white-space character.");
            }
            if (CityStartsLowerCase())
            {
                throw new ArgumentException($"{nameof(city)} cannot start with a lower case.");
            }
            if (CityEndsWithUpperCase())
            {
                throw new ArgumentException($"{nameof(city)} cannot end with a upper case.");
            }
            if (CityContainsIllegalCharacters())
            {
                throw new ArgumentException($"{nameof(city)} can only contain letters and white-space characters.");
            }

            bool CityStartsWithWhiteSpace() => city[0] == ' ';
            bool CityEndsWithWhiteSpace() => city[city.Length - 1] == ' ';
            bool CityStartsLowerCase() => char.IsLower(city[0]);
            bool CityEndsWithUpperCase() => city.Length > 1 && char.IsUpper(city[city.Length - 1]);
            bool CityContainsIllegalCharacters() => city.Any(character =>
                                                             !char.IsLetter(character) &&
                                                             character != ' ');
        }
예제 #2
0
        public async Task <IActionResult> ConsumableAnonymousContactAsync([FromBody] ContactInformationDemand contactInformationDemand, int id)
        {
            NullCheck.ThrowIfNull <ContactInformationDemand>(contactInformationDemand);

            try
            {
                _mailInputValidatorService.validateMail(contactInformationDemand.senderEmail);
                ConsumableDemandEntity consumable = await _resourceDemandQueryService.FindAsync(new ConsumableDemandEntity(), id);

                if (consumable is null)
                {
                    return(NotFound(FailureCodes.NotFoundDevice));
                }

                DemandEntity demand = await _resourceDemandQueryService.FindAsync(new DemandEntity(), consumable.demand_id);

                if (demand is null)
                {
                    return(NotFound(FailureCodes.NotFoundOffer));
                }

                var resourceNameDE = _languageDE.Consumable[consumable.category];
                var resourceNameEN = _languageEN.Consumable[consumable.category];

                var mailAddressReceiver  = demand.mail;
                var mailUserNameReceiver = demand.name;
                // TODO
                var region = "de";
                await _mailService.SendOfferMailToDemanderAsync(region, contactInformationDemand, mailAddressReceiver,
                                                                mailUserNameReceiver, resourceNameDE, resourceNameEN);

                await _mailService.SendDemandConformationMailToDemanderAsync(region, contactInformationDemand);

                return(Ok());
            }
            catch (ArgumentException e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #3
0
        public async Task <IActionResult> GetAsync([FromQuery][Required] string region,
                                                   [FromQuery] Consumable consumable, [FromQuery] Address address)
        {
            NullCheck.ThrowIfNull <Consumable>(consumable);
            NullCheck.ThrowIfNull <Address>(address);

            try
            {
                _configurationService.ThrowIfUnknownRegion(region);
                consumable.address = address;
                _resourceStockInputValidatorService.ValidateForStockQuery(consumable);
                return(Ok(await _resourceStockQueryService.QueryOffersAsync(consumable, region).ToListAsync()));
            }
            catch (ArgumentException e)
            {
                return(BadRequest(e.Message));
            }
            catch (UnknownAdressException e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #4
0
        public void LoadData()
        {
            DataTable dt = Sql.GetTable(SelectProcedure, new object[] { "@ItemId", ItemId });

            if (dt.Rows.Count > 0)
            {
                tItemCode.Text          = NullCheck.IsNullString(dt.Rows[0]["Code"]);
                tItemName.Text          = NullCheck.IsNullString(dt.Rows[0]["Name"]);
                tItemDescription.Text   = NullCheck.IsNullString(dt.Rows[0]["Description"]);
                cItemType.SelectedValue = NullCheck.IsNullString(dt.Rows[0]["TypeId"]);
                tNetWeight.Text         = NullCheck.IsNullString(dt.Rows[0]["NetWeight"]);
                tBrutoWeight.Text       = NullCheck.IsNullString(dt.Rows[0]["BrutoWeight"]);
                tVolume.Text            = NullCheck.IsNullString(dt.Rows[0]["Volume"]);
                cMU.SelectedValue       = NullCheck.IsNullString(dt.Rows[0]["MeasureUnitId"]);
                tCreateDate.Text        = NullCheck.IsNullDate(dt.Rows[0]["CreateDate"]).ToShortDateString();
                tUpdated.Text           = NullCheck.IsNullDate(dt.Rows[0]["UpdateDate"]).ToShortDateString();
                tWarehouseId.Text       = NullCheck.IsNullString(dt.Rows[0]["WarehouseCode"]);
                tBarcode.Text           = NullCheck.IsNullString(dt.Rows[0]["Barcode"]);
                tWidth.Text             = NullCheck.IsNullString(dt.Rows[0]["Width"]);
                tHeight.Text            = NullCheck.IsNullString(dt.Rows[0]["Height"]);
            }
        }
예제 #5
0
 public void SaveRow(DataGridViewRow row)
 {
     if (NullCheck.IsNullInt(row.Cells["ItemId"].Value) > 0 && NullCheck.IsNullDecimal(row.Cells["Quantity"].Value) > 0)
     {
         Sql.ExecuteCmd(NullCheck.IsNullInt(row.Cells["OrderedItemId"].Value) <= 0 ? SaveRcvDocDet : UpdateRcvDocDet, new object[]
         {
             "@OrderedItemId", NullCheck.IsNullInt(row.Cells["OrderedItemId"].Value),
             "@Quantity", NullCheck.IsNullDecimal(row.Cells["Quantity"].Value),
             "@Created", DateTime.Now,
             "@Updated", DateTime.Now,
             "@ItemId", NullCheck.IsNullInt(row.Cells["ItemId"].Value),
             "@RcvDocId", CurrentRcvDocId
         });
         _handle = false;
         if (NullCheck.IsNullInt(row.Cells["OrderedItemId"].Value) <= 0)
         {
             ((DataTable)dataGridView2.DataSource).Rows.Add();
         }
         row.Cells["OrderedItemId"].Value = NullCheck.IsNullInt(Sql.GetString($"SELECT dbo.ValidateDetSave('{NullCheck.IsNullInt(row.Cells["ItemId"].Value)}','{CurrentRcvDocId}')"));
         _handle = true;
     }
 }
예제 #6
0
    protected override void Start()
    {
        base.Start();

        Container = LiquidContainer.FindLiquidContainer(transform);
        Assert.IsNotNull(Container);
        ObjectType = ObjectType.Syringe;

        Type.On(InteractableType.Attachable, InteractableType.HasLiquid, InteractableType.Interactable, InteractableType.SmallObject);

        Container.OnAmountChange += SetSyringeHandlePosition;
        SetSyringeHandlePosition();

        hasBeenInBottle = false;

        syringeCap = transform.Find("syringe_cap").gameObject;
        NullCheck.Check(syringeCap);

        syringeCap.SetActive(false);

        liquidDisplay = Resources.Load <GameObject>("Prefabs/LiquidDisplay");
        displayState  = false;
    }
예제 #7
0
        public async Task <IActionResult> ChangeAmountDeviceAsync(string token, int id, [FromBody] AmountChange amountChange)
        {
            NullCheck.ThrowIfNull <AmountChange>(amountChange);

            try
            {
                await _resourceStockUpdateService.ChangeDeviceAmountAsync(token, id, amountChange.amount, amountChange.reason);

                return(Ok());
            }
            catch (ArgumentException e)
            {
                return(BadRequest(e.Message));
            }
            catch (DataNotFoundException e)
            {
                return(NotFound(e.Message));
            }
            catch (InvalidDataStateException e)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, e));
            }
        }
예제 #8
0
        public async Task <IActionResult> ConsumableAnonymousContactAsync([FromBody] ContactInformationDemand contactInformationDemand,
                                                                          int id)
        {
            NullCheck.ThrowIfNull <ContactInformationDemand>(contactInformationDemand);

            try
            {
                _mailInputValidatorService.validateMail(contactInformationDemand.senderEmail);

                var consumable = (ConsumableEntity)await _resourceStockQueryService.FindAsync(new ConsumableEntity(), id);

                if (consumable is null)
                {
                    return(NotFound(FailureCodes.NotFoundConsumable));
                }

                var offer = (OfferEntity)await _resourceStockQueryService.FindAsync(new OfferEntity(), consumable.offer_id);

                if (offer is null)
                {
                    return(NotFound(FailureCodes.NotFoundOffer));
                }

                var mailAddressReceiver  = offer.mail;
                var mailUserNameReceiver = offer.name;
                await _mailService.SendDemandMailToProviderAsync(offer.region, contactInformationDemand, mailAddressReceiver,
                                                                 mailUserNameReceiver);

                await _mailService.SendDemandConformationMailToDemanderAsync(offer.region, contactInformationDemand);

                return(Ok());
            }
            catch (ArgumentException e)
            {
                return(BadRequest(e.Message));
            }
        }
예제 #9
0
        private bool ValidInput()
        {
            string errorMsg = string.Empty;

            if (string.IsNullOrEmpty(tCode.Text))
            {
                tCode.Invalidate();
                errorMsg += "Negalimas sandėlio kodas\n";
            }
            if (string.IsNullOrEmpty(tName.Text))
            {
                tName.Invalidate();
                errorMsg += "Negalimas sandėlio pavadinimas\n";
            }

            int Exists = NullCheck.IsNullInt(Sql.GetString($"SELECT dbo.ValidateWarehouse('{tCode.Text}', '{tName.Text}')"));

            if (Exists > 0 && WarehouseId < 0)
            {
                errorMsg += "Sandėlio kodo ir pavadinimo kombinacija nėra unikali\n";
            }

            if (Exists > 0 && WarehouseId > 0)
            {
                if (NullCheck.IsNullInt(Sql.GetString($"SELECT dbo.CheckIfWarehouseIsUnique('{WarehouseId}','{tName.Text}','{tCode.Text}')")) == 0)
                {
                    errorMsg += "Sandėlio kodo ir pavadinimo kombinacija nėra unikali\n";
                }
            }

            if (!string.IsNullOrEmpty(errorMsg))
            {
                MessageBox.Show("Negalima išsaugoti sandėlio:\n" + errorMsg, "Klaida", MessageBoxButtons.OK);
                return(false);
            }
            return(true);
        }
예제 #10
0
파일: AddressDTO.cs 프로젝트: ooleoole/Ros
        private void ValidateStreet(string street)
        {
            NullCheck.ThrowArgumentNullEx(street);
            if (StreetMinLength > street.Length || street.Length > StreetMaxLength)
            {
                throw new ArgumentException($"{nameof(street)} must have a length between {StreetMinLength} and {StreetMaxLength}.");
            }
            if (StreetStartsWithWhiteSpace())
            {
                throw new ArgumentException($"{nameof(street)} cannot start with a white-space character.");
            }
            if (StreetEndsWithWhiteSpace())
            {
                throw new ArgumentException($"{nameof(street)} cannot end with a white-space character.");
            }
            if (StreetStartsWithDigit())
            {
                throw new ArgumentException($"{nameof(street)} cannot start with a digit.");
            }
            if (StreetDoesNotContainAnyWhiteSpace())
            {
                throw new ArgumentException($"{nameof(street)} does not contain any white-space characters.");
            }
            if (StreetContainsIllegalCharacters())
            {
                throw new ArgumentException($"{nameof(street)} can only contain letters, digits and white-space characters.");
            }

            bool StreetStartsWithWhiteSpace() => street[0] == ' ';
            bool StreetEndsWithWhiteSpace() => street[street.Length - 1] == ' ';
            bool StreetStartsWithDigit() => char.IsDigit(street[0]);
            bool StreetDoesNotContainAnyWhiteSpace() => street.All(character => character != ' ');
            bool StreetContainsIllegalCharacters() => street.Any(character =>
                                                                 !char.IsLetter(character) &&
                                                                 !char.IsDigit(character) &&
                                                                 character != ' ');
        }
예제 #11
0
        private void SetupForm()
        {
            DataTable dt = Sql.GetTable(WarehouseComboSql);

            if (dt != null && dt.Rows.Count > 0)
            {
                if (dt.AsEnumerable().Where(x => x.Field <string>("WarehouseCode") == "TEST").FirstOrDefault() != null)
                {
                    GlobalUser.SetWarehouseId(NullCheck.IsNullInt(dt.AsEnumerable().Where(x => x.Field <string>("WarehouseCode") == "TEST").FirstOrDefault()["WarehouseId"]));
                }
                else
                {
                    GlobalUser.SetWarehouseId(NullCheck.IsNullInt(dt.Rows[0]["WarehouseId"]));
                }
            }
            else
            {
                MessageBox.Show("Nerastas registruotas sandėlys sistemoje.", "Ispėjimas", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            this.MinimizeBox     = false;
            this.WindowState     = FormWindowState.Maximized;
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            SetupUserInfo();
        }
예제 #12
0
        private void LoadDView()
        {
            DataTable dt = Sql.GetTable("GetRcvOrdersForShipmentEditor", new object[]
            {
                "@ShipmentId", ShipmentId
            });

            dView.DataSource = dt;
            if (dt != null)
            {
                EditColumns();
                foreach (DataGridViewRow row in dView.Rows)
                {
                    if (NullCheck.IsNullInt(row.Cells["ShipmentId"].Value) == ShipmentId)
                    {
                        row.DefaultCellStyle.BackColor = Color.Cyan;
                    }
                    else
                    {
                        row.DefaultCellStyle.BackColor = Color.LightGreen;
                    }
                }
            }
        }
예제 #13
0
 public void RemovePhoneNumberFromClub(UserDTO caller, PhoneNumberDTO phoneNumber)
 {
     NullCheck.ThrowArgumentNullEx(caller, phoneNumber);
     CheckPermission(caller);
     RemoveRelationFromDb(GetRelation(phoneNumber));
 }
예제 #14
0
 public void RemoveEmailFromClub(UserDTO caller, EmailDTO email)
 {
     NullCheck.ThrowArgumentNullEx(caller, email);
     CheckPermission(caller);
     RemoveRelationFromDb(GetRelation(email));
 }
예제 #15
0
 public async Task DeleteAsync(ResourceContext context)
 {
     NullCheck.ThrowIfNull <ResourceContext>(context);
     context.address.Remove(this);
     await context.SaveChangesAsync();
 }
예제 #16
0
 public async Task <IFindable> FindAsync(ResourceContext context, int id)
 {
     NullCheck.ThrowIfNull <ResourceContext>(context);
     return(await context.address.FindAsync(id));
 }
예제 #17
0
        private static DataTable ProcessDataTableQuantityById(DataTable dt)
        {
            DataTable clone = dt.Clone();

            foreach (DataRow row in dt.Rows)
            {
                DataRow _row = clone.AsEnumerable().Where(x => x.Field <int>("ItemId") == NullCheck.IsNullInt(row["ItemId"])).FirstOrDefault();

                if (_row == null)
                {
                    clone.Rows.Add(row.ItemArray);
                }
                else
                {
                    _row["Quantity"] = NullCheck.IsNullDecimal(_row["Quantity"]) + NullCheck.IsNullDecimal(row["Quantity"]);
                }
            }

            return(clone);
        }
예제 #18
0
        public PluralizedStaticText Build()
        {
            NullCheck.Check(m_baseTextBuilder.CurrentInstance().IntervalTexts);

            return(m_baseTextBuilder.Build());
        }
        public void ValidateForStockInsertion(Personal personal)
        {
            NullCheck.ThrowIfNull <Personal>(personal);

            validateInformation(personal);
        }
예제 #20
0
 public async Task UpdateAsync(ResourceContext context)
 {
     NullCheck.ThrowIfNull <ResourceContext>(context);
     context.consumable.Update(this);
     await context.SaveChangesAsync();
 }
예제 #21
0
 private void AddRelationToDb(RegisteredUserDTO relation)
 {
     NullCheck.ThrowArgumentNullEx(relation);
     ServiceLocator.RegisteredUserService.Add(relation);
 }
예제 #22
0
 public static int ValidatePallet(string Barcode)
 {
     return(NullCheck.IsNullInt(Sql.GetString($"SELECT dbo.ValidateBarcode('{Barcode}')")));
 }
예제 #23
0
        public void VisitNode(JSIfStatement ifs)
        {
            var  boe                  = ifs.Condition as JSBinaryOperatorExpression;
            var  uoe                  = ifs.Condition as JSUnaryOperatorExpression;
            var  invocation           = ifs.Condition as JSInvocationExpression;
            bool invocationIsInverted = false;

            if ((boe != null) && (boe.Operator == JSOperator.Equal))
            {
                var leftVar     = boe.Left as JSVariable;
                var leftIgnored = boe.Left as JSIgnoredMemberReference;
                var rightNull   = (JSLiteral)(boe.Right as JSDefaultValueLiteral) ?? (JSLiteral)(boe.Right as JSNullLiteral);

                if (rightNull != null)
                {
                    if (leftVar != null)
                    {
                        NullChecks[leftVar] = new NullCheck {
                            Statement      = ifs,
                            SwitchVariable = leftVar,
                            Goto           = ifs.AllChildrenRecursive.OfType <JSGotoExpression>().FirstOrDefault()
                        };
                    }
                    else if (leftIgnored != null)
                    {
                        var leftField = leftIgnored.Member as FieldInfo;

                        if (leftField != null)
                        {
                            var initializer = Initializers[leftField] = new Initializer {
                                Field     = leftField,
                                Statement = ifs,
                            };

                            foreach (var _invocation in ifs.TrueClause.AllChildrenRecursive.OfType <JSInvocationExpression>())
                            {
                                if (_invocation.JSMethod == null)
                                {
                                    continue;
                                }
                                if (_invocation.JSMethod.Identifier != "Add")
                                {
                                    continue;
                                }
                                if (_invocation.Arguments.Count != 2)
                                {
                                    continue;
                                }

                                var value = _invocation.Arguments[0];
                                var index = _invocation.Arguments[1] as JSIntegerLiteral;
                                if (index == null)
                                {
                                    continue;
                                }

                                initializer.Values[(int)index.Value] = value;
                            }

                            foreach (var iae in ifs.TrueClause.AllChildrenRecursive.OfType <JSInitializerApplicationExpression>())
                            {
                                var targetNew = iae.Target as JSNewExpression;
                                if (targetNew == null)
                                {
                                    continue;
                                }

                                var targetNewJSType = targetNew.Type as JSType;
                                if (targetNewJSType == null)
                                {
                                    continue;
                                }

                                var targetNewType = targetNewJSType.Type as GenericInstanceType;
                                if (targetNewType == null)
                                {
                                    continue;
                                }
                                if (!targetNewType.Name.Contains("Dictionary"))
                                {
                                    continue;
                                }
                                if (targetNewType.GenericArguments.Count != 2)
                                {
                                    continue;
                                }
                                if (targetNewType.GenericArguments[1].MetadataType != MetadataType.Int32)
                                {
                                    continue;
                                }

                                var initArray = iae.Initializer as JSArrayExpression;
                                if (initArray == null)
                                {
                                    continue;
                                }

                                foreach (var item in initArray.Values)
                                {
                                    var itemArray = item as JSArrayExpression;
                                    if (itemArray == null)
                                    {
                                        continue;
                                    }

                                    var value = itemArray.Values.First();
                                    var index = itemArray.Values.Skip(1).First() as JSIntegerLiteral;
                                    if (index == null)
                                    {
                                        continue;
                                    }

                                    initializer.Values[(int)index.Value] = value;
                                }
                            }
                        }
                    }
                }
            }
            else if ((uoe != null) && (uoe.Operator == JSOperator.LogicalNot))
            {
                invocation           = uoe.Expression as JSInvocationExpression;
                invocationIsInverted = true;
            }

            if (
                (invocation != null) &&
                (invocation.Arguments.Count == 2) &&
                (invocation.JSMethod != null) &&
                (invocation.JSMethod.Identifier == "TryGetValue")
                )
            {
                var thisIgnored = invocation.ThisReference as JSIgnoredMemberReference;
                var switchVar   = invocation.Arguments[0] as JSVariable;
                var outRef      = invocation.Arguments[1] as JSPassByReferenceExpression;

                if ((thisIgnored != null) && (switchVar != null) && (outRef != null))
                {
                    var thisField   = thisIgnored.Member as FieldInfo;
                    var outReferent = outRef.Referent as JSReferenceExpression;

                    if ((thisField != null) && (outReferent != null))
                    {
                        var outVar = outReferent.Referent as JSVariable;

                        if (outVar != null)
                        {
                            IndexLookups[outVar] = new IndexLookup {
                                OutputVariable = outVar,
                                SwitchVariable = switchVar,
                                Field          = thisField,
                                Statement      = ifs,
                                Goto           = ifs.TrueClause.AllChildrenRecursive.OfType <JSGotoExpression>().FirstOrDefault(),
                                IsInverted     = invocationIsInverted
                            };

                            if (!invocationIsInverted)
                            {
                                var replacement = ifs.TrueClause;
                                ParentNode.ReplaceChild(ifs, replacement);
                                VisitReplacement(replacement);
                                return;
                            }
                        }
                    }
                }
            }

            VisitChildren(ifs);
        }
예제 #24
0
 public async Task DeleteAsync(ResourceContext context)
 {
     NullCheck.ThrowIfNull <ResourceContext>(context);
     context.demand_consumable.Remove(this);
     await context.SaveChangesAsync();
 }
예제 #25
0
 public ConsumableDemandEntity Build(AddressEntity a)
 {
     NullCheck.ThrowIfNull <AddressEntity>(a);
     return(this);
 }
예제 #26
0
 public Personal build(Address a)
 {
     NullCheck.ThrowIfNull <Address>(a);
     address = a;
     return(this);
 }
예제 #27
0
 public static int ZoneExists(string ZoneCode)
 {
     return(NullCheck.IsNullInt(Sql.GetString($"SELECT dbo.ValidateReceivingLocation('{GlobalUser.CurrentWarehouseId}','{ZoneCode}')")));
 }
예제 #28
0
        public static string GetSuggestedReceivingZone()
        {
            DataTable dt          = GetReceivingItemList();
            decimal   TotalVolume = CalculateTotalVolume(dt);

            return(Sql.GetString($"SELECT dbo.GetFirstReceivingLocation('{GlobalUser.CurrentWarehouseId}','{TotalVolume + NullCheck.IsNullDecimal(Cache.ReturnValueByKey("@PalletType"))}')"));
        }
        public void ValidateForStockQuery(Manpower manpower)
        {
            NullCheck.ThrowIfNull <Manpower>(manpower);

            validateAddress(manpower.address);
        }
예제 #30
0
        //static async Task Main() - C# 7.1
        static async Task Main()
        {
            #region C# 1.0

            //value types, reference types, boxing vs unboxing
            // ValueTypesExample.ExecuteExample();
            // ReferenceTypesExample.ExecuteExample();
            // BoxingUnboxing.ExecuteExample();

            //classes
            //TestPerson.ExecuteExample();

            //interfaces
            //InterfaceExample.ExecuteExample();

            //events
            //EventExample.ExecuteExample();
            //EventExample2.ExecuteExample();

            //delegates
            //DelegateExample.ExecuteExample();

            //atributes
            //AttributeExample.ExecuteExample();
            #endregion

            #region C# 1.2
            //ForEachIDisposable.ExecuteExample();
            //ReflectionTest.ExecuteExample();
            //UnsafeTest.ExecuteExample();
            //CheckUncheck.ExecuteExample();
            //ConstructorsDestructors.ExecuteExample();
            //UsingTest.ExecuteExample();

            #endregion

            #region C# 2.0
            //GenericsTest.ExecuteExample();
            //PartialTypes.ExecuteExample();
            //AnonymousMethods.ExecuteExample();
            //NullableValueTypes.ExecuteExample();
            //Iterators.ExecuteExample();
            //CovarianceContravariance.ExecuteExample();
            #endregion

            #region C# 3.0
            // AutoImplementedPropertiesTest.ExecuteExample();
            // AnonymousTypesTests.ExecuteExample();
            // QueryExpressionsTests.ExecuteExample();
            // LambdaExpressionsTest.ExecuteExample();
            // ExpressionTreesTest.ExecuteExample();
            //ExtensionMethodsTest.ExecuteExample();
            //CSharpStudy.Test.Test.Execute();
            #endregion

            #region C# 4.0
            //DynamicTest.ExecuteExample();
            //CovariantContravariantGenericTypesTest.ExecuteExample();
            #endregion

            #region C# 5.0
            //CallerInfoAttributesTest.ExecuteExample();
            #endregion

            #region C# 6.0
            //AutoPropertyInitializer.ExecuteExample();
            //NullConditionalOperator.ExecuteExample();
            // StringInterpolation.ExecuteExample();
            //ExceptionFilters.ExecuteExample();
            //NameOfExpression.ExecuteExample();
            // AwaitCatchFinally.ExecuteExample();
            #endregion

            #region C# 7.0
            //DigitBinarySeparator.ExecuteExample();
            //PatternMatching.ExecuteExample();
            //RefReturns.ExecuteExample();
            //Tuples.ExecuteExample();
            #endregion

            #region C# 7.1
            //await new AsyncMain().ExecuteExample();
            //DefaultLiteralExpressions.ExecuteExample();
            //InferredTupleNames.ExecuteExample();
            //GenericPatternMatching.ExecuteExample();
            #endregion

            #region C# 7.2
            //NonTrailingNamedArguments.ExecuteExample();
            //PrivateProtected.ExecuteExample();
            //RefConditional.ExecuteExample();
            #endregion

            #region C# 7.3

            #endregion

            #region C# 8.0
            //PatternMatchingNew.ExecuteExample();
            //UsingDeclarations.ExecuteExample();
            //await AsyncStreams.ExecuteExample();
            //ndicesRanges.ExecuteExample();
            #endregion

            #region C# 9.0
            // RecordType.ExecuteExample();
            // HalfClass.ExecuteExample();
            // PatternMatchingImprovements.ExecuteExample();
            #endregion

            #region C# 10
            // GlobalUsings.ExecuteExample();
            // FileScopedNamespace.ExecuteExample();
            // ExtendedPropertyPatterns.ExecuteExample();
            // ConstantInterpolationString.ExecuteExample();
            // RecordStruct.ExecuteExample();
            // LambdaImprovements.ExecuteExample();
            NullCheck.ExecuteExample();
            #endregion

            #region Features
            //IndexesRanges.ExecuteExample();
            var x = new DirectoryInfo(@"C:\temp\directory");


            #endregion

            #region C# Basic

            //Console.WriteLine("Hello World!");

            #region Section 3 - Primitive Types and Extensions

            //const float Pi = 3.14F;

            // Byte b = 1;
            // byte b = 2;

            //overflowing
            //byte number = byte.MaxValue;
            ////number = number++;
            //number = ++number; //0
            //number = ++number; //1
            //Console.WriteLine(number); //1

            //byte number = 255;

            //number += 2;

            //Console.WriteLine(number);

            //checked
            //{
            //    //number = number + 1; //exception
            //}


            //overflowing
            // try
            // {
            //     unchecked {
            //         Int32 x = Int32.MaxValue;

            //         x = x + 1;

            //         System.Console.WriteLine(x);
            //     }
            // }
            // catch (System.Exception ex)
            // {
            //     System.Console.WriteLine("erro " + ex.Message);
            //     //throw;
            // }

            //Console.WriteLine()

            //scope:
            //{
            //    byte a = 1;
            //    {
            //        byte b = 2;
            //    }
            //}
            //Console.WriteLine(a); //not accessible in tis context

            // var number = 2;
            // var letterA = 'A';
            // var totalPrice = 12.02;
            // float x = 12.23f;
            // const float y = 12.34f;

            //System.Console.WriteLine("{0} {1}", byte.MinValue, byte.MaxValue);

            //implicit type conversion
            // byte b = 1;
            // int i = b;

            //explicit type conversion
            // int i = 1;
            // byte b = (byte) i;

            //short s = short.MaxValue;
            //byte b = (byte)s; //255

            //float f = 1.0f;
            //int i = (int)f; //1

            // string x = "1";
            // int i = Convert.ToInt32(x);
            // int j = int.Parse(x);

            //non-compatible types
            //string x = "1";
            //int i = Convert.ToInt32(x);
            //int z = int.Parse(x);



            // string str1="9009";
            // string str2=null;
            // string str3="9009.9090800";
            // string str4="90909809099090909900900909090909";
            // int finalResult;
            // finalResult = int.Parse(str1); //success
            // finalResult = int.Parse(str2); // ArgumentNullException
            // finalResult = int.Parse(str3); //FormatException
            // finalResult = int.Parse(str4); //OverflowException

            // finalResult = Convert.ToInt32(str1); // 9009
            // finalResult = Convert.ToInt32(str2); // 0
            // finalResult = Convert.ToInt32(str3); //FormatException
            // finalResult = Convert.ToInt32(str4); //OverflowException

            // bool output;
            // output = int.TryParse(str1,out finalResult); // 9009
            // output = int.TryParse(str2,out finalResult); // 0
            // output = int.TryParse(str3,out finalResult); // 0
            // output = int.TryParse(str4, out finalResult); // 0

            // Console.WriteLine((float) 10 / (float) 3);

            // byte number = 255;
            // number += 2;
            // System.Console.WriteLine(byte.MaxValue);

            #endregion

            #region Section 4 - Non-Primitive Types

            //var x = new int[3] { 1, 2, 3 };

            //string x = "abc";
            //string z = x;
            //z = "cde";
            //Console.WriteLine($"x: {x} - z: {z}");

            // var john = new Person();
            // john.FirstName = "John";
            // john.LastName = "Smith";
            // john.Introduce();

            // var calc = new Calculator();
            // System.Console.WriteLine(calc.Add(1,2));

            //arrays
            // var numbers = new int[3] {1, 2, 3};
            // System.Console.WriteLine(string.Join(",", numbers));

            //var x = "asdasdasd";
            //Console.WriteLine(ShippingMethod.Express); //Express

            //System.Console.WriteLine((int)ShippingMethod.Express); //3

            //var methodId = 3;
            //System.Console.WriteLine((ShippingMethod)methodId); //Express

            //System.Console.WriteLine(ShippingMethod.Express.ToString()); //Express

            //var methodName = "Express";
            //var shipping = (ShippingMethod)Enum.Parse(typeof(ShippingMethod), methodName);

            //Console.WriteLine(shipping); //Express

            //Reference Types and Value Types
            // var a = 10;
            // var b = a;
            // b++;

            // var arr = new int[3] {1, 2, 3};
            // var arr2 = arr;
            // arr2[2] = 0;

            // System.Console.WriteLine(arr[2]);
            // System.Console.WriteLine(arr2[2]);

            // byte number = byte.MaxValue;

            // number = number++;
            // number = number++;
            // number = ++number;
            // number = ++number;

            // Console.WriteLine(number);

            //Console.WriteLine(TaxCalculator.Calculate());

            #endregion

            #region Section 5 - Control Flow

            //var role = "as";
            //switch (role)
            //{
            //    case "a":
            //    case "b":
            //        System.Console.WriteLine("as");
            //        break;
            //    default:
            //        System.Console.WriteLine("Default");
            //        break;
            //}

            // System.Console.WriteLine("type your name: ");
            // var input = Console.ReadLine();
            // System.Console.WriteLine(input);

            //var random = new Random();
            //random.Next(-1,2);

            // System.Console.WriteLine((int)'a');
            // System.Console.WriteLine((char)100);

            #endregion

            #region Secion 6 - Arrays

            //            var numbers = new int[4] {1, 2, 3, 3}; //single-dimensional

            //multi dimension arrays:

            //rectangular 2D array
            // var matrix = new int[3,5]{
            //     {1,2,3,4,5},
            //     {1,2,3,4,5},
            //     {1,2,3,4,5}
            // };

            // var el = matrix[1,2];

            // //jagged array
            // var arr = new int[3][];
            // arr[0] = new int[3];
            // arr[1] = new int[3];
            // arr[2] = new int[3];

            // var el = arr[0][2];

            // var numbers = new [] {3, 2, 4,5, 3, 5 , 12};

            // System.Console.WriteLine(numbers.Length);
            // System.Console.WriteLine(Array.IndexOf(numbers, 4));
            // Array.Clear(numbers,0,2);

            // var anotherArray = new int[2];
            // Array.Copy(numbers, anotherArray, 2);

            // System.Console.WriteLine("numb");

            // Array.Sort(numbers);
            // Array.Reverse(numbers);
            // foreach (var item in numbers)
            // {
            //     System.Console.WriteLine(item);
            // }


            //working with lists
            // var numbers = new List<int>() {1, 2, 3};
            // numbers.AddRange(new int[]{3, 4,5,6,1, 1,1});

            // foreach (var number in numbers)
            // {
            //     System.Console.WriteLine(number);
            // }

            // System.Console.WriteLine("Index of 3: " + numbers.IndexOf(3));
            // System.Console.WriteLine("Index of 3: " + numbers.LastIndexOf(3));

            // System.Console.WriteLine("Count: " + numbers.Count);
            // //numbers.Remove(1);
            // numbers.RemoveAll(_ => _.Equals(1));

            // foreach (var number in numbers)
            // {
            //     System.Console.WriteLine(number);
            // }


            #endregion

            #region Section 7 - Dates and Times

            // System.Console.WriteLine(DateTime.Today);
            // System.Console.WriteLine(DateTime.Now);
            // System.Console.WriteLine(DateTime.Now.ToString("dd/MM/yyyy hh:mi:ss"));
            // System.Console.WriteLine(DateTime.Now.ToLongDateString());
            // System.Console.WriteLine(DateTime.Now.ToShortDateString());
            // System.Console.WriteLine(DateTime.Now.ToLongTimeString());
            // System.Console.WriteLine(DateTime.Now.ToShortTimeString());

            // var timeSpan = new TimeSpan(1,2,3);
            // var timeSpan2 = new TimeSpan(1,0,0);
            // var timeSpan3 = TimeSpan.FromHours(1);

            // System.Console.WriteLine(timeSpan.Minutes);
            // System.Console.WriteLine(timeSpan.TotalMinutes);

            // System.Console.WriteLine(timeSpan);
            // System.Console.WriteLine(timeSpan.Add(TimeSpan.FromMinutes(8)));

            // System.Console.WriteLine(TimeSpan.Parse("01:12:23"));

            #endregion

            #region Section 8 - Text

            // var fullName = " ";
            // System.Console.WriteLine(String.IsNullOrWhiteSpace(fullName));

            // var price = 12.12F;
            // System.Console.WriteLine(price.ToString("C3"));

            // var sb = new StringBuilder("tittle");
            // sb.Append('-', 10)
            //   .AppendLine()
            //   .Append("asasdasd")
            //   .Insert(0, new string('a', 20));

            //var x = sb.ToString().IndexOf('t');

            //System.Console.WriteLine(sb);


            #endregion

            #region Section 9 - Files and Directories

            //File, FileInfo, Directory, DirectoryInfo, Path

            #endregion

            #endregion

            #region C# Intermediate

            #region Section 2 - Classes

            //var p = Person2.Parse("john");

            //var customer = new Customer(1);
            //Console.WriteLine(customer.Id);
            //Console.WriteLine(customer.Name);

            // var order = new Order();
            // customer.Orders.Add(order);
            // var point = new Point(10, 20);
            // point.Move(new Point(40,20));
            // System.Console.WriteLine(point.X);

            //var calculator = new Calculator();
            // System.Console.WriteLine(calculator.Add(1,2,3));
            // System.Console.WriteLine(calculator.Add(new int[]{1,23,4,5}));

            // try
            // {
            //     var x = int.Parse("asbc");
            // }
            // catch (System.Exception)
            // {
            //     System.Console.WriteLine("Conversion vailed");
            // }

            // int number;
            // var result = int.TryParse("123", out number);

            // var cookie = new HttpCookie();
            // cookie["name"] = "mosh";
            // System.Console.WriteLine(cookie["name"]);

            #endregion

            #region Section 3 - Association between classes

            // var text = new Text();
            // text.Width = 100;
            // text.Copy();

            // var dbMigrator = new DbMigrator(new Logger());

            // var logger = new Logger();
            // var installer = new Installer(logger);

            // dbMigrator.Migrate();
            // installer.Install();


            #endregion

            #region Section 4 - Inheritance

            //var customer = new Customer();
            //var car = new Car("123123123");

            //upcasting
            // var text = new Text(10,"asd");
            // Shape shape = text;

            // text.Width = 200;
            // shape.Width = 100;

            // System.Console.WriteLine(text.Width);

            // StreamReader reader = new StreamReader(new MemoryStream());
            // StreamReader reader = new StreamReader(new FileStream());

            //downcasting
            // Shape shape = new Text(12, "adasd"); //shape has limited vision
            // Text text = (Text) shape;

            //boxing
            // var list = new ArrayList();
            // list.Add(1); //boxing will happen, get back unboxing
            // list.Add("asdas"); //not boxing
            // list.Add(DateTime.Today); //will boxing

            // var number = (int)list[1]; //InvalidCastException

            // var anotherList = new List<int>();
            // anotherList.Add(1); //type safety with no boxing

            // var names = new List<string>();
            // names.Add("");//no boxing

            #endregion

            #region Section 5 - Polymorphism

            // var x = new Circle();
            // x.Draw();

            // var shapes = new List<Shape>();
            // shapes.Add(new Circle());

            #endregion

            #region Section 6 - Interfaces

            #endregion

            #endregion

            #region C# Advanced

            //Generics:
            //var numbers = new GenericList<int>();
            //numbers.Add(10);

            // var books = new GenericList<Book>();
            // books.Add(new Book());

            // var dictionary = new GenericDictionary<string, Book>();
            // dictionary.Add("123", new Book());

            // var number = new Nullable<int>();
            // System.Console.WriteLine("HasValue? " + number.HasValue);
            // System.Console.WriteLine("Actual value: " + number.GetValueOrDefault());

            ////Delegates:
            //var processor = new PhotoProcessor();
            //var filters = new PhotoFilters();
            ////PhotoProcessor.PhotoFilterHandler filterHandler = filters.Resize;
            //Action<Photo> filterHandler = filters.Resize;
            //filterHandler += filters.ApplyContrast;
            //filterHandler += RemoveRedEye;

            //processor.Process("photo.jpg", filterHandler);

            //Lambda Expressions:
            // System.Console.WriteLine(Square(4));
            // Func<int, int> square = number => number * number;
            // System.Console.WriteLine(square(5));

            // const int factor = 5;
            // Func<int, int> multiplier = n => n * factor;
            // System.Console.WriteLine(multiplier(3));

            // var books = new BookRepository().GetBooks();
            // var cheapBooks = books.FindAll(IsCheaperThan10Dollars);
            // var cheapBooksLambda = books.FindAll(b => b.Price < 10);

            // foreach (var book in cheapBooks)
            // {
            //     System.Console.WriteLine(book.Title);
            // }

            //Events and Delegates:
            //var video = new Video() { Title = "Video 1" };
            //var videoEncoder = new VideoEncoder(); //publisher
            //var mailService = new MailService(); //subscriber
            //var messageService = new MessageService(); //subscriber

            //videoEncoder.VideoEncoded += mailService.OnVideoEncoded; //subscription
            //videoEncoder.VideoEncoded += messageService.OnVideoEncoded;

            //videoEncoder.Encode(video);

            //Extension Methods:
            //var post = "this is a big string, that it is very long and we need ssss";
            //var shortenedPost = post.Shorten(5);
            //System.Console.WriteLine(shortenedPost);

            //LINQ:
            //var books = new BookRepository().GetBooks();

            //LINQ Query Operators:
            // var cheapBooks1 =
            //     from b in books
            //     where b.Price < 50
            //     orderby b.Title descending
            //     select b.Title;

            //LINQ Extension Methods
            // var cheapBooks = books.Where(b => b.Price < 50)
            //         .OrderByDescending(b => b.Price)
            //         .Select(b => b.Title);

            // foreach (var book in cheapBooks)
            // {
            //     //System.Console.WriteLine(book.Title + " - " + book.Price);
            //     System.Console.WriteLine(book);
            // }

            // var pagedBooks = books.Skip(2).Take(30);

            // foreach (var book in pagedBooks)
            // {
            //     System.Console.WriteLine(book.Title);
            // }

            // System.Console.WriteLine(book);

            //Nullable Types:

            // Nullable<DateTime> date = null;

            //DateTime? date2 = null;
            //DateTime dataX = date2;
            // DateTime dataX = date2 ?? DateTime.Today;//date2.GetValueOrDefault();
            // DateTime? date3 = date2;

            //Dynamic:
            //object obj = "mosh";
            //obj.GetHashCode()

            //reflexion
            // var methodInfo = obj.GetType().GetMethod("GetHashCode");
            // methodInfo.Invoke(null, null);

            //using dynamic
            // dynamic obj2 = "mosh";
            // obj2 = 1;
            // System.Console.WriteLine(obj2);
            // obj2.Optimize();

            // int i = 5;
            // dynamic d = i;
            // long l = d;

            //Exception Handling:
            // try
            // {
            // using (StreamReader r = new StreamReader(@"asdasd"))
            // {

            // }
            //     var calc = new Calculator();
            //     calc.Divide(1, 0);


            // }
            // catch (DivideByZeroException ex){

            // }
            // catch (ArithmeticException ex){

            // }
            // catch (Exception ex)
            // {
            //     System.Console.WriteLine("error");

            //     throw new CustomizedException("Customized", ex);
            // }


            //Asynchronous Programming with Async/Await
            //DownloadHtmlAsync("http://www.google.com");
            //DownloadAsync("http://www.google.com");
            //var t = GetHtmlAsync("http://www.google.com");

            //Parallel
            //ParallelVsForEach.ExecuteExample();

            #endregion

            #region C# 2.0

            #endregion

            #region C# 7.0

            //TUPLAS
            //Tuplas.ExecuteExample();

            //REF RETURNS
            //RefReturns.ExecuteExample();

            //PATTERN MATCHING
            //PatternMatching.ExecuteExample();

            //PATTERN MATCHING 2:
            //PatternMatching2.ExecuteExample();

            //LOCAL FUNCTIONS
            //LocalFunctions.ExecuteExample();

            //DIGIT SEPARATORS
            //DigitSeparator.ExecuteExample();

            //OUT VARIABLES
            //OutVariables.ExecuteExample("12");

            //EXPRESSION BODIED
            //var exp = new ExpressioBodied("descricao");
            //exp.Label = "descricao modificada";
            //Console.WriteLine(exp.Label);

            //VALUE TASKS:
            //ValueTasks2.ExecuteExample();

            //PATTERN MATCHING
            //PatternMatching.ExecuteExample();

            #endregion

            #region Functional Programming

            #endregion

            #region Searching Techniques

            //linear search: consider every single item on a one by one basis
            // int[] numbers = {1,32,5,12,53,65,7,234};
            // var index = LinearSearch.returnIndex(numbers, 53);
            // Console.WriteLine($"Value search: 53. Index found is {index}, in array [{string.Join(",",numbers)}].");

            //binary search: the target value is compared with de middle element of a sorted array.
            // int[] numbers = {1,20,25,32,45,50,70,80};
            // var index = BinarySearch.returnIndex(numbers, 0, numbers.Length, 50);
            // Console.WriteLine($"Value search: 50. Index found is {index}, in array [{string.Join(",",numbers)}].");

            //

            #endregion

            #region Best Practices for Developers

            #endregion

            #region Other

            //RuntimePolymorphismExample.Execute();
            //structs
            //StructSample.ExecuteExample();

            //Properties
            // var prop = new PropertiesExample();
            // Console.WriteLine(prop.FirstName);

            // var prop2 = new PropertiesExample("asdasdasd");
            // Console.WriteLine(prop2.FirstName);

            // prop2.ChangePropert = "ddddddddddddd";
            // Console.WriteLine(prop2.FirstName);

            //expressions: is a sequence of one or more operands and zero or more operators that can be evaluated to a single value, object, method, or namespace
            //((x < 10) && ( x > 5)) || ((x > 20) && (x < 25));
            //System.Convert.ToInt32("35");

            //statements: the action that a program takes (assign, declaration)

            //yield: A type of statement
            //attributes: Attributes add metadata to your program
            //YieldExample.ExecuteExample();

            //literals: constants refer to fixed values that the program may not alter during its execution - fixed values
            //ex: \n \t floating-point: 3.14159 string: @"asdasd" const

            //value types:
            //ValueTypesExample.ExecuteExample();

            //reference types:
            //ReferenceTypesExample.ExecuteExample();

            #endregion
        }