Beispiel #1
0
        public void Add(string objectName, string value)
        {
            VarObjectStruct varObjectStruct = null;

            // if objectStruct exists return it, else return null
            varObjectStruct = GetObjectFromName(objectName);

            if (varObjectStruct == null)
            {
                // VarObjectStruct entry is object with name and value propertis
                varObjectStruct = new VarObjectStruct(objectName, VarObjectStruct.Type.Array);
                varObjectStruct.Add(value);

                // Add entry to row collection
                varObjectStructList.Add(varObjectStruct);
            }
            else
            {
                varObjectStruct.Add(value);
            }
        }
        private string VarObject(Tag2 tag)
        {
            string result = null;
            try
            {
                if (tag.Child.Name == "set")
                {
                    VarObjectStruct varObjectStruct = null;

                    //{=var.set.[VariableName].[Value]}
                    // If varObject is null, first use, create instance
                    if (varObjectList == null)
                    {
                        varObjectList = new ArrayList();
                    }
                    // Is object alredy set ?
                    foreach (VarObjectStruct isVariable in varObjectList)
                    {
                        if (tag.Child.Child.Name == isVariable.Name)
                        {
                            varObjectStruct = isVariable;
                            break;
                        }
                    }
                    if (varObjectStruct == null)
                    {
                        // varObject entry is object with name and value propertis, tag class will be replacet with one of generic  class
                        varObjectStruct = new VarObjectStruct(tag.Child.Child.Name, VarObjectStruct.Type.Single);
                        varObjectStruct.Add(tag.Child.Child.Child.Name);
                        // Add entry to row collection
                        varObjectList.Add(varObjectStruct);
                        result = ""; // varObjectStruct.Name + " set value to " + varObjectStruct.FetchNext();
                    }
                    else
                    {
                        varObjectStruct.Add(tag.Child.Child.Child.Name);
                        // Remove var object tag and replace with value
                        result = ""; // varObjectStruct.Name + " update value to " + varObjectStruct.FetchNext();
                    }
                }
                else if (tag.Child.Name == "get")
                {
                    //{=var.get.[VariableName]}
                    foreach (VarObjectStruct varObjectStruct in varObjectList)
                    {
                        if (varObjectStruct.Name == tag.Child.Child.Name)
                        {
                            result = varObjectStruct.Fetch();

                            break;
                        }
                    }
                    if (result == null)
                    {
                        result = constError_SyntaxError;
                    }
                }
                else
                {
                    ModuleLog.Write(new string[] { constError_CommandNotFound, tag.InputText }, this, "VarObject", ModuleLog.LogType.ERROR);
                    result = constError_SyntaxError;
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(new string[] { constError_ExecutingBlock, tag.InputText }, this, "VarObject", ModuleLog.LogType.DEBUG);
                ModuleLog.Write(ex, this, "VarObject", ModuleLog.LogType.ERROR);
                result = constError_SyntaxError;
            }
            return result;
        }
        private string VarObject(Tag2 tag)
        {
            string result = null;

            try
            {
                if (tag.Child.Name == "set")
                {
                    VarObjectStruct varObjectStruct = null;

                    //{=var.set.[VariableName].[Value]}
                    // If varObject is null, first use, create instance
                    if (varObjectList == null)
                    {
                        varObjectList = new ArrayList();
                    }
                    // Is object alredy set ?
                    foreach (VarObjectStruct isVariable in varObjectList)
                    {
                        if (tag.Child.Child.Name == isVariable.Name)
                        {
                            varObjectStruct = isVariable;
                            break;
                        }
                    }
                    if (varObjectStruct == null)
                    {
                        // varObject entry is object with name and value propertis, tag class will be replacet with one of generic  class
                        varObjectStruct = new VarObjectStruct(tag.Child.Child.Name, VarObjectStruct.Type.Single);
                        varObjectStruct.Add(tag.Child.Child.Child.Name);
                        // Add entry to row collection
                        varObjectList.Add(varObjectStruct);
                        result = ""; // varObjectStruct.Name + " set value to " + varObjectStruct.FetchNext();
                    }
                    else
                    {
                        varObjectStruct.Add(tag.Child.Child.Child.Name);
                        // Remove var object tag and replace with value
                        result = ""; // varObjectStruct.Name + " update value to " + varObjectStruct.FetchNext();
                    }
                }
                else if (tag.Child.Name == "get")
                {
                    //{=var.get.[VariableName]}
                    foreach (VarObjectStruct varObjectStruct in varObjectList)
                    {
                        if (varObjectStruct.Name == tag.Child.Child.Name)
                        {
                            result = varObjectStruct.Fetch();

                            break;
                        }
                    }
                    if (result == null)
                    {
                        result = constError_SyntaxError;
                    }
                }
                else
                {
                    ModuleLog.Write(new string[] { constError_CommandNotFound, tag.InputText }, this, "VarObject", ModuleLog.LogType.ERROR);
                    result = constError_SyntaxError;
                }
            }
            catch (Exception ex)
            {
                ModuleLog.Write(new string[] { constError_ExecutingBlock, tag.InputText }, this, "VarObject", ModuleLog.LogType.DEBUG);
                ModuleLog.Write(ex, this, "VarObject", ModuleLog.LogType.ERROR);
                result = constError_SyntaxError;
            }
            return(result);
        }