public PolyfacingValueOfDecoration(IValueOf <T> decorated, Polyface rootFace = null) : base(decorated) { //if no polyface is set we create new one this.RootFace = (rootFace == null) ? Polyface.New() : rootFace; //register the face this.RootFace.Is(typeof(Tface), this); }
/// <summary> /// a new Polyface is created and injected. /// </summary> /// <param name="face"></param> /// <returns></returns> public static Polyface NewRoot(this IPolyfacing face) { Condition.Requires(face).IsNotNull(); var rv = Polyface.New(); rv.Is(face.GetType(), face); return(rv); }
/// <summary> /// Sets the behaviour for the provided face name /// </summary> /// <param name="type"></param> /// <param name="behaviour"></param> /// <returns></returns> public static Polyface Is(this IPolyfacing face, string faceName, object behaviour) { Condition.Requires(face).IsNotNull(); Polyface rv = face.RootFace; if (rv == null) { rv = Polyface.New(); face.RootFace = rv; } return(rv.Is(faceName, behaviour)); }
/// <summary> /// decorates with polyfacingness if it's not already there /// </summary> /// <typeparam name="T"></typeparam> /// <param name="valueOf"></param> /// <param name="rootFace"></param> /// <returns></returns> public static PolyfacingValueOfDecoration <T, Tface> Polyfacing <T, Tface>(this IValueOf <T> decorated, Polyface rootFace = null) where Tface : IValueOf <T> { Condition.Requires(decorated).IsNotNull(); PolyfacingValueOfDecoration <T, Tface> rv = null; //if we have polyface in our chain, we return that if (decorated.HasDecoration <PolyfacingValueOfDecoration <T, Tface> >()) { rv = decorated.As <PolyfacingValueOfDecoration <T, Tface> >(); } else { rv = new PolyfacingValueOfDecoration <T, Tface>(decorated, rootFace); } return(rv); }
public static PolyfacingValueOfDecoration <T, Tface> New(IValueOf <T> decorated, Polyface rootFace = null) { return(new PolyfacingValueOfDecoration <T, Tface>(decorated, rootFace)); }
public static PolyfacingIHasIdDecoration <Tface> Polyfacing <Tface>(this IHasId decorated, Polyface rootFace = null) where Tface : IHasId { Condition.Requires(decorated).IsNotNull(); PolyfacingIHasIdDecoration <Tface> rv = null; /*Summary: * if we spec a root we are setting that root * if the condition is already polyfacing we use that otherwise build new one * if no root is spec'd we create new polyface */ //if we have polyface in our chain, we return that if (decorated.HasDecoration <PolyfacingIHasIdDecoration <Tface> >()) { rv = decorated.FindDecoration <PolyfacingIHasIdDecoration <Tface> >(); } else { rv = new PolyfacingIHasIdDecoration <Tface>(decorated, rootFace); } return(rv); }
public static PolyfacingLogicDecoration <Tface> New(ILogic decorated, Polyface rootFace = null) { return(new PolyfacingLogicDecoration <Tface>(decorated, rootFace)); }
public static PolyfacingConditionDecoration <Tface> New(ICondition decorated, Polyface rootFace = null) { return(new PolyfacingConditionDecoration <Tface>(decorated, rootFace)); }