This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //C# | |
| public T FindInList<T>(IEnumerable<T> source, IEnumerable<T> target) | |
| { | |
| return source.First(target.Contains) | |
| //return source.Intersect(target).First(); | |
| } | |
| //F# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //C# | |
| public T FindInList<T>(IEnumerable<T> source, IEnumerable<T> target) | |
| { | |
| return source.First(target.Contains) | |
| } | |
| //F# | |
| let FindInList (source : seq<_>) (target : seq<_>) = source.First(Func<_,bool>(target.Contains)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Felipe: | |
| quer minha opinião? | |
| Rodrigo Vidal: | |
| sim :D | |
| Felipe: | |
| na grande maioria dos casos, tanto faz | |
| não terá diferença | |
| em casos que um FileSystem é um problema, o DB será um problema também | |
| e vice-cersa | |
| vice-versa |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MeuDependencyResolver : IDependencyResolver | |
| { | |
| private ILookup<Type, object> dependencias; | |
| public MeuDependencyResolver() | |
| { | |
| this.dependencias = Dependencias().ToLookup(x => x.GetType()); | |
| } | |
| private IEnumerable<object> Depencencias() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MeuDependencyResolver : IDependencyResolver | |
| { | |
| private ILookup<Type, object> lookup; | |
| public MeuDependencyResolver() | |
| { | |
| var dependencias = new [] | |
| { | |
| new DummyDependencia1(), new DummyDependencia2(), new DummyDependencia2_2() | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var intForm = Type.GetType("ModuloControle.IMessageForm'1").MakeGenericType(myDesiredType) | |
| GetType().Assembly.GetTypes() | |
| .Where(x=>!x.IsAbstract && typeof(Form).IsAssignableFrom(x) && intForm.IsAssignableFrom(x)) | |
| .Select(x => (Form)Activator.CreateInstance(x)); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public struct MyEnum | |
| { | |
| public static readonly MyEnum Value1 = new MyEnum("value1"); | |
| public static readonly MyEnum Value2 = new MyEnum("value2"); | |
| readonly string name; | |
| MyEnum(string name) : this() | |
| { | |
| this.name = name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Test] | |
| public static void Class_AllStaticMethodsShouldBeDecoratedWithDebuggerStepThroughAttribute() | |
| { | |
| var methods = StaticMethodsWithout(typeof(Mooble.Util.StringExtensions), typeof(DebuggerStepThroughAttribute)) | |
| methods.Count.Should.Be(0); | |
| } | |
| IEnumerable<MethodInfo> StaticMethodsWithout(Type type, Type attribute) | |
| { | |
| return from m in type.GetMethods() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class TypeExtensions | |
| { | |
| public static Type GetValueTypeIfNullable(this Type type) | |
| { | |
| return (type.IsGenericType && typeof(Nullable<>) == type.GetGenericTypeDefinition()) | |
| ? type.GetGenericArguments()[0] : type; | |
| } | |
| } | |
| public static class StringExtensions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public IEnumerable<Token> Scan(IEnumerable<char> source) | |
| { | |
| var currentState = StatesTable.InitialStage; | |
| var currentValue = ""; | |
| Func<Token> markPartialStop = () => | |
| { | |
| if (currentState.IsStop) | |
| { | |
| var result = new Token(currentState.ResultingTokenId, currentValue); |
OlderNewer