SetValue() public method

public SetValue ( object o, object v ) : void
o object
v object
return void
示例#1
0
        private static void ParseSimpleData(object o, ZXPProxy zpp, string s, List <DIndices> ld, ref int li)
        {
            // Check If A Key Is Available
            string key = GetKeyString(s, ld, li);

            if (string.IsNullOrWhiteSpace(key))
            {
                return;
            }

            // Find The Field That Matches To This Key
            ZXPDatum datum = null;

            if (zpp.DataDict.TryGetValue(key, out datum))
            {
                object val = null;

                // Check For Array
                if (datum.Type.IsArray)
                {
                    if (!datum.Type.HasElementType)
                    {
                        return;
                    }
                    Type eType = datum.Type.GetElementType();
                    if (ParseArray(eType, s.Substring(ld[li].Start, ld[li].Length), out val))
                    {
                        datum.SetValue(o, val);
                    }
                }

                // Check For A Possible Conversion
                if (datum.Converter == null)
                {
                    return;
                }

                // Try To Convert
                string sValue = s.Substring(ld[li].Start, ld[li].Length);
                if (ReadValue(sValue, datum.Converter, out val))
                {
                    datum.SetValue(o, val);
                }
            }
        }
示例#2
0
        private static void ParseComplexData(object o, ZXPProxy zpp, string s, List <DIndices> ld, ref int li)
        {
            // Check For Data Availability
            if (li + 1 >= ld.Count || ld[li].Length < 1 || ld[li + 1].Type != DelimitType.Curly)
            {
                return;
            }

            // Check If A Key Is Available
            string key = GetKeyString(s, ld, li);

            if (string.IsNullOrWhiteSpace(key))
            {
                return;
            }

            // Get Substrings
            DIndices diType = ld[li], diData = ld[li + 1];

            li++;

            // Find The Field That Matches To This Key
            ZXPDatum datum = null;

            if (!zpp.DataDict.TryGetValue(key, out datum))
            {
                return;
            }

            // Check For A Possible Conversion
            if (datum.Converter != null)
            {
                // Try To Convert
                object val    = null;
                string sValue = s.Substring(ld[li].Start, ld[li].Length);
                if (ReadValue(sValue, datum.Converter, out val))
                {
                    datum.SetValue(o, val);
                }
                return;
            }
            else
            {
                // Get The Special Type
                string sType = s.Substring(diType.Start, diType.Length);
                if (string.IsNullOrWhiteSpace(sType))
                {
                    return;
                }
                Type cType = GetTypeFromString(sType);
                if (cType == null)
                {
                    return;
                }

                // Create And Set The Data
                object val    = null;
                string sValue = s.Substring(diData.Start, diData.Length);
                if (ReadValue(sValue, datum.Converter, cType, out val))
                {
                    datum.SetValue(o, val);
                }
            }
        }