Skip to content

Instantly share code, notes, and snippets.

View luisdeol's full-sized avatar
🎯
Focusing

Luis Felipe de Oliveira luisdeol

🎯
Focusing
View GitHub Profile
@luisdeol
luisdeol / Program.cs
Created August 18, 2019 16:48
2.6 - Using statement
using System;
namespace _26_ManageObjLifecycle
{
class Program
{
static void Main(string[] args)
{
using (var baseClass = new BaseClass())
{
@luisdeol
luisdeol / Program.cs
Created August 18, 2019 16:44
Dispose pattern (from Microsoft docs)
using Microsoft.Win32.SafeHandles;
using System;
using System.Runtime.InteropServices;
namespace _26_ManageObjLifecycle
{
class BaseClass : IDisposable
{
// Flag: Has Dispose already been called?
bool disposed = false;
@luisdeol
luisdeol / ClassForReflectionPractice.cs
Created July 15, 2019 22:30
2.5 - Using reflection (example class)
using System;
namespace _25RuntimeReflection
{
public class ClassForReflectionPractice
{
public ClassForReflectionPractice(string oneString)
{
_oneString = oneString;
}
@luisdeol
luisdeol / Program.cs
Last active July 14, 2019 13:23
2.5 - Using Expression Trees
using System;
using System.Linq.Expressions;
namespace _25_RuntimeReflection
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Calculating 3 to the power 2.");
@luisdeol
luisdeol / Program.cs
Created July 14, 2019 12:38
2.5 - Using Lambda code and anonymous function.
using System;
using System.Linq;
namespace _25_RuntimeReflection
{
class Program
{
static void Main(string[] args)
{
var oneToTen = Enumerable.Range(0, 10).ToList();
@luisdeol
luisdeol / TasksController.cs
Created July 14, 2019 12:18
2.5 - Generated code by CodeDOM
//------------------------------------------------------------------------------
// <auto-generated>
// O código foi gerado por uma ferramenta.
// Versão de Tempo de Execução:4.0.30319.42000
//
// As alterações ao arquivo poderão causar comportamento incorreto e serão perdidas se
// o código for gerado novamente.
// </auto-generated>
//------------------------------------------------------------------------------
@luisdeol
luisdeol / Program.cs
Last active July 14, 2019 12:18
2.5 - Using CodeDom to Generate an ASP.NET Web API Controller.
using Microsoft.CSharp;
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.IO;
using System.Reflection;
namespace _25_RuntimeReflection
{
class Program
@luisdeol
luisdeol / Program.cs
Last active July 14, 2019 11:07
2.5 - Using Reflection
using System;
using System.Linq;
using System.Reflection;
namespace _25RuntimeReflection
{
class Program
{
static void Main(string[] args)
{
@luisdeol
luisdeol / Program.cs
Created July 14, 2019 10:30
2.5 - Creating and accessing Attributes
using System;
namespace _25RuntimeReflection
{
class Program
{
static void Main(string[] args)
{
// Checking if the Phrase property was set when using the custom attribute on UsingAttribute class.
var attribute = (MyCoolAttribute)Attribute.GetCustomAttribute(typeof(UsingAttribute), typeof(MyCoolAttribute));
@luisdeol
luisdeol / Program.cs
Created April 3, 2019 10:50
Implement IEnumerable
using System;
using System.Collections;
using System.Collections.Generic;
namespace CreateAndImplClassHierar
{
class Program
{
static void Main(string[] args)
{