Exemplo n.º 1
0
        public object GetValue(string variableName)
        {
            switch (ContainerType)
            {
            case VariableContainerType.InstanceSave:

#if DEBUG
                if (ElementStack.Count != 0)
                {
                    if (ElementStack.Last().Element == null)
                    {
                        throw new InvalidOperationException("The ElementStack contains an ElementWithState with no Element");
                    }
                }
#endif

                VariableSave variable = GetVariable(variableName);
                if (variable != null)
                {
                    return(variable.Value);
                }
                else
                {
                    return(null);
                }

            //return mInstanceSave.GetValueFromThisOrBase(mElementStack, variableName);
            //break;
            case VariableContainerType.StateSave:
                return(mStateSave.GetValueRecursive(variableName));
                //break;
            }

            throw new NotImplementedException();
        }
Exemplo n.º 2
0
        public VariableListSave GetVariableList(string variableName)
        {
            switch (ContainerType)
            {
            case VariableContainerType.InstanceSave:
                return(mInstanceSave.GetVariableListFromThisOrBase(ElementStack.Last().Element, variableName));

            case VariableContainerType.StateSave:
                return(mStateSave.GetVariableListRecursive(variableName));
                //break;
            }
            throw new NotImplementedException();
        }
Exemplo n.º 3
0
        public VariableSave GetVariable(string variableName)
        {
            switch (ContainerType)
            {
            case VariableContainerType.InstanceSave:

                string instanceName = null;
                if (ElementStack.Count != 0)
                {
                    instanceName = ElementStack.Last().InstanceName;
                }

                bool onlyIfSetsValue = false;

#if DEBUG
                if (ElementStack.Count != 0)
                {
                    if (ElementStack.Last().Element == null)
                    {
                        throw new InvalidOperationException("The ElementStack contains an ElementWithState with no Element");
                    }
                }
#endif

                var found = mInstanceSave.GetVariableFromThisOrBase(ElementStack, this, variableName, false, onlyIfSetsValue);
                if (found != null && !string.IsNullOrEmpty(found.ExposedAsName))
                {
                    var allExposed = GetExposedVariablesForThisInstance(mInstanceSave, instanceName, ElementStack, variableName);
                    var exposed    = allExposed.FirstOrDefault();

                    if (exposed != null && exposed.Value != null)
                    {
                        found = exposed;
                    }
                }

                if (found == null || found.SetsValue == false || found.Value == null)
                {
                    onlyIfSetsValue = true;
                    found           = mInstanceSave.GetVariableFromThisOrBase(ElementStack, this, variableName, false, true);
                }

                return(found);

            case VariableContainerType.StateSave:
                return(mStateSave.GetVariableRecursive(variableName));
                //break;
            }
            throw new NotImplementedException();
        }
Exemplo n.º 4
0
        public T GetValue <T>(string variableName)
        {
#if DEBUG
            if (ElementStack.Count != 0)
            {
                if (ElementStack.Last().Element == null)
                {
                    throw new InvalidOperationException("The ElementStack contains an ElementWithState with no Element");
                }
            }
#endif


            object valueAsObject = GetValue(variableName);
            if (valueAsObject is T)
            {
                return((T)valueAsObject);
            }
            else
            {
                return(default(T));
            }
        }