Ejemplo n.º 1
0
    public async Task <bool> UnifiedWriteTxT()
    {
        var        isOk                 = false;
        ISubSystem ISubSystemAccout     = new Accout(FirstName, LastName, Age, ValidAccout);
        ISubSystem ISubSystemAddress    = new Address(AddressDescription, City, State, ValidAddress);
        ISubSystem ISubSystemCreditCard = new CreditCard(CreditType, CardNumber, CardExpDate, ValidCard);

        if (
            (await ISubSystemAccout.SaveAsync()) && (await ISubSystemAddress.SaveAsync()) &&
            (await ISubSystemCreditCard.SaveAsync())
            )
        {
            Console.WriteLine("写入成功");
            isOk = true;
        }
        else
        {
            Console.WriteLine("写入失败");
            isOk = false;
        }

        return(isOk);
    }
Ejemplo n.º 2
0
    public async void CommonWayAsync()
    {
        Console.WriteLine("进入CommonWay方法...直接调用SubWay");
        string firstName = "张", lastName = "三丰", addressDescription = "武当", city = "十堰市", state = "中国", carditType = "掌门", cardExpDate = "9999-99-99";
        int    age = 100, cardNumber = 100;
        bool   validAccout = true, validAddress = true, validCard = true;

        ISubSystem ISubSystemAccout     = new Accout(firstName, lastName, age, validAccout);
        ISubSystem ISubSystemAddress    = new Address(addressDescription, city, state, validAddress);
        ISubSystem ISubSystemCreditCard = new CreditCard(carditType, cardNumber, cardExpDate, validCard);

        if (
            (await ISubSystemAccout.SaveAsync()) && (await ISubSystemAddress.SaveAsync()) &&
            (await ISubSystemCreditCard.SaveAsync())
            )
        {
            Console.WriteLine("CommonWay写入成功");
        }
        else
        {
            Console.WriteLine("CommonWay写入失败");
        }
    }