public Boolean Set(String[] Values) { WrapBuiltInVariable <String[]> Data = new WrapBuiltInVariable <String[]>(); Data.Value = Values; return(Component.Set(Name, Data)); }
public Boolean Set(double Value) { WrapBuiltInVariable <double> Data = new WrapBuiltInVariable <double>(); Data.Value = Value; return(Component.Set(Name, Data)); }
public int[] ToInt32Array() { WrapBuiltInVariable <int[]> Data = new WrapBuiltInVariable <int[]>(); Component.Get(Name, Data, false); return(Data.Value); }
/// <summary> /// Set the value of a variable. /// Every name is relative to this component (unless preceded by '.' for backward compatiblity) /// </summary> private bool SetInternal <T>(string NamePath, T Value) { WrapBuiltInVariable <T> Data = new WrapBuiltInVariable <T>(); Data.Value = Value; object E = FindInternalEntity(NamePath); if (E != null && E is Entity) { return((E as Entity).Set(Data)); } else { String SetterName = NamePath; // external variable if (NamePath[0] == '.') //this is a FQN { SetterName = NamePath.Remove(0, 1); } else { if (!NamePath.Contains(".")) //if it is qualified then it is relative to this component { SetterName = NamePrefix + NamePath; } } // not an internal entity so look for an external one. return(HostComponent.Set(SetterName, Data)); //not officially correct but the infrastructure doesn't return the correct value when setting readonly property } }
public String[] ToStringArray() { WrapBuiltInVariable <String[]> Data = new WrapBuiltInVariable <String[]>(); Component.Get(Name, Data, false); return(Data.Value); }
/// <summary> /// Attempts to find and return the value of a variable that matches the specified name path. /// The method will return true if found or false otherwise. The value of the variable will be /// returned through the out parameter. /// </summary> public bool GetObject(string NamePath, out object Data) { //// Look in cache first. if (VariableCache.ContainsKey(NamePath)) { Data = VariableCache[NamePath].Get(); return(true); } Data = FindInternalEntity(NamePath); if (Data is Entity) { VariableCache.Add(NamePath, Data as Entity); Data = (Data as Entity).Get(); return(true); } else if (Data is Instance) { Data = (Data as Instance).Model; } if (Data == null) { WrapBuiltInVariable <double> Value = new WrapBuiltInVariable <double>(); if (GetInternal <double>(NamePath, Value)) { Data = Value.Value; } } return(Data != null); }
/// <summary> /// Locate a variable that matches the specified path and return its value. Returns null /// if not found. /// Every name is relative to this component (unless preceded by '.' for backward compatiblity) /// e.g. NamePath: /// "Plant" - no path specified so look in this system /// "Phenology.CurrentPhase" - relative path specified so look for matching child /// ".met.maxt" - absolute path specified so look for exact variable. /// </summary> private bool GetInternal <T>(string NamePath, WrapBuiltInVariable <T> Data) { // relative path. // assume internal entity. object E = FindInternalEntity(NamePath); if (E != null && E is Entity) { Data.setValue((E as Entity).Get()); return(true); } else { String GetterName = NamePath; // external variable if (NamePath[0] == '.') //this is a FQN { GetterName = NamePath.Remove(0, 1); } else { if (!NamePath.Contains(".")) //if it is qualified then it is relative to this component { GetterName = NamePrefix + NamePath; } } return(HostComponent.Get(GetterName, Data, true)); } }
public Boolean Set(float Value) { WrapBuiltInVariable <float> Data = new WrapBuiltInVariable <float>(); Data.Value = Value; return(Component.Set(Name, Data)); }
public float[] ToSingleArray() { WrapBuiltInVariable <float[]> Data = new WrapBuiltInVariable <float[]>(); Component.Get(Name, Data, false); return(Data.Value); }
public override String ToString() { WrapBuiltInVariable <String> Data = new WrapBuiltInVariable <String>(); Component.Get(Name, Data, false); return(Data.Value); }
public double ToDouble() { WrapBuiltInVariable <double> Data = new WrapBuiltInVariable <double>(); Component.Get(Name, Data, false); return(Data.Value); }
/// <summary> /// /// </summary> /// <returns></returns> public bool ToBoolean() { WrapBuiltInVariable <bool> Data = new WrapBuiltInVariable <bool>(); Component.Get(Name, Data, false); return(Data.Value); }
public DateTime ToDateTime() { WrapBuiltInVariable <int> Data = new WrapBuiltInVariable <int>(); Component.Get(Name, Data, false); int JulianDate = Data.Value; return(DateUtility.JulianDayNumberToDateTime(JulianDate)); }
/// <summary> /// Attempts to find and return the value of a variable that matches the specified name path. /// The method will return true if found or false otherwise. The value of the variable will be /// returned through the out parameter. /// </summary> public bool Get(string NamePath, out string[] Data) { WrapBuiltInVariable <string[]> Value = new WrapBuiltInVariable <string[]>(); if (GetInternal <string[]>(NamePath, Value)) { Data = Value.Value; return(true); } else { Data = null; return(false); } }
/// <summary> /// Attempts to find and return the value of a variable that matches the specified name path. /// The method will return true if found or false otherwise. The value of the variable will be /// returned through the out parameter. /// </summary> public bool Get(string NamePath, out double Data) { WrapBuiltInVariable <double> Value = new WrapBuiltInVariable <double>(); if (GetInternal <double>(NamePath, Value)) { Data = Value.Value; return(true); } else { Data = Double.NaN; return(false); } }
/// <summary> /// Attempts to find and return the value of a variable that matches the specified name path. /// The method will return true if found or false otherwise. The value of the variable will be /// returned through the out parameter. /// </summary> public bool Get(string NamePath, out float Data) { WrapBuiltInVariable <float> Value = new WrapBuiltInVariable <float>(); if (GetInternal <float>(NamePath, Value)) { Data = Value.Value; return(true); } else { Data = Single.NaN; return(false); } }
/// <summary> /// Attempts to find and return the value of a variable that matches the specified name path. /// The method will return true if found or false otherwise. The value of the variable will be /// returned through the out parameter. /// </summary> public bool Get(string NamePath, out int Data) { WrapBuiltInVariable <int> Value = new WrapBuiltInVariable <int>(); if (GetInternal <int>(NamePath, Value)) { Data = Value.Value; return(true); } else { Data = Int32.MaxValue; return(false); } }
public bool Exists() { WrapBuiltInVariable <String> Data = new WrapBuiltInVariable <String>(); return(Component.Get(Name, Data, true)); }