Example #1
0
        //---------------------------------------------------------------------
        public Dictionary <string, string> getMapProp4NetSync(byte current_nodetype, byte to_nodetype)
        {
            if (mMapProp.Count == 0)
            {
                return(null);
            }

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

            FieldInfo[] list_fieldinfo = GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
            foreach (var fi in list_fieldinfo)
            {
                if (!fi.FieldType.BaseType.Equals(typeof(IProp)))
                {
                    continue;
                }

                Attribute[] attrs = System.Attribute.GetCustomAttributes(fi);
                foreach (Attribute attr in attrs)
                {
                    if (!(attr is PropAttrDistribution))
                    {
                        continue;
                    }

                    PropAttrDistribution a = (PropAttrDistribution)attr;
                    if (a.NodePrimary == current_nodetype && a.NodeDistribution != null)
                    {
                        foreach (var i in a.NodeDistribution)
                        {
                            if (i == to_nodetype)
                            {
                                IProp p = (IProp)fi.GetValue(this);
                                map_ret[p.getKey()] = EbTool.jsonSerialize(p.getValue());
                                break;
                            }
                        }
                    }
                    break;
                }
            }

            return(map_ret);
        }
Example #2
0
        //-----------------------------------------------------------------------------
        public override void copyValueFrom(IProp other_prop)
        {
            T value = (T)other_prop.getValue();

            set(value);
        }