public static bool GetData <TGoo, T>(ITargetParam <TGoo, T> owner, out GH_ParamAccess access, out T value) where TGoo : GH_Goo <T> { access = GH_ParamAccess.item; if (owner.Target.Attributes.HasInputGrip) { owner.Enable = owner.Target.SourceCount == 0; } else { owner.Enable = false; } if (owner.Target.VolatileData.AllData(true).Count() > 0) { if (owner.Target.VolatileData.AllData(false).Count() > 1) { access = owner.Target.VolatileData.PathCount == 1 ? GH_ParamAccess.list : GH_ParamAccess.tree; } GH_Goo <T> gh_color = owner.Target.VolatileData.AllData(true).ElementAt(0) as GH_Goo <T>; value = gh_color.Value; return(true); } else { //ParamControlHelper.SetData<TGoo, T>(owner, owner.Default); //return owner.Default; value = default(T); return(false); } }
/** * Goo.CastTo<> supports cross-type castings i.e. Integers could be cast to Strings. We need strong typing. * GH_integer -> integer * GH_boolean -> boolean * * returns the System primitive wrapped by the GH_Goo object * returns a Boolean out of GH_Boolean * returns an Integer out of GH_Integer * */ public static Object ConvertToSystemType(GH_Goo <Object> goo) { if (goo.GetType() == GH_TypeLib.t_gh_bool)//GH_BooleanPrototype.GetType())//check if it is a boolean { Boolean result = false; goo.CastTo <Boolean>(ref result); return(result); } else if (goo.GetType() == GH_TypeLib.t_gh_int) { int result = -1; goo.CastTo <int>(ref result); return(result); } else if (goo.GetType() == GH_TypeLib.t_gh_string) { String result = null; goo.CastTo <String>(ref result); return(result); } else if (goo.GetType() == GH_TypeLib.t_gh_objwrapper) { GH_ObjectWrapper result = null; goo.CastTo <GH_ObjectWrapper>(ref result); return(result.Value); } throw new NotSupportedException("Could not get the System object for Goo of type" + goo.GetType()); }
public GH_SpeckleStream(GH_Goo <StreamWrapper> other) : base(other) { Value = other.Value; }
public BasePatternClass(GH_Goo <int> other) : base(other) { }
public GH_SpeckleBase(GH_Goo <Base> other) : base(other) { Value = other.Value; }