示例#1
0
        /// <summary>
        /// convert passengers to dss for getting sign name.
        /// </summary>
        /// <param name="p">the passengers object</param>
        /// <param name="openWith">the dictionary</param>
        /// <example>
        /// <code language="C#" description="convert passengers to dss">
        /// RequestBus.PackagePassengersToDSS(p:p, specifiedFields:specifiedFields, openWith: out openWith);
        /// </code>
        /// </example>
        private static void PackagePassengersToDSS(Passengers p, out Dictionary <string, string> openWith, Dictionary <string, string> specifiedFields = null, string SignNameKey = "Sign", Dictionary <string, string> keyIDpair = null)
        {
            Dictionary <string, string> _dss = new Dictionary <string, string>();

            specifiedFields = specifiedFields ?? new Dictionary <string, string>()
            {
            };
            keyIDpair = keyIDpair ?? new Dictionary <String, String>();
            RF.GlobalClass.Utils.Do.getPropertyNamesOfObject(p).Select(delegate(string _name)
            {
                string result = RF.GlobalClass.Utils.Do.MagicProperty <string>(p, _name)();
                try
                {
                    string _tmp = String.Empty;
                    if (keyIDpair.TryGetValue(_name, out _tmp))
                    {
                        _name = _tmp;
                    }
                    else
                    {
                    }
                    if ((specifiedFields.Keys.Count == 0 && SignNameKey != _name))
                    {
                        _dss.Add(_name, "" + result + "");
                    }
                    else if ((specifiedFields.TryGetValue(_name, out _tmp)))
                    {
                        if (!String.IsNullOrEmpty(_tmp))
                        {
                            _name = _tmp;
                        }
                        else
                        {
                        }
                        _dss.Add(_name, "" + result + "");
                    }
                    else
                    {
                    }
                    if (null == result)
                    {
                        p.GetType().GetProperty(_name).SetValue(p, "", null);
                    }
                    else
                    {
                    }
                }
                catch (Exception ex) { }
                return(result);
            }).ToArray();
            openWith = _dss;
        }
示例#2
0
        public static string SRExampleGetRequest(object[] objectAry) // object obj, Dictionary<string, string> specifiedFields, Dictionary<string, string> keyIDpair = null})
        {
            Object obj = objectAry.GetValue(0);
            Dictionary <String, String> specifiedFields = objectAry.GetValue(1) as Dictionary <String, String>;
            Dictionary <String, String> keyIDpair       = objectAry.GetValue(2) as Dictionary <String, String>;

            Passengers p = obj as Passengers;

            Dictionary <string, string> openWith = new Dictionary <string, string>();

            #region comment

            /*
             * 签名:
             *
             */
            #endregion

            #region specifiedFields default value
            specifiedFields = specifiedFields ?? SRExampleGetRequestSpecifiedFields;
            #endregion

            keyIDpair = keyIDpair ?? SRExampleGetRequestKeyIDPair;
            RequestBus.PackagePassengersToDSS(p: p, specifiedFields: specifiedFields, openWith: out openWith, keyIDpair: keyIDpair);

            p.passenger0 = carfs.CARFSecurer.Program.GetEncrytedMessage("QADHOAEBPEUISDTAPJOPNGOERINRVF", RF.GlobalClass.Utils.Convert.ObjectToJSON(openWith));

            #region modified in programming of SRExample
            p.GetType().GetProperties().Select(delegate(System.Reflection.PropertyInfo pi)
            {
                if (keyIDpair.ContainsKey(pi.Name))
                {
                    string kipValue = keyIDpair[pi.Name];
                    if (!openWith.ContainsKey(kipValue) && !String.IsNullOrEmpty(kipValue))
                    {
                        openWith.Add(kipValue, pi.GetValue(p, null) as String);
                    }
                    else
                    {
                    }
                    //if (specifiedFields.ContainsKey(keyIDpair[pi.Name]))
                    //{
                    //    if (!openWith.ContainsKey(specifiedFields[keyIDpair[pi.Name]]))
                    //    {
                    //        openWith.Add(specifiedFields[keyIDpair[pi.Name]], pi.GetValue(p, null) as String);
                    //    }
                    //    else { }
                    //}
                    //else { }
                }
                else if (keyIDpair.Count == 0 && !openWith.ContainsKey(pi.Name))
                {
                    openWith.Add(pi.Name, pi.GetValue(p, null) as String);
                }
                else
                {
                }
                return(pi);
            }).ToArray();
            return(RF.GlobalClass.Utils.Convert.ObjectToJSON(openWith));

            // return RF.GlobalClass.Utils.Convert.ObjectToJSON(p);
            #endregion
        }