Looking for Основи розробки програмного забезпечення на платформі Microsoft.NET test answers and solutions? Browse our comprehensive collection of verified answers for Основи розробки програмного забезпечення на платформі Microsoft.NET at do.ipo.kpi.ua.
Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!
public class FileMetadata : ICloneable
{
public string Name { get; set; }
public byte[] Hash { get; set; }
public object Clone() => MemberwiseClone();
}
Чому такий клон потенційно небезпечний?
Недоліком патерну “Абстрактна фабрика” (Abstract Factory) є те, що
public class CompositeHandler : Handler
{
private readonly IEnumerable
_items;
public CompositeHandler(IEnumerable
items)=>_items=items;
public override bool Handle(Request r) =>
_items.All(h => h.Handle(r)) && (Next?.Handle(r) ?? true);
}
Яка причина поєднання COR з Composite?
var pairs = Enumerable.Range(0,4)
.Select(i => (i, val: i*i))
.ToDictionary(t=>t.i, t=>t.val);
]]>public record Glyph(char Code, Font Font);
public class GlyphFactory
{
private readonly Dictionary<(char, string), Glyph> _pool = new();
public Glyph Get(char c, Font f)
=> _pool.TryGetValue((c, f.Name), out var g)
? g : _pool[(c, f.Name)] = new Glyph(c, f);
}
Що робить GlyphFactory?
var arr = new[]{2,4,6,8}
.TakeWhile(n=>n<7)
.Aggregate(1,(acc,v)=>acc*v);
]]>var s = "abcdef";
var ch = s.Skip(2).Take(2).Reverse().First();
]]>Яку проблему вирішує патерн Міст (Bridge)
string js = @"{""Id"":1,""id"":2}";
var opt = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
var r = JsonSerializer.Deserialize<Record>(js, opt);
System.Console.WriteLine(r!.Id);
record Record(int Id);