Ejemplo n.º 1
0
 /// <summary>
 /// 字段复制
 /// </summary>
 /// <param name="value"></param>
 /// <param name="copyValue"></param>
 private void copy(ref valueType value, valueType copyValue)
 {
     foreach (FieldInfo field in fields)
     {
         field.SetValue(value, field.GetValue(copyValue));
     }
 }
Ejemplo n.º 2
0
 public void Push(valueType value)
 {
     Monitor.Enter(poolLock);
     value.Next = head;
     head       = value;
     Monitor.Exit(poolLock);
 }
Ejemplo n.º 3
0
            public static void Write(CharStream sqlStream, valueType value, ConstantConverter converter)
            {
#if NOJIT
                if (fields != null)
                {
                    byte     isAnd = 0;
                    object[] sqlColumnParameters = null, castParameters = null, parameters = null;
                    foreach (sqlModel.updateField field in fields)
                    {
                        if (isAnd == 0)
                        {
                            isAnd = 1;
                        }
                        else
                        {
                            sqlStream.WriteNotNull(" and ");
                        }
                        field.Set(sqlStream, value, converter, ref sqlColumnParameters, ref castParameters, ref parameters);
                    }
                }
#else
                if (writer != null)
                {
                    writer(sqlStream, value, converter);
                }
#endif
            }
Ejemplo n.º 4
0
 /// <summary>
 /// 释放列表
 /// </summary>
 /// <param name="value"></param>
 private void disposeLink(valueType value)
 {
     do
     {
         value.Dispose();
     }while ((value = value.NextTask) != null);
 }
Ejemplo n.º 5
0
            internal int PushNotNull(valueType value)
            {
                if (count >= maxCount)
                {
                    value.Dispose();
                    return(0);
                }
                System.Threading.Interlocked.Increment(ref count);
                valueType headValue;

                do
                {
                    if ((headValue = head) == null)
                    {
                        value.NextTask = null;
                        if (System.Threading.Interlocked.CompareExchange(ref head, value, null) == null)
                        {
                            return(1);
                        }
                    }
                    else
                    {
                        value.NextTask = headValue;
                        if (System.Threading.Interlocked.CompareExchange(ref head, value, headValue) == headValue)
                        {
                            return(1);
                        }
                    }
                    AutoCSer.Threading.ThreadYield.Yield(AutoCSer.Threading.ThreadYield.Type.YieldLinkPush);
                }while (true);
            }
Ejemplo n.º 6
0
            internal void PushLink(valueType value, valueType end, int count)
            {
                System.Threading.Interlocked.Add(ref this.count, count);
                valueType headValue;

                do
                {
                    if ((headValue = head) == null)
                    {
                        end.NextTask = null;
                        if (System.Threading.Interlocked.CompareExchange(ref head, value, null) == null)
                        {
                            return;
                        }
                    }
                    else
                    {
                        end.NextTask = headValue;
                        if (System.Threading.Interlocked.CompareExchange(ref head, value, headValue) == headValue)
                        {
                            return;
                        }
                    }
                    AutoCSer.Threading.ThreadYield.Yield(AutoCSer.Threading.ThreadYield.Type.YieldLinkPush);
                }while (true);
            }
Ejemplo n.º 7
0
            /// <summary>
            /// 清除缓存数据
            /// </summary>
            /// <param name="count">保留缓存数据数量</param>
            internal void ClearCache(int count)
            {
                valueType head = Interlocked.Exchange(ref this.head, null);

                this.count = 0;
                if (head != null)
                {
                    if (count == 0)
                    {
                        disposeLink(head);
                    }
                    else
                    {
                        int       pushCount = count;
                        valueType end       = head;
                        while (--count != 0)
                        {
                            if (end.NextTask == null)
                            {
                                PushLink(head, end, pushCount - count);
                                return;
                            }
                            end = end.NextTask;
                        }
                        valueType next = end.NextTask;
                        end.NextTask = null;
                        PushLink(head, end, pushCount);
                        if (next != null)
                        {
                            disposeLink(next);
                        }
                    }
                }
            }
Ejemplo n.º 8
0
            public static void Update(CharStream sqlStream, MemberMap memberMap, valueType value, ConstantConverter converter)
            {
#if NOJIT
                if (fields != null)
                {
                    byte     isNext = 0;
                    object[] sqlColumnParameters = null, castParameters = null, parameters = null;
                    foreach (sqlModel.updateField field in fields)
                    {
                        if (memberMap.IsMember(field.Field.MemberMapIndex))
                        {
                            if (isNext == 0)
                            {
                                isNext = 1;
                            }
                            else
                            {
                                sqlStream.Write(',');
                            }
                            field.Set(sqlStream, value, converter, ref sqlColumnParameters, ref castParameters, ref parameters);
                        }
                    }
                }
#else
                if (updater != null)
                {
                    updater(sqlStream, memberMap, value, converter);
                }
#endif
            }
Ejemplo n.º 9
0
            public static void Write(CharStream sqlStream, valueType value, ConstantConverter converter, string columnName)
            {
#if NOJIT
                if (fields != null)
                {
                    string[] columnNames         = update.GetColumnNames(columnName);
                    object[] sqlColumnParameters = null, castParameters = null, parameters = null;
                    object   objectValue         = value;
                    int      index = 0;
                    foreach (sqlModel.updateField field in fields)
                    {
                        if (index != 0)
                        {
                            sqlStream.WriteNotNull(" and ");
                        }
                        field.Set(sqlStream, objectValue, converter, columnNames[index++], ref sqlColumnParameters, ref castParameters, ref parameters);
                    }
                }
#else
                if (writer != null)
                {
                    writer(sqlStream, value, converter, Updater.GetColumnNames(columnName));
                }
#endif
                else if (custom != null)
                {
                    custom.Where(sqlStream, value, converter, columnName);
                }
            }
Ejemplo n.º 10
0
 //looks for values by trial and error (no keyword was found)
 private void findValue(String line)
 {
     //in order of most strict to least strict
     if (getINDEX(line))
     {
         type = valueType.INDEX;
     }
     else if (getYESNO(line))
     {
         type = valueType.YESNO;
     }
     else if (getCONTROLTYPE(line))
     {
         type = valueType.CONTROLTYPE;
     }
     else if (getSIZE(line))
     {
         type = valueType.SIZE;
     }
     else if (getNUMBER(line))
     {
         type = valueType.NUMBER;
     }
     else
     {
         type = valueType.STRING; getSTRING(line);
     }                                                  //if all else fails
 }
            /// <summary>
            /// 序列化
            /// </summary>
            /// <param name="serializer"></param>
            /// <param name="value"></param>
            public void Serialize(Serializer serializer, valueType value)
            {
                object     objectValue = value;
                CharStream charStream  = serializer.CharStream;
                byte       isNext      = 0;

                foreach (Field field in fields)
                {
                    if (isNext == 0)
                    {
                        isNext = 1;
                    }
                    else
                    {
                        charStream.Write(',');
                    }
                    serialize(serializer, objectValue, field);
                }
                foreach (Property property in properties)
                {
                    if (isNext == 0)
                    {
                        isNext = 1;
                    }
                    else
                    {
                        charStream.Write(',');
                    }
                    serialize(serializer, objectValue, property);
                }
            }
Ejemplo n.º 12
0
            internal valueType Pop()
            {
                valueType value = Value;

                Value = null;
                return(value);
            }
Ejemplo n.º 13
0
            /// <summary>
            /// 添加节点
            /// </summary>
            /// <param name="value"></param>
            internal void PushNotNull(valueType value)
            {
                if (count >= maxCount)
                {
                    if (isDisponse)
                    {
                        ((IDisposable)value).Dispose();
                    }
                    return;
                }
                System.Threading.Interlocked.Increment(ref count);
                valueType headValue;

                do
                {
                    if ((headValue = head) == null)
                    {
                        value.LinkNext = null;
                        if (System.Threading.Interlocked.CompareExchange(ref head, value, null) == null)
                        {
                            return;
                        }
                    }
                    else
                    {
                        value.LinkNext = headValue;
                        if (System.Threading.Interlocked.CompareExchange(ref head, value, headValue) == headValue)
                        {
                            return;
                        }
                    }
                    ThreadYield.Yield(ThreadYield.Type.YieldLinkPush);
                }while (true);
            }
Ejemplo n.º 14
0
            public valueType GetClear()
            {
                valueType value = head;

                head = end = null;
                return(value);
            }
Ejemplo n.º 15
0
 /// <summary>
 /// 查找节点
 /// </summary>
 /// <param name="node"></param>
 /// <param name="value"></param>
 internal SearchNode(ref Node node, out valueType value)
 {
     HashCode = node.HashCode;
     Key      = node.Key;
     Index    = int.MaxValue;
     value    = node.Value;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 释放列表
 /// </summary>
 /// <param name="value"></param>
 private void disposeLink(valueType value)
 {
     do
     {
         ((IDisposable)value).Dispose();
     }while ((value = value.LinkNext) != null);
 }
Ejemplo n.º 17
0
        public void SetValue(object pValue)
        {
            valueType valueType = getValueType(pValue.GetType());

            switch (valueType)
            {
            case valueType.Int:
                _int = (int)pValue;
                break;

            case valueType.Float:
                _float = (float)pValue;
                break;

            case valueType.Bool:
                _bool = (bool)pValue;
                break;

            case valueType.UnityObject:
                _unityObject = (UnityEngine.Object)pValue;
                break;

            default:
                Debug.LogWarning("not implemented type");
                break;
            }
            _currentValueType = valueType;
        }
Ejemplo n.º 18
0
            public static void Insert(CharStream sqlStream, MemberMap memberMap, valueType value, ConstantConverter converter)
            {
#if NOJIT
                if (fields != null)
                {
                    object[] sqlColumnParameters = null, castParameters = null, parameters = null;
                    byte     isNext = 0;
                    foreach (sqlModel.insertField field in fields)
                    {
                        if (memberMap.IsMember(field.Field.MemberMapIndex))
                        {
                            if (isNext == 0)
                            {
                                isNext = 1;
                            }
                            else
                            {
                                sqlStream.Write(',');
                            }
                            AutoCSer.code.cSharp.sqlModel.fieldInfo fieldInfo = field.Field;
                            if (fieldInfo.IsSqlColumn)
                            {
                                if (sqlColumnParameters == null)
                                {
                                    sqlColumnParameters = new object[] { sqlStream, null, converter }
                                }
                                ;
                                sqlColumnParameters[1] = fieldInfo.Field.GetValue(value);
                                field.SqlColumnMethod.Invoke(null, sqlColumnParameters);
                            }
                            else
                            {
                                object memberValue = fieldInfo.Field.GetValue(value);
                                if (fieldInfo.ToSqlCastMethod != null)
                                {
                                    if (castParameters == null)
                                    {
                                        castParameters = new object[1];
                                    }
                                    castParameters[0] = memberValue;
                                    memberValue       = fieldInfo.ToSqlCastMethod.Invoke(null, castParameters);
                                }
                                if (parameters == null)
                                {
                                    parameters = new object[] { sqlStream, null }
                                }
                                ;
                                parameters[1] = memberValue;
                                fieldInfo.ToSqlMethod.Invoke(converter, parameters);
                            }
                        }
                    }
                }
#else
                if (inserter != null)
                {
                    inserter(sqlStream, memberMap, value, converter);
                }
#endif
            }
Ejemplo n.º 19
0
        public static string GetValue(ManagementScope connectionScope,
                                      baseKey BaseKey,
                                      string key,
                                      string valueName,
                                      valueType ValueType)
        {
            string          typeOfValue  = RegistryMethod.ConvertGetValueType(ValueType);
            string          returnValue  = string.Empty;
            ManagementClass registryTask = new ManagementClass(connectionScope,
                                                               new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters(typeOfValue);

            methodParams["hDefKey"]     = BaseKey;
            methodParams["sSubKeyName"] = key;
            methodParams["sValueName"]  = valueName;

            ManagementBaseObject exitValue = registryTask.InvokeMethod(typeOfValue,
                                                                       methodParams, null);

            try{
                returnValue = exitValue["sValue"].ToString();
            }
            catch {
                try{ //ToDo: fix this ASAP, nested try/catch, I mean come on dude!
                    returnValue = exitValue["uValue"].ToString();
                }
                catch (SystemException e) {
                    returnValue = e.Message.ToString();
                }
            }
            return(returnValue);
        }
Ejemplo n.º 20
0
            internal void PushNotNull(valueType value)
            {
                valueType headValue;

                do
                {
                    if ((headValue = head) == null)
                    {
                        value.LinkNext = null;
                        if (System.Threading.Interlocked.CompareExchange(ref head, value, null) == null)
                        {
                            return;
                        }
                    }
                    else
                    {
                        value.LinkNext = headValue;
                        if (System.Threading.Interlocked.CompareExchange(ref head, value, headValue) == headValue)
                        {
                            return;
                        }
                    }
                    ThreadYield.Yield(ThreadYield.Type.YieldLinkPush);
                }while (true);
            }
Ejemplo n.º 21
0
        public static string ConvertSetValueType(valueType entry)
        {
            string translation = string.Empty;

            switch (entry)
            {
            case valueType.BINARY:
                translation = "SetBinaryValue";
                break;

            case valueType.DWORD:
                translation = "SetDWORDValue";
                break;

            case valueType.EXPANDED_STRING:
                translation = "SetExpandedStringValue";
                break;

            case valueType.MULTI_STRING:
                translation = "SetMultiStringValue";
                break;

            case valueType.STRING:
                translation = "SetStringValue";
                break;
            }
            return(translation);
        }
Ejemplo n.º 22
0
            internal valueType GetClear()
            {
                valueType value = head.LinkNext;

                end           = head;
                head.LinkNext = null;
                return(value);
            }
Ejemplo n.º 23
0
            /// <summary>
            /// 删除数据
            /// </summary>
            /// <param name="logSize"></param>
            /// <returns></returns>
            public valueType Clear(out int logSize)
            {
                valueType value = Value;

                logSize = LogSize;
                Value   = null;
                return(value);
            }
Ejemplo n.º 24
0
 /// <summary>
 /// 设置数据
 /// </summary>
 /// <param name="node"></param>
 /// <param name="value"></param>
 /// <param name="source"></param>
 internal void Set(ref SearchNode node, valueType value, uint source)
 {
     HashCode = node.HashCode;
     Next     = int.MaxValue;
     Key      = node.Key;
     Value    = value;
     Source   = source;
 }
Ejemplo n.º 25
0
 internal void Push()
 {
     countMember.freeValue = value;
     Query.Clear();
     countMember = null;
     value       = null;
     YieldPool.Default.PushNotNull(this);
 }
Ejemplo n.º 26
0
 /// <summary>
 /// 新建会话信息
 /// </summary>
 /// <param name="sessionId"></param>
 /// <param name="timeout"></param>
 /// <param name="value"></param>
 public void New(ref SessionId sessionId, DateTime timeout, valueType value)
 {
     Timeout                 = timeout;
     Low                     = sessionId.Low;
     High                    = sessionId.High;
     SessionValue            = value;
     sessionId.IndexIdentity = Identity;
 }
Ejemplo n.º 27
0
    public void setMuteToggleRemote(valueType valType, bool val)
    {
        if (val)
        {
            switch (valType)
            {
            case valueType.aqi:
                isActiveAqi = true;
                break;

            case valueType.temperature:
                isActiveTemp = true;
                break;

            case valueType.windspeed:
                isActiveWind = true;
                break;

            case valueType.humidity:
                isActiveHumidity = true;
                break;

            case valueType.rainfall:
                isActiveRain = true;
                break;
            }
        }
        else
        {
            switch (valType)
            {
            case valueType.aqi:
                isActiveAqi = false;
                break;

            case valueType.temperature:
                isActiveTemp = false;
                break;

            case valueType.windspeed:
                isActiveWind = false;
                break;

            case valueType.humidity:
                isActiveHumidity = false;
                break;

            case valueType.rainfall:
                isActiveRain = false;
                break;
            }
        }

        foreach (setMute sm in muteScripts)
        {
            sm.updateToggle();
        }
    }
Ejemplo n.º 28
0
 internal int GetNodeOrLink(keyType letter, ref int node, ref int link, out valueType value)
 {
     value = Value;
     if (Nodes == null || Nodes.Count == 0 || !Nodes.TryGetValue(letter, out node))
     {
         return(link = Link);
     }
     return(0);
 }
Ejemplo n.º 29
0
 /// <summary>
 /// 获取Session值
 /// </summary>
 /// <param name="sessionId">Session名称</param>
 /// <param name="value">返回值</param>
 /// <returns>是否存在返回值</returns>
 public bool TryGet(ref SessionId sessionId, out valueType value)
 {
     if (sessionId.Low != 0 && (uint)sessionId.Index < (uint)IndexPool.Array.Length)
     {
         return(IndexPool.Array[sessionId.Index].Get(ref sessionId, Date.NowTime.Now.AddTicks(timeoutTicks), out value));
     }
     value = default(valueType);
     return(false);
 }
Ejemplo n.º 30
0
            internal valueType GetClear(out valueType end)
            {
                end = this.end;
                valueType value = head.LinkNext;

                this.end      = head;
                head.LinkNext = null;
                return(value);
            }
Ejemplo n.º 31
0
 public Register()
 {
     _name = "imma regista";
     _address = 1;
     _valueType = valueType.UINT16;
     _commandFunction = function.Holding;
     _pureValue = "0";
     _value = "0";
     _timeStamp = DateTime.Now;
     _quality = quality.Unknown;
     _val = new Value();
 }
Ejemplo n.º 32
0
 public override string GetValue(baseKey RootKey, string key, string valueName, valueType ValueType)
 {
     string Value = string.Empty;
     if (IsConnected)
         try
         {
             Value = RegistryMethod.GetValue(connectionScope, RootKey, key, valueName, ValueType);
         }
         catch (ManagementException err)
         {
             Console.WriteLine("An error occurred: " + err.Message);
         }
     return Value;
 }
Ejemplo n.º 33
0
 public static string ConvertSetValueType(valueType entry)
 {
     string translation = string.Empty;
     switch (entry)
     {
         case valueType.BINARY:
             translation = "SetBinaryValue";
             break;
         case valueType.DWORD:
             translation = "SetDWORDValue";
             break;
         case valueType.EXPANDED_STRING:
             translation = "SetExpandedStringValue";
             break;
         case valueType.MULTI_STRING:
             translation = "SetMultiStringValue";
             break;
         case valueType.STRING:
             translation = "SetStringValue";
             break;
     }
     return translation;
 }
Ejemplo n.º 34
0
 public object getValue(DateTime dt, string str, int no, valueType valueType = valueType.MEAN)
 {
     return sVals[getDateNo(dt)].getValue(str, no, valueType);
 }
Ejemplo n.º 35
0
 public object getValue(DateTime dt, string str, string measureName, valueType valueType = valueType.MEAN)
 {
     return values.getValue(dt, str, measureName, valueType);
 }
Ejemplo n.º 36
0
 public object getValue(DateTime dt, string str, int no, valueType valueType = valueType.MEAN)
 {
     return values.getValue(dt, str, no, valueType);
 }
Ejemplo n.º 37
0
 public object getValue(string str, string measureName, valueType valueType = valueType.MEAN)
 {
     return vVals[getStringNo(str)].getValue(measureName, valueType);
 }
Ejemplo n.º 38
0
 public object getValue(string str, int no, valueType valueType = valueType.MEAN)
 {
     return vVals[getStringNo(str)].getValue(no, valueType);
 }
Ejemplo n.º 39
0
 public object getValue(DateTime dt, string str, string measureName, valueType valueType = valueType.MEAN)
 {
     return getValue(dt, str, getColNo(dt, measureName, str), valueType);
 }
Ejemplo n.º 40
0
 public abstract string GetValue(baseKey RootKey, string key, string valueName, valueType ValueType);
Ejemplo n.º 41
0
        public static void SetValue(ManagementScope connectionScope,
            baseKey BaseKey,
            string key,
            string valueName,
            string value,
            valueType ValueType)
        {
            string typeOfValue = RegistryMethod.ConvertSetValueType(ValueType);
            string returnValue = string.Empty;
            ManagementClass registryTask = new ManagementClass(connectionScope,
                           new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters(typeOfValue);

            methodParams["hDefKey"] = BaseKey;
            methodParams["sSubKeyName"] = key;
            methodParams["sValueName"] = valueName;
            methodParams["sValue"] = value;

            ManagementBaseObject exitValue = registryTask.InvokeMethod(typeOfValue,
                                                                     methodParams, null);
        }
 //Create a new param object for adding params
 public static Parameter getParam(Int16 hsh, string nme, Int32 vlen, int val, Parameter prm, Color clor, math.vector v, valueType f)
 {
     prm.hash = hsh;
     prm.nb = 0;
     prm.name = nme;
     prm.flag = f;
     prm.valueLength = vlen;
     switch(vlen){
         case 2:
             prm.intValue = (Int16)val;
             break;
         case 4:
             if (f == valueType.integer){
                 prm.intValue = val;
             }
             if (f == valueType.dub) {
                 prm.dubValue = val;
             }
             if (f == valueType.color) {
                 prm.colorVal = clor;
             }
             break;
         case 12:
             f = valueType.vec;
             prm.vec = v;
             break;
     }
     return prm;
 }
Ejemplo n.º 43
0
 public override void SetValue(baseKey RootKey, string key, string valueName, string value, valueType ValueType)
 {
     if (IsConnected)
         try
         {
             RegistryMethod.SetValue(connectionScope, RootKey, key, valueName, value, ValueType);
         }
         catch (ManagementException err)
         {
             Console.WriteLine("An error occurred: " + err.Message);
         }
 }
Ejemplo n.º 44
0
 public object getValue(string measureName, valueType valueType = valueType.MEAN)
 {
     return getValue(getColNo(measureName), valueType);
 }
Ejemplo n.º 45
0
        public static string GetValue(ManagementScope connectionScope,
            baseKey BaseKey,
            string key,
            string valueName,
            valueType ValueType)
        {
            string typeOfValue = RegistryMethod.ConvertGetValueType(ValueType);
            string returnValue = string.Empty;
            ManagementClass registryTask = new ManagementClass(connectionScope,
                           new ManagementPath("DEFAULT:StdRegProv"), new ObjectGetOptions());
            ManagementBaseObject methodParams = registryTask.GetMethodParameters(typeOfValue);

            methodParams["hDefKey"] = BaseKey;
            methodParams["sSubKeyName"] = key;
            methodParams["sValueName"] = valueName;

            ManagementBaseObject exitValue = registryTask.InvokeMethod(typeOfValue,
                                                                     methodParams, null);
            try{
                returnValue = exitValue["sValue"].ToString();
            }
            catch{
                try{ //ToDo: fix this ASAP, nested try/catch, I mean come on dude!
                    returnValue = exitValue["uValue"].ToString();
                }
                catch (SystemException e){
                    returnValue = e.Message.ToString();
                }
            }
            return returnValue;
        }
Ejemplo n.º 46
0
        public object getValue(DateTime dt, string str, int no, valueType valueType = valueType.MEAN)
        {
            if (no > dataTP.Count - 1)
                throw new Exception("inverter.getValue: invalid index");

            object valObj = values.getValue(dt, str, no);

            switch (dataTP[no])
            {
                case valueDTP.INT:
                case valueDTP.DOUBLE:
                case valueDTP.STRING:
                    return valObj;
                default:
                    List<object> valObjs = (List<object>)valObj;
                    return (object) valObjs [(int) valueType];
            }
            throw new Exception ("inverter.getValue: why am I here ??");
        }
Ejemplo n.º 47
0
 public object getValue(DateTime dt, string str, string measureName, valueType valueType = valueType.MEAN)
 {
     return sVals[getDateNo(dt)].getValue(str, measureName, valueType);
 }
Ejemplo n.º 48
0
            //finds and saves values according to the keyword found
            private bool getValue(String line, int k)
            {
                //search for value (in order of frequency)
                bool found = false;

                if (k == 14)
                {
                    type = valueType.INDEX;
                    found = getINDEX(line);
                }
                else if ((k == 5) || (k == 6) || (k == 7) || (k == 8) || (k == 10))
                {
                    type = valueType.YESNO;
                    found = getYESNO(line);
                }
                else if ((k == 3) || (k == 9) || (k == 11) || (k == 12) || (k == 13))
                {
                    type = valueType.NUMBER;
                    found = getNUMBER(line);
                }
                else if (k == 2)
                {
                    type = valueType.CONTROLTYPE;
                    found = getCONTROLTYPE(line);
                }
                else if (k == 4)
                {
                    type = valueType.SIZE;
                    found = getSIZE(line);
                }
                else if (k == 15) //END
                {
                    type = valueType.STRING;
                    found = true;
                }
                else
                {
                    type = valueType.STRING;
                    found = getSTRING(line);
                }

                return found;
            }
Ejemplo n.º 49
0
        public object getValue(int no, valueType valueType = valueType.MEAN)
        {
            checkNo(no);

            int indiceArray = (int) valueType;

            switch(dType[no])
            {
                case valueDTP.INT:
                    List<int> valInt = (List<int>) val;
                    return valInt[no];
                case valueDTP.DOUBLE:
                    List<double> valDbl = (List<double>) val;
                    return valDbl[no];
                case valueDTP.STRING:
                    List<string> valStr = (List<string>) val;
                    return valStr[no];
                case valueDTP.M3INT:
                    List<int[]> valIntArr = (List<int[]>) val;
                    return valIntArr[no][indiceArray];
                case valueDTP.M3DOUBLE:
                    List<double[]> valDblArr = (List<double[]>) val;
                    return valDblArr[no][indiceArray];
            }
            throw new Exception ("I should not be there in valueVal.getValue " + no.ToString() + ", " + dType[no].ToString());
        }
Ejemplo n.º 50
0
 //looks for values by trial and error (no keyword was found)
 private void findValue(String line)
 {
     //in order of most strict to least strict
     if (getINDEX(line)) { type = valueType.INDEX; }
     else if (getYESNO(line)) { type = valueType.YESNO; }
     else if (getCONTROLTYPE(line)) { type = valueType.CONTROLTYPE; }
     else if (getSIZE(line)) { type = valueType.SIZE; }
     else if (getNUMBER(line)) { type = valueType.NUMBER; }
     else { type = valueType.STRING; getSTRING(line); } //if all else fails
 }
 //constructer, it determines a few things to get length.
 public Parameter(Int16 hsh, byte n, string nme, Int32 vlen, bbreader binr)
 {
     this.hash = hsh;
     this.nb = n;
     this.name = nme;
     this.valueLength = vlen;
     switch (vlen)
     {
         case 4:
             if (!this.name.Contains("Color"))
             {
                 this.flag = valueType.unk;
                 this.fourVal = binr.ReadBytes(4);
                 Array.Reverse(this.fourVal);
                 this.intValue = BitConverter.ToInt32(this.fourVal, 0);
                 this.dubValue = BitConverter.ToSingle(this.fourVal, 0);
                 Array.Reverse(this.fourVal);
             }
             else {
                 flag = valueType.color;
                 this.colorVal = binr.readRgba();
             }
             break;
         case 2:
             flag = valueType.integer;
             this.intValue = binr.ReadInt16();
             break;
         case 1:
             flag = valueType.integer;
             this.intValue = binr.ReadByte();
             break;
         case 12:
             flag = valueType.vec;
             this.vec = new math.vector(binr.ReadSingle(), binr.ReadSingle(), binr.ReadSingle());
             break;
         default:
             Console.Write("Unknown Value Length {0} at offset {1}", this.valueLength, binr.BaseStream.Position);
             break;
     }
 }
 private void vLength_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (vLength.SelectedIndex == 3)
     {
         vSel = true;
         panel1.Visible = false;
         value.DecimalPlaces = 5;
         vVal1.DecimalPlaces = 5;
         vVal2.DecimalPlaces = 5;
         add.Location = new Point(12, 195);
         cButton.Location = new Point(109, 195);
         this.Size = new System.Drawing.Size(230, 260);
         groupBox1.Height += 50;
         vVal1.Visible = true;
         vVal2.Visible = true;
         vt = valueType.vec;
     }
     else
     {
         if (vSel)
         {
             add.Location = new Point(12, 145);
             cButton.Location = new Point(109, 145);
             groupBox1.Height -= 50;
             vVal1.Visible = false;
             vVal2.Visible = false;
             this.Size = new System.Drawing.Size(230, 211);
         }
         vSel = false;
         switch (vLength.SelectedIndex)
         {
             case 0:
                 value.DecimalPlaces = 0;
                 panel1.Visible = false;
                 value.Maximum = 32767;
                 value.Minimum = -32767;
                 break;
             case 1:
                 value.DecimalPlaces = 0;
                 vt = valueType.integer;
                 panel1.Visible = false;
                 value.Maximum = 2147483647;
                 value.Minimum = -2147483647;
                 break;
             case 2:
                 vt = valueType.dub;
                 value.DecimalPlaces = 5;
                 panel1.Visible = false;
                 value.Maximum = decimal.MaxValue;
                 value.Maximum = decimal.MinValue;
                 break;
             case 4:
                 vt = valueType.color;
                 panel1.BackColor = c;
                 panel1.Visible = true;
                 break;
         }
     }
 }
Ejemplo n.º 53
0
 /// <summary>
 /// 成员值类型转换委托
 /// </summary>
 /// <param name="value">目标对象</param>
 /// <returns>返回值</returns>
 public object Get(valueType value)
 {
     return Converter(GetValue(value));
 }