Exemplo n.º 1
0
        public T GetVariableValueInternal <T>(string name)
        {
            //TODO:@muhammet burada vb de ref vardı c# karşılık yap.
            GenericVariable <T> result = new GenericVariable <T>();

            if (_myVariables.ContainsKey(name))
            {
                result.ValueAsObject = _myVariables[name].ValueAsObject;
                return((T)result.GetValue());
            }
            //if (MyVariables.TryGetValue(name, out v))
            //{
            //    return v.GetValue();
            //}

            GenericVariable <T>           vTemp = new GenericVariable <T>();
            ResolveVariableValueEventArgs args  = new ResolveVariableValueEventArgs(name, typeof(T));

            ResolveVariableValue?.Invoke(this, args);

            ValidateSetValueType(typeof(T), args.VariableValue);
            vTemp.ValueAsObject = args.VariableValue;
            result = vTemp;
            return((T)result.GetValue());
        }
Exemplo n.º 2
0
        public T GetVariableValueInternal <T>(string name)
        {
            if (_myVariables.TryGetValue(name, out IVariable variable))
            {
                if (typeof(IVariableReference).IsAssignableFrom(variable.VariableType))
                {
                    var val = (IVariableReference)variable.ValueAsObject;
                    return(GetVariableValueInternal <T>(val.Target));
                }

                if (variable is IGenericVariable <T> generic)
                {
                    return((T)generic.GetValue());
                }
            }

            GenericVariable <T>           result = new GenericVariable <T>();
            GenericVariable <T>           vTemp  = new GenericVariable <T>();
            ResolveVariableValueEventArgs args   = new ResolveVariableValueEventArgs(name, typeof(T));

            ResolveVariableValue?.Invoke(this, args);

            ValidateSetValueType(typeof(T), args.VariableValue);
            vTemp.ValueAsObject = args.VariableValue;
            result = vTemp;
            return((T)result.GetValue());
        }