private VAL Valize(object host) { VAL val; if (this.valizer is string) { val = Script.Run(host, (string)valizer, new Memory()); goto L1; } if (this.valizer is Valizer) { Valizer valizer = (Valizer)this.valizer; val = valizer(host); goto L1; } if (this.valizer is IValizer) { IValizer I = (IValizer)this.valizer; val = I.Valizer(host); goto L1; } if (this.valizer is string[]) { string[] members = (string[])this.valizer; string script = ""; for (int i = 0; i < members.Length; i++) { if (i != 0) { script += ","; } script += string.Format("{0} : this.{0}", members[i]); } script = "{" + script + "}"; val = Script.Run(host, script, new Memory()); goto L1; } return(null); L1: if (val.ty == VALTYPE.stringcon) { val.ty = VALTYPE.scriptcon; } val.Class = host.GetType().FullName; return(val); }
private object Devalize(VAL val) { if (this.devalizer is string) { VAL x = Script.Run(val, (string)devalizer, new Memory()); return(x.HostValue); } if (this.devalizer is Devalizer) { Devalizer devalizer = (Devalizer)this.devalizer; return(devalizer(val)); } if (this.valizer is IValizer) { IValizer I = (IValizer)this.valizer; return(I.Devalizer(val)); } return(null); }
/// <summary> /// Register Valizer by object interface /// </summary> /// <param name="type"></param> /// <param name="valizer"></param> /// <returns></returns> public static VAL Register(Type type, IValizer valizer) { return(ValizerScript.Register(type, valizer, null)); }