Beispiel #1
0
			/// <summary>
			/// Tries to get the external variable based on the stored reference
			/// and will return the evaluation result of the looked up object if possible.
			/// Returns <c>null</c> in case the variable could not be found or the evaluation
			/// of the looked up variable returned <c>null</c>.
			/// </summary>
			public override L20nObject Eval(LocaleContext ctx, params L20nObject[] argv)
			{
				var variable = ctx.GetVariable(m_Identifier);
				if (variable == null)
				{
					return variable;
				}

				return variable.Eval(ctx, argv);
			}
Beispiel #2
0
			/// <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;
			}
Beispiel #3
0
			/// <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;
			}