Skip to content

Instantly share code, notes, and snippets.

View NMZivkovic's full-sized avatar

Nikola Živković NMZivkovic

View GitHub Profile
try
{
Console.WriteLine("Enter entity type:");
var entytyType = (EntityType)Enum.Parse(typeof(EntityType), Console.ReadLine(), true);
Console.WriteLine("Enter new value:");
var modificationValue = Convert.ToInt32(Console.ReadLine());
var entityFactory = new EntityFactory();
var entity = entityFactory.GetEntityBasedOnType(entytyType);
type Shape =
| Rectangle of width : float * length : float
| Circle of radius : float
let getShapeHeight shape =
match shape with
| Rectangle(width = h) -> h
| Circle(radius = r) -> 2. * r
var shapes = new Dictionary<string, object>
{
{ "FirstShape", new Rectangle(1, 1) },
{ "SecondShape", new Circle(6) }
};
foreach(var shape in shapes)
{
if (shape.Value is Rectangle)
{
foreach (var shape in shapes)
{
switch(shape.Value)
{
case Rectangle r:
Console.WriteLine(r.Height);
break;
case Circle c:
Console.WriteLine(2 * c.Radius);
break;
foreach (var shape in shapes)
{
switch(shape.Value)
{
case Rectangle r:
Console.WriteLine(r.Height);
break;
case Circle c when c.Radius > 10:
Console.WriteLine(2 * c.Radius);
break;
{
"_id" : ObjectId("58e28d41b1ad7d0c5cd27549"),
"name" : "Nikola Zivkovic",
"blog" : "rubikscode.net",
"numberOfArticles" : 10,
"Adress" : [
"street" : "some street",
"city" : "Novi Sad",
"country" : "Serbia"
],
{
"_id" : ObjectId("58e28da0b1ad7d0c5cd2754a"),
"name" : "Vladimir Pecanac",
"blog" : "code-maze.com",
"Adress" : [
"street" : "some street",
"city" : "Novi Sad",
"country" : "Serbia"
],
"company" : "Vega IT Sourcing",
{
_id : "rs0",
members: [
{_id : 0, host : "localhost:27017"}
]
}
{
_id : "rs0",
members: [
{ _id : 0, host : "localhost:27017" },
{ _id : 0, host : "localhost:27018" },
{ _id : 0, host : "localhost:27019" }
]
}