Created
April 17, 2016 06:46
-
-
Save hoetz/203ddadf33209d838487b9af8cf276e7 to your computer and use it in GitHub Desktop.
SplitContainer
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
type SplitContainerChildPosition= One | Two | |
type IContainerComponent = | |
abstract ComponentId : string | |
type Empty () = | |
interface IContainerComponent with | |
member this.ComponentId = "Empty" | |
type Table () = | |
interface IContainerComponent with | |
member this.ComponentId = "Table" | |
type Graph () = | |
interface IContainerComponent with | |
member this.ComponentId = "Graph" | |
type SplitContainerComponent = | |
| EmptyComponent of IContainerComponent | |
| Container of IContainerComponent | |
| Graph of IContainerComponent | |
| TableComponent of IContainerComponent | |
type SingleContainer= | |
{Child:IContainerComponent} | |
type SplitContainer= | |
{Child1:SplitContainerComponent; Child2:SplitContainerComponent; Parent:SplitContainerComponent} | |
interface IContainerComponent with | |
member this.ComponentId="SplitContainer" | |
let setItemAtSplitContainerPosition newItem container position = | |
match position with | |
| One -> { Child1=newItem; Child2=container.Child2; Parent=container.Parent } | |
| Two -> { Child1=container.Child2; Child2=newItem; Parent=container.Parent } | |
let firstItem =EmptyComponent(new Empty()) | |
let splitContainer = | |
{ Child1=firstItem; Child2=firstItem; Parent=firstItem } | |
let splitContainer2= setItemAtSplitContainerPosition (Graph(new Graph())) splitContainer Two | |
let splitContainer3= setItemAtSplitContainerPosition (TableComponent(new Table())) splitContainer2 One | |
let testmatch containerItem = | |
match containerItem with | |
| Graph x -> x.ComponentId | |
| TableComponent t -> let t2=t :> IContainerComponent | |
t2.ComponentId | |
| _ -> "not implemented" | |
testmatch splitContainer3.Child1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment