erl -sname somename
erl -setcookie foo -sname somename
| <?xml version="1.0" encoding="utf-8"?> | |
| <Edmx Version="3.0" xmlns="http://schemas.microsoft.com/ado/2009/11/edmx"> | |
| <Runtime> | |
| <ConceptualModels> | |
| <Schema Namespace="Test" Alias="Self" p4:UseStrongSpatialTypes="false" xmlns:p4="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm"> | |
| <EntityType Name="Contact"> | |
| <Key> | |
| <PropertyRef Name="Id" /> | |
| </Key> | |
| <Property Name="Id" Type="Int32" Nullable="false" p4:StoreGeneratedPattern="Identity" /> |
| using AutoMapper; | |
| using System; | |
| using System.Linq; | |
| using System.Linq.Expressions; | |
| namespace MappingTest | |
| { | |
| class Cat | |
| { | |
| public string Name { get; set; } |
| /// <summary> | |
| /// Compare two expressions so that methods taking lambda | |
| /// expressions as arguments can be mocked with NSubstitute. | |
| /// <example> | |
| /// _ordersRepository.Find(Expr.Is<Order>(o => o.Id == 2)).Returns(order2) | |
| /// </example> | |
| /// </summary> | |
| public static class Expr | |
| { | |
| public static Expression<Func<TArg, bool>> Is<TArg>(Expression<Func<TArg, bool>> expression) |
| let (|Value|_|) value item = | |
| if item = value | |
| then Some() | |
| else None | |
| let x = 1 | |
| match [1] with | |
| | [Value x] -> "match" | |
| | _ -> "no match" |
| // I'm using lots of operating overloading voodoo to avoid | |
| // having to specify static type constraints manually. | |
| // I'm also using MemoryStream / BinaryReader which is probably | |
| // slow but it was the easiest way to read values sequentially. | |
| // It's currently just using the size of the receiving datatype | |
| // rather than specifying it, though that could change. | |
| open System | |
| open System.IO | |
| // Computation expression builder that uses a custom bind operation | |
| // to allow binding a value to a name and yielding it as part of a | |
| // list in one go. | |
| type ListBuilder() = | |
| member this.Bind(x, f) = x::f(x) | |
| member this.Delay(f) = f() | |
| member this.Combine(x, xs) = x @ xs | |
| member this.Yield(x) = [x] | |
| let list = ListBuilder() |
| // This was the idea. Unfortunately, it doesn't work. The expression expects every successive item to be | |
| // the same type the first expression, ProvidedProperty. I can upcast them all to MemberInfo, but then they | |
| // don't work as arguments to the next items in the expression. | |
| let createType name (parameters:obj[]) = | |
| let providedAsmPath = Path.Combine(config.TemporaryFolder, "FixedLengthTypes.dll") | |
| let providedAsm = ProvidedAssembly(providedAsmPath) | |
| let length = parameters.[0] :?> int | |
| let ty = ProvidedTypeDefinition(asm, "FixedLengthTypes", name, Some typeof<obj>, IsErased = false) | |
| ty.AddMembers(list { | |
| yield ProvidedProperty("Length", typeof<int>, IsStatic = true, |
| public class GuidLayout : RawPropertyLayout | |
| { | |
| public override object Format(LoggingEvent loggingEvent) | |
| { | |
| var baseFormat = base.Format(loggingEvent); | |
| if (baseFormat is Guid) | |
| return baseFormat; | |
| var guidString = baseFormat as string; |
| // Functor instances. Define Functor as a single case discriminated union | |
| // to help with overload resolution. | |
| type Functor = Functor with | |
| static member fmap(Functor, mapping, option) = Option.map mapping option | |
| static member fmap(Functor, mapping, list) = List.map mapping list | |
| // Helper function to resolve Functor overload. Needed because we can't specify a concrete type | |
| // such as Functor in a statically-resolved type parameter constraint, so we instead pass in an | |
| // instance of Functor to resolve the ^o parameter. Also notice we have ^c and ^d instead of | |
| // ^f< ^a > and ^f < ^b > because F# doesn't allow this. |