Example #1
0
        public static SyncProperty GetSyncProperty(Type InType)
        {
            SyncProperty property;

            if (propertyDict.TryGetValue(InType, out property))
            {
                return(property);
            }

            try
            {
                PropertyInfo[] infos = InType.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                int            len   = infos.Length;
                Dictionary <int, PropertyInfo> propertyInfoDict = new Dictionary <int, PropertyInfo>(len);

                for (int i = 0; i < len; i++)
                {
                    object[] attrs = infos[i].GetCustomAttributes(SyncConfig.SYNC_ATTR_TYPE, false);

                    if (1 == attrs.Length)
                    {
                        SyncAttribute syncAttribute = attrs[0] as SyncAttribute;
                        if (null != syncAttribute)
                        {
                            if (propertyInfoDict.ContainsKey(syncAttribute.SyncID))
                            {
                                throw new Exception();
                            }
                            propertyInfoDict.Add(syncAttribute.SyncID, infos[i]);
                        }
                    }
                }

                property = new SyncProperty(InType, propertyInfoDict);
                propertyDict.Add(InType, property);
            }
            catch (Exception ex)
            {
                Debug.LogError(InType + " Create SyncFactory Error : " + ex.Message);
            }


            return(property);
        }
Example #2
0
        protected SyncBase()
        {
            Property = SyncFactory.GetSyncProperty(GetType());

            propertyDelegates = new Delegate[Property.InfosLength];
        }