/// <summary>
 /// SYNTAX: Config set myVar "string value"
 /// </summary>
 /// <param name="args">Command line parameters</param>
 private static void SetVariable(string[] args)
 {
     if (args.Length > 2)
     {
         string variableName  = args[1];
         string variableValue = args[2];
         Epi.PermanentVariable perm;
         if (args.Length == 3)
         {
             perm = new PermanentVariable(variableName, DataType.Text);
         }
         else
         {
             perm = new PermanentVariable(variableName, GetDataType(args[3]));
         }
         try
         {
             new MemoryRegion().DefineVariable(perm);
         }
         catch (Exception ex)
         {
             //
         }
         perm.Expression = variableValue;
     }
 }
 private static void SetVariableViaDialog(string[] args)
 {
     if (args.Length > 2)
     {
         string variableName = args[1];
         string prompt       = args[2];
         Epi.PermanentVariable perm;
         DataType dataType;
         if (args.Length == 3)
         {
             dataType = DataType.Text;
         }
         else
         {
             dataType = GetDataType(args[3]);
         }
         perm = new PermanentVariable(variableName, dataType);
         try
         {
             new MemoryRegion().DefineVariable(perm);
         }
         catch (Exception ex)
         {
             //
         }
         VariableInputDialog dialog = new VariableInputDialog(dataType, prompt);
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             perm.Expression = dialog.Result.ToString();
         }
     }
 }
Пример #3
0
        public void Define(EpiInfo.Plugin.IVariable symbol)
        {
            if
            (
                (symbol.VariableScope == EpiInfo.Plugin.VariableScope.Permanent | symbol.VariableScope == EpiInfo.Plugin.VariableScope.Global) && !_name.Equals("global", StringComparison.OrdinalIgnoreCase) ||
                !string.IsNullOrEmpty(symbol.Namespace) && (!string.IsNullOrEmpty(_name) && !_name.Equals(symbol.Namespace, StringComparison.OrdinalIgnoreCase))
            )
            {
                if (_parent != null)
                {
                    _parent.Define(symbol);
                }
            }
            else if (!string.IsNullOrEmpty(symbol.Namespace) && !_name.Equals(symbol.Namespace))
            {
                if (_parent != null)
                {
                    _parent.Define(symbol);
                }
            }
            else
            {
                if (_symbolList.ContainsKey(symbol.Name))
                {
                    _symbolList[symbol.Name] = symbol;
                }
                else
                {
                    _symbolList.Add(symbol.Name, symbol);

                    if (symbol.VariableScope == EpiInfo.Plugin.VariableScope.Permanent)
                    {
                        PermanentVariable permanentVariable = new PermanentVariable(symbol.Name, (Epi.DataType)symbol.DataType);
                        permanentVariable.Expression = symbol.Expression;
                        Epi.MemoryRegion.UpdatePermanentVariable(permanentVariable);
                    }
                }
            }
        }
Пример #4
0
        public void Define(EpiInfo.Plugin.IVariable symbol)
        {
            if
            (
                (symbol.VariableScope == EpiInfo.Plugin.VariableScope.Permanent | symbol.VariableScope == EpiInfo.Plugin.VariableScope.Global) && !_name.Equals("global", StringComparison.OrdinalIgnoreCase)
                || !string.IsNullOrEmpty(symbol.Namespace) && (!string.IsNullOrEmpty(_name) && !_name.Equals(symbol.Namespace, StringComparison.OrdinalIgnoreCase))
            )
            {
                if (_parent != null)
                {
                    _parent.Define(symbol);
                }
            }
            else if (!string.IsNullOrEmpty(symbol.Namespace) && !_name.Equals(symbol.Namespace))
            {
                if (_parent != null)
                {
                    _parent.Define(symbol);
                }
            }
            else
            {
                if (_symbolList.ContainsKey(symbol.Name))
                {
                    _symbolList[symbol.Name] = symbol;
                }
                else
                {
                    _symbolList.Add(symbol.Name, symbol);

                    if (symbol.VariableScope == EpiInfo.Plugin.VariableScope.Permanent)
                    {
                        PermanentVariable permanentVariable = new PermanentVariable(symbol.Name, (Epi.DataType)symbol.DataType);
                        permanentVariable.Expression = symbol.Expression;
                        Epi.MemoryRegion.UpdatePermanentVariable(permanentVariable);
                    }
                }
            }
        }