コード例 #1
0
        //private DateTime _BeginDate;
        //private MB.WinBase.IFace.IViewGridForm _LastSetGridForm;
        //private bool _LastSetState;
        //[System.Diagnostics.DebuggerStepThrough()]
        //private void timer1_Tick(object sender, EventArgs e) {
        //        var sp = System.DateTime.Now.Subtract(_BeginDate);
        //        int house = sp.Hours;
        //        TimeSpan nsp = new TimeSpan(house, sp.Minutes, sp.Seconds);

        //        barStaticItemTime.Caption = string.Format("累计在线时间: {0}", nsp.ToString());
        //}
        //控件权限检验。
        private bool chenckButtonEnable(MB.WinBase.IFace.IViewGridForm gridViewForm, DevExpress.XtraBars.BarButtonItem item)
        {
            if (_ButtonValidatedCatch.ContainsKey(gridViewForm))
            {
                var items = _ButtonValidatedCatch[gridViewForm];
                if (items.ContainsKey(item))
                {
                    return(items[item]);
                }
                else
                {
                    bool v = checkExistsRejectCommand(item) && ValidatedCommandButton(item);
                    items.Add(item, v);
                    return(v);
                }
            }
            else
            {
                bool v    = checkExistsRejectCommand(item) && ValidatedCommandButton(item);
                var  keys = new Dictionary <DevExpress.XtraBars.BarButtonItem, bool>();
                keys.Add(item, v);
                _ButtonValidatedCatch.Add(gridViewForm, keys);
                return(v);
            }
        }
コード例 #2
0
        private void processObject(StringBuilder sXml, object val, Type entityType, bool exceptCheckDataMember)
        {
            Type ty = entityType;

            PropertyInfo[] pros = ty.GetProperties();
            foreach (PropertyInfo info in pros)
            {
                if (info.IsSpecialName)
                {
                    continue;
                }
                if (!exceptCheckDataMember)
                {
                    if (_PropertysIsDataMember.ContainsKey(info))
                    {
                        if (!_PropertysIsDataMember[info])
                        {
                            continue;
                        }
                    }
                    else
                    {
                        object[] att = info.GetCustomAttributes(typeof(DataMemberAttribute), true);
                        _PropertysIsDataMember[info] = att != null && att.Length > 0;
                        if (att == null || att.Length == 0)
                        {
                            continue;
                        }
                    }
                }
                ValueXmlSerializerAttribute cfgAtt = null;
                if (_PropertysXmlAtt.ContainsKey(info))
                {
                    cfgAtt = _PropertysXmlAtt[info];
                }
                else
                {
                    cfgAtt = Attribute.GetCustomAttribute(info, typeof(ValueXmlSerializerAttribute)) as ValueXmlSerializerAttribute;
                    _PropertysXmlAtt.Add(info, cfgAtt);
                }
                if (cfgAtt != null && !cfgAtt.Switch)
                {
                    continue;
                }

                Type proType = info.PropertyType;

                object v = info.GetValue(val, null);

                writeFirstMarker(sXml, info.Name, proType, cfgAtt);
                if (info.PropertyType.IsValueType || string.Compare(info.PropertyType.Name, "String", true) == 0)
                {
                    valueToXmlString(sXml, v, info.PropertyType, cfgAtt);
                }
                else if (info.PropertyType.IsArray)
                {
                    if (v == null)
                    {
                        continue;
                    }
                    if (string.Compare(info.PropertyType.Name, "String[]", true) == 0)
                    {
                        string[] avs = (string[])v;
                        valueToXmlString(sXml, string.Join(",", avs), info.PropertyType, cfgAtt);
                    }
                    else
                    {
                        throw new MB.Util.APPException(string.Format("实体对象的系列化,属性数组类型只支持string[] 类型, {0} 类型暂时不支持", info.PropertyType.Name));
                    }
                }
                else
                {
                    if (v == null)
                    {
                        continue;
                    }

                    IList lstEntity = v as IList;
                    if (lstEntity != null)
                    {
                        foreach (object o in lstEntity)
                        {
                            if (o == null)
                            {
                                continue;
                            }
                            Type childDataType = o.GetType();
                            if (childDataType.IsValueType || string.Compare(childDataType.Name, "String", true) == 0)
                            {
                                valueToXmlString(sXml, v, childDataType, cfgAtt);
                                continue;
                            }
                            writeFirstMarker(sXml, CHILD_ITEM, childDataType, cfgAtt);
                            processObject(sXml, o, childDataType);
                            writeLastMarker(sXml, CHILD_ITEM);
                        }
                    }
                    else
                    {
                        processObject(sXml, v, info.PropertyType);
                    }
                }
                writeLastMarker(sXml, info.Name);
            }
        }