public override L20nObject Eval(LocaleContext ctx, params L20nObject[] argv) { var global = ctx.GetGlobal(m_Identifier); if (global == null) { return global; } return global.Eval(ctx, argv); }
/// <summary> /// A help function to get the entity based on the first variable. /// The given identifier is either an Identifier, Variable or Global, /// which will define the action to be taken in order to get and return the Root Entity. /// </summary> private Entity GetEntity(LocaleContext ctx) { // is it an identifier? var identifier = m_Root as Identifier; if (identifier != null) return ctx.GetEntity(identifier.Value); // is it a string? var str = m_Root.Eval(ctx) as StringOutput; if (str != null) return ctx.GetEntity(str.Value); // is it a variable? var variable = m_Root as Variable; if (variable != null) return ctx.GetVariable(variable.Identifier) as Entity; // is it a global? var global = m_Root as Global; if (global != null) return ctx.GetGlobal(global.Identifier) as Entity; return null; }
/// <summary> /// A help function to get the root entity based on the first variable. /// The given identifier is either an Identifier, Variable or Global, /// which will define the action to be taken in order to get and return the Root Entity. /// </summary> private Entity GetEntity(LocaleContext ctx, L20nObject key) { // is it an identifier? var identifier = key as Identifier; if (identifier != null) return ctx.GetEntity(identifier.Value); // is it a variable? var variable = key as Variable; if (variable != null) { var obj = ctx.GetVariable(variable.Identifier); // a variable can also be a string-reference to an entity var reference = obj as StringOutput; if (reference != null) { return ctx.GetEntity(reference.Value); } // otherwise it's simply an entity (or at least it should be) return obj as Entity; } // is it a global? var global = key as Global; if (global != null) return ctx.GetGlobal(global.Identifier) as Entity; // is it a string? var str = key as StringOutput; if (str != null) return ctx.GetEntity(str.Value); return null; }