От: | Sinix | ||
Дата: | 12.06.15 20:22 | ||
Оценка: | 131 (5) |
(я когда читал — помню бросился перепроверять, не мог же я всё настолько забыть).Framework assemblies always load
It is worth noting that, unlike other dependencies, references to .NET Framework assemblies will always cause those assemblies to load. Even if you are not really using an assembly, it will still load at application startup. Fortunately, if multiple projects in the solution all reference the same assembly, only one instance of this assembly is loaded into memory and is shared among all dependents.
public class NullUser : IUser { public void IncrementSessionTicket() { // do nothing } }
Я тут могу добавить только одно слово: наследование.Fluent interfaces are easy to implement, too.
public class LoggingStopwatch : IStopwatch { public LoggingStopwatch(IStopwatch decoratedStopwatch) { this.decoratedStopwatch = decoratedStopwatch; } public void Start() { decoratedStopwatch.Start(); Console.WriteLine("Stopwatch started..."); } public long Stop() { var elapsedMilliseconds = decoratedStopwatch.Stop(); Console.WriteLine("Stopwatch stopped after {0} seconds", TimeSpan.FromMilliseconds(elapsedMilliseconds).TotalSeconds); return elapsedMilliseconds; } private readonly IStopwatch decoratedStopwatch; }
public class AsyncComponent : IComponent { // ... public void Process() { Task.Run((Action)decoratedComponent.Process); } }
не подглядывать. А впрочем, всё равно не угадаете | |
| |
Да, по мнению автора — это стратегия. Очевидно, потому что в имени класса упомянуто.public class OnlineCart { public OnlineCart() { paymentStrategies = new Dictionary<PaymentType, IPaymentStrategy>(); paymentStrategies.Add(PaymentType.CreditCard, new PaypalPaymentStrategy()); paymentStrategies.Add(PaymentType.GoogleCheckout, new GoogleCheckoutPaymentStrategy()); paymentStrategies.Add(PaymentType.AmazonPayments, new AmazonPaymentsPaymentStrategy()); paymentStrategies.Add(PaymentType.Paypal, new PaypalPaymentStrategy()); } public void CheckOut(PaymentType paymentType) { paymentStrategies[paymentType].ProcessPayment(); } private IDictionary<PaymentType, IPaymentStrategy> paymentStrategies; }
Одобряю, замысел удалсяHrorH: На правах троллинга