Пример #1
0
        private void CreateProxyProps()
        {
            PropertyInfo[] props = Type.GetProperties(SEARCH_TYPE);
            for (int i = 0; i < props.Length; i++)
            {
                var data = props[i];
                ZXParseAttribute attr = GetAttribute(data);

                // Add The Property
                if (attr != null)
                {
                    // If There Is No String, This Is Not A Proxy
                    if (attr.Key == null)
                    {
                        continue;
                    }
                    ZXPDatum v = new ZXPDatum(attr.Key, data);
                    Data.Add(v);
                    DataDict[v.Key] = v;
                }
                else
                {
                    ZXPDatum v = new ZXPDatum(data.Name, data);
                    Data.Add(v);
                    DataDict[v.Key] = v;
                }
            }
        }
Пример #2
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);
                }
            }
        }
Пример #3
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);
                }
            }
        }
Пример #4
0
        private void CreateProxyProps()
        {
            PropertyInfo[] props = Type.GetProperties(SEARCH_TYPE);
            for(int i = 0; i < props.Length; i++) {
                var data = props[i];
                ZXParseAttribute attr = GetAttribute(data);

                // Add The Property
                if(attr != null) {
                    // If There Is No String, This Is Not A Proxy
                    if(attr.Key == null) continue;
                    ZXPDatum v = new ZXPDatum(attr.Key, data);
                    Data.Add(v);
                    DataDict[v.Key] = v;
                }
                else {
                    ZXPDatum v = new ZXPDatum(data.Name, data);
                    Data.Add(v);
                    DataDict[v.Key] = v;
                }
            }
        }
Пример #5
0
        private void CreateProxyFields()
        {
            FieldInfo[] fields = Type.GetFields(SEARCH_TYPE);
            for(int i = 0; i < fields.Length; i++) {
                var data = fields[i];
                ZXParseAttribute attr = GetAttribute(data);

                // Add The Field
                if(attr != null) {
                    // If There Is No String, This Is Not A Proxy
                    if(attr.Key == null) continue;
                    ZXPDatum v = new ZXPDatum(attr.Key, data);
                    Data.Add(v);
                    DataDict[v.Key] = v;
                }
                else {
                    ZXPDatum v = new ZXPDatum(data.Name, data);
                    Data.Add(v);
                    DataDict[v.Key] = v;
                }
            }
        }