Esempio n. 1
0
    public override void onUpdateSync <T>(WrapProperty wrapProperty, List <Sync <T> > syncs)
    {
        if (WrapProperty.checkError(wrapProperty))
        {
            return;
        }
        if (wrapProperty.p is UIData)
        {
            switch ((UIData.Property)wrapProperty.n)
            {
            case UIData.Property.state:
            {
                ValueChangeUtils.replaceCallBack(this, syncs);
                dirty = true;
            }
            break;

            default:
                Logger.LogError("Don't process: " + wrapProperty + "; " + this);
                break;
            }
            return;
        }
        // Child
        if (wrapProperty.p is State)
        {
            dirty = true;
            return;
        }
        Logger.LogError("Don't process: " + wrapProperty + "; " + syncs + "; " + this);
    }
Esempio n. 2
0
    public override void onUpdateSync <T>(WrapProperty wrapProperty, List <Sync <T> > syncs)
    {
        if (WrapProperty.checkError(wrapProperty))
        {
            return;
        }
        if (wrapProperty.p is UIData)
        {
            switch ((UIData.Property)wrapProperty.n)
            {
            case UIData.Property.toastData:
            {
                ValueChangeUtils.replaceCallBack(this, syncs);
                dirty = true;
            }
            break;

            case UIData.Property.toastMessageUI:
            {
                ValueChangeUtils.replaceCallBack(this, syncs);
                dirty = true;
            }
            break;

            default:
                Debug.LogError("unknown wrapProperty: " + wrapProperty + "; " + this);
                break;
            }
            return;
        }
        if (wrapProperty.p is ToastData)
        {
            switch ((ToastData.Property)wrapProperty.n)
            {
            case ToastData.Property.messages:
                dirty = true;
                break;

            case ToastData.Property.maxIndex:
                break;

            case ToastData.Property.state:
                dirty = true;
                break;

            default:
                Debug.LogError("unknown wrapProperty: " + wrapProperty + "; " + this);
                break;
            }
            return;
        }
        if (wrapProperty.p is ToastMessageUI.UIData)
        {
            return;
        }
        Debug.LogError("Don't process: " + wrapProperty + "; " + syncs + "; " + this);
    }
Esempio n. 3
0
 public static bool checkError(WrapProperty wrapProperty)
 {
     if (wrapProperty.p == null)
     {
         Logger.LogError("wrapProperty null");
         return(true);
     }
     return(false);
 }
Esempio n. 4
0
 public override void copyWrapProperty(WrapProperty otherWrapProperty)
 {
     if (otherWrapProperty != null && otherWrapProperty is VO <T> )
     {
         VO <T> otherVP = (VO <T>)otherWrapProperty;
         this.v = otherVP.v;
     }
     else
     {
         Logger.LogError("why not the same type wrapProperty: " + this + "; " + otherWrapProperty);
     }
 }
Esempio n. 5
0
    public string getListWrapPropertyString()
    {
        string temp = "";

        {
            for (int i = 0; i < pts.Count; i++)
            {
                WrapProperty wrapProperty = pts[i];
                temp += "{" + wrapProperty + "}";
            }
        }
        return(temp);
    }
Esempio n. 6
0
    public WrapProperty findProperty(byte propertyName)
    {
        WrapProperty property = null;

        for (int i = 0; i < pts.Count; i++)
        {
            WrapProperty check = pts[i];
            if (check.n == propertyName)
            {
                property = check;
                break;
            }
        }
        return(property);
    }
Esempio n. 7
0
 /**
  * cai copy nay chua copy cai makeId: chua biet nen lam the nao
  * */
 public static void copyData(Data copyData, Data originData, List <byte> allowNames = null)
 {
     if (copyData == null || originData == null || copyData.GetType() != originData.GetType())
     {
         Logger.LogError("cannot copy data null or wrong type");
         return;
     }
     if (copyData == originData)
     {
         Logger.LogError("the same data");
         return;
     }
     // Field
     {
         FieldInfo[] fieldInfos = copyData.GetType().GetFields();
         for (int index = 0; index < fieldInfos.Length; index++)
         {
             FieldInfo fieldInfo = fieldInfos[index];
             if (fieldInfo.FieldType.IsSubclassOf(typeof(WrapProperty)))
             {
                 // Debug.Log ("this is wrapProperty: " + fieldInfo.FieldType);
                 object copyFieldValue   = fieldInfo.GetValue(copyData);
                 object originFieldValue = fieldInfo.GetValue(originData);
                 if (copyFieldValue is WrapProperty && originFieldValue is WrapProperty)
                 {
                     WrapProperty copyWrapProperty = (WrapProperty)(object)copyFieldValue;
                     if (allowNames == null || allowNames.Contains(copyWrapProperty.n))
                     {
                         WrapProperty originWrapProperty = (WrapProperty)(object)originFieldValue;
                         // Copy index
                         copyWrapProperty.setIndex(originWrapProperty.getIndex());
                         // Copy content
                         copyWrapProperty.copyWrapProperty(originWrapProperty);
                     }
                     else
                     {
                         // Debug.LogError ("not allow copy wrapProperty: " + copyWrapProperty);
                     }
                 }
                 else
                 {
                     Logger.LogError("Why not wrap property");
                 }
             }
         }
     }
 }
Esempio n. 8
0
 public static bool IsDifferent(Data A, Data B)
 {
     if (A == B)
     {
         Logger.LogError("the same data");
         return(false);
     }
     if (A != null && B != null)
     {
         if (A.GetType() == B.GetType())
         {
             bool ret = false;
             // compare each property
             foreach (WrapProperty AProperty in A.pts)
             {
                 WrapProperty BProperty = B.findProperty(AProperty.n);
                 if (BProperty != null)
                 {
                     if (WrapProperty.isDifferent(AProperty, BProperty))
                     {
                         ret = true;
                         break;
                     }
                 }
                 else
                 {
                     Logger.LogError("BProperty null: " + A + "; " + B);
                     ret = true;
                     break;
                 }
             }
             return(ret);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         Logger.LogError("A, B null");
         return(false);
     }
 }
            public WrapType()
            {
                var properties = typeof(T).GetProperties();
                var fields     = typeof(T).GetFields();

                _properties = new PropertyInfo[properties.Length + fields.Length];

                for (int i = 0; i < properties.Length; i++)
                {
                    var m = properties[i];
                    _properties[i] = new WrapProperty(m.PropertyType, m);
                }

                for (int i = 0; i < fields.Length; i++)
                {
                    var m = fields[i];
                    _properties[i + properties.Length] = new WrapProperty(m.FieldType, m);
                }
            }
Esempio n. 10
0
 public override void copyWrapProperty(WrapProperty otherWrapProperty)
 {
     if (otherWrapProperty != null && otherWrapProperty is VD <T> )
     {
         VD <T> otherVP = (VD <T>)otherWrapProperty;
         // copy index
         {
         }
         // Data
         {
             // Get Data
             Data oldData = this.v != null ? (Data)(object)this.v : null;
             Data newData = otherVP.v != null ? (Data)(object)otherVP.v : null;
             // Check need new
             bool needNew = true;
             {
                 if (oldData != null && newData != null)
                 {
                     if (oldData.GetType() == newData.GetType())
                     {
                         if (oldData.uid == newData.uid)
                         {
                             needNew = false;
                         }
                     }
                 }
             }
             if (needNew)
             {
                 this.v = (T)(object)DataUtils.cloneData(newData);
             }
             else
             {
                 // update
                 DataUtils.copyData(oldData, newData);
             }
         }
     }
     else
     {
         Logger.LogError("why not the same type wrapProperty: " + this + "; " + otherWrapProperty);
     }
 }
Esempio n. 11
0
        public override void onUpdateSync <T>(WrapProperty wrapProperty, List <Sync <T> > syncs)
        {
            if (WrapProperty.checkError(wrapProperty))
            {
                return;
            }
            if (wrapProperty.p is Appear)
            {
                switch ((Appear.Property)wrapProperty.n)
                {
                case Appear.Property.toastMessage:
                    break;

                default:
                    Logger.LogError("Don't process: " + wrapProperty + "; " + this);
                    break;
                }
                return;
            }
            Logger.LogError("Don't process: " + data + "; " + syncs + "; " + this);
        }
Esempio n. 12
0
        public override void onUpdateSync <T>(WrapProperty wrapProperty, List <Sync <T> > syncs)
        {
            if (WrapProperty.checkError(wrapProperty))
            {
                return;
            }
            if (wrapProperty.p is Hide)
            {
                switch ((Hide.Property)wrapProperty.n)
                {
                case Hide.Property.toastMessage:
                    dirty = true;
                    break;

                default:
                    Logger.LogError("Don't process: " + wrapProperty + "; " + this);
                    break;
                }
                return;
            }
            // Parent
            if (wrapProperty.p is ToastMessageUI.UIData)
            {
                switch ((ToastMessageUI.UIData.Property)wrapProperty.n)
                {
                case ToastMessageUI.UIData.Property.toastMessage:
                    dirty = true;
                    break;

                case ToastMessageUI.UIData.Property.state:
                    break;

                default:
                    Logger.LogError("Don't process: " + wrapProperty + "; " + this);
                    break;
                }
                return;
            }
            Logger.LogError("Don't process: " + data + "; " + syncs + "; " + this);
        }
Esempio n. 13
0
 set => SetValue(WrapProperty, value);
Esempio n. 14
0
 public Data findData(List <Data.SI> idList)
 {
     // Debug.LogError ("findData: " + this + ", " + this.propertyName + ", " + this.uid);
     if (idList.Count >= 1)
     {
         Data.SI searchInfo = idList[idList.Count - 1];
         if (searchInfo.i == uid && (this.p == null || searchInfo.n == this.propertyName))
         {
             //Debug.Log ("foundData: " + this + ", " + this.propertyName + ", " + this.uniqueId);
             if (idList.Count == 1)
             {
                 return(this);
             }
             else
             {
                 // find deeper in child
                 List <Data.SI> childIdList = new List <Data.SI>();
                 for (int i = 0; i < idList.Count - 1; i++)
                 {
                     childIdList.Add(idList[i]);
                 }
                 // search
                 Data find = null;
                 {
                     // Find WrapProperty
                     Data.SI      childInfo    = childIdList[childIdList.Count - 1];
                     WrapProperty wrapProperty = this.findProperty(childInfo.n);
                     if (wrapProperty != null && wrapProperty.getValueType().IsSubclassOf(typeof(Data)))
                     {
                         Data child = null;
                         // Find child
                         {
                             int valueCount = wrapProperty.getValueCount();
                             for (int i = valueCount - 1; i >= 0; i--)
                             {
                                 Data checkChild = (Data)wrapProperty.getValue(i);
                                 if (checkChild != null)
                                 {
                                     if (checkChild.uid == childInfo.i)
                                     {
                                         child = checkChild;
                                         break;
                                     }
                                 }
                                 else
                                 {
                                     Logger.LogError("checkChild null");
                                 }
                             }
                         }
                         // Search in child
                         if (child != null)
                         {
                             find = child.findData(childIdList);
                         }
                         else
                         {
                             // Debug.LogError ("Cannot find child");
                         }
                     }
                     else
                     {
                         // Debug.LogError ("wrapProperty null");
                     }
                 }
                 // Debug.Log ("search: " + this + ", find: " + find);
                 return(find);
             }
         }
         else
         {
             // Debug.LogError ("Cannot find data: " + searchInfo + ", " + this.uid + ", " + this.p + ", " + this);
             return(null);
         }
     }
     else
     {
         // Debug.Log ("Cannot find data: " + idList + ", " + this);
         return(null);
     }
     // return findData (idList, null);
 }
Esempio n. 15
0
 public abstract void copyWrapProperty(WrapProperty otherWrapProperty);
Esempio n. 16
0
 public override void copyWrapProperty(WrapProperty otherWrapProperty)
 {
     if (otherWrapProperty is LD <T> )
     {
         LD <T> otherLD = (LD <T>)otherWrapProperty;
         // find listChange
         List <Change <T> > changes = new List <Change <T> >();
         {
             // make the same count
             {
                 // remove excess value
                 if (this.getValueCount() > otherLD.getValueCount())
                 {
                     ChangeRemove <T> changeRemove = new ChangeRemove <T>();
                     {
                         changeRemove.index  = otherLD.getValueCount();
                         changeRemove.number = this.getValueCount() - otherLD.getValueCount();
                     }
                     changes.Add(changeRemove);
                 }
                 // need insert
                 else if (this.getValueCount() < otherLD.getValueCount())
                 {
                     ChangeAdd <T> changeAdd = new ChangeAdd <T>();
                     {
                         changeAdd.index = this.getValueCount();
                         for (int i = this.getValueCount(); i < otherLD.getValueCount(); i++)
                         {
                             Data oldData = (Data)(object)otherLD.vs[i];
                             changeAdd.values.Add((T)(object)DataUtils.cloneData(oldData));
                         }
                     }
                     changes.Add(changeAdd);
                 }
             }
             // Copy each value
             {
                 // oldChangeSet
                 ChangeSet <T> oldChangeSet = null;
                 // minCount
                 int minCount = Math.Min(this.getValueCount(), otherLD.getValueCount());
                 for (int i = 0; i < minCount; i++)
                 {
                     T oldValue = this.vs[i];
                     T newValue = otherLD.vs[i];
                     // get new add data
                     T    needAddData = default(T);
                     bool needAdd     = false;
                     {
                         // Get Data
                         Data oldData = oldValue != null ? (Data)(object)oldValue : null;
                         Data newData = newValue != null ? (Data)(object)newValue : null;
                         // Check need new
                         bool needNew = true;
                         {
                             if (oldData != null && newData != null)
                             {
                                 if (oldData.GetType() == newData.GetType())
                                 {
                                     if (oldData.uid == newData.uid)
                                     {
                                         needNew = false;
                                     }
                                 }
                             }
                         }
                         if (needNew)
                         {
                             needAdd     = true;
                             needAddData = (T)(object)DataUtils.cloneData(newData);
                         }
                         else
                         {
                             // update
                             DataUtils.copyData(oldData, newData);
                         }
                     }
                     // Make changeSet
                     if (needAdd)
                     {
                         // get changeSet
                         ChangeSet <T> changeSet = null;
                         {
                             // setIdex: set position in list
                             int setIndex = i;
                             // check old
                             if (oldChangeSet != null)
                             {
                                 if (oldChangeSet.index + oldChangeSet.values.Count == setIndex)
                                 {
                                     changeSet = oldChangeSet;
                                 }
                             }
                             // make new
                             if (changeSet == null)
                             {
                                 changeSet = new ChangeSet <T>();
                                 {
                                     changeSet.index = setIndex;
                                 }
                                 changes.Add(changeSet);
                                 // set new old
                                 oldChangeSet = changeSet;
                             }
                         }
                         // add value
                         changeSet.values.Add(needAddData);
                     }
                 }
             }
         }
         // Change
         if (changes.Count > 0)
         {
             this.processChange(changes);
         }
     }
     else
     {
         Logger.LogError("why not the same type wrapProperty: " + this + "; " + otherWrapProperty);
     }
 }
Esempio n. 17
0
 public override void copyWrapProperty(WrapProperty otherWrapProperty)
 {
     if (otherWrapProperty is LO <T> )
     {
         LO <T> otherLP = (LO <T>)otherWrapProperty;
         // find listChange
         List <Change <T> > changes = new List <Change <T> >();
         {
             // make the same count
             {
                 // remove excess value
                 if (this.getValueCount() > otherLP.getValueCount())
                 {
                     ChangeRemove <T> changeRemove = new ChangeRemove <T>();
                     {
                         changeRemove.index  = otherLP.getValueCount();
                         changeRemove.number = this.getValueCount() - otherLP.getValueCount();
                     }
                     changes.Add(changeRemove);
                 }
                 // need insert
                 else if (this.getValueCount() < otherLP.getValueCount())
                 {
                     ChangeAdd <T> changeAdd = new ChangeAdd <T>();
                     {
                         changeAdd.index = this.getValueCount();
                         for (int i = this.getValueCount(); i < otherLP.getValueCount(); i++)
                         {
                             changeAdd.values.Add(otherLP.vs[i]);
                         }
                     }
                     changes.Add(changeAdd);
                 }
             }
             // Copy each value
             {
                 // oldChangeSet
                 ChangeSet <T> oldChangeSet = null;
                 // minCount
                 int minCount = Math.Min(this.getValueCount(), otherLP.getValueCount());
                 for (int i = 0; i < minCount; i++)
                 {
                     T oldValue = this.vs[i];
                     T newValue = otherLP.vs[i];
                     // get new add data
                     T    needAddData = default(T);
                     bool needAdd     = false;
                     {
                         if (!object.Equals(newValue, oldValue))
                         {
                             needAdd     = true;
                             needAddData = newValue;
                         }
                     }
                     // Make changeSet
                     if (needAdd)
                     {
                         // get changeSet
                         ChangeSet <T> changeSet = null;
                         {
                             // setIdex: set position in list
                             int setIndex = i;
                             // check old
                             if (oldChangeSet != null)
                             {
                                 if (oldChangeSet.index + oldChangeSet.values.Count == setIndex)
                                 {
                                     changeSet = oldChangeSet;
                                 }
                             }
                             // make new
                             if (changeSet == null)
                             {
                                 changeSet = new ChangeSet <T>();
                                 {
                                     changeSet.index = setIndex;
                                 }
                                 changes.Add(changeSet);
                                 // set new old
                                 oldChangeSet = changeSet;
                             }
                         }
                         // add value
                         changeSet.values.Add(needAddData);
                     }
                 }
             }
         }
         // Change
         if (changes.Count > 0)
         {
             this.processChange(changes);
         }
     }
     else
     {
         Logger.LogError("why not the same type wrapProperty: " + this + "; " + otherWrapProperty);
     }
 }
Esempio n. 18
0
 public static bool isDifferent(WrapProperty wrapProperty1, WrapProperty wrapProperty2)
 {
     if (!object.Equals(wrapProperty1, wrapProperty2))
     {
         if (wrapProperty1.getType() == wrapProperty2.getType())
         {
             if (wrapProperty1.getValueCount() == wrapProperty2.getValueCount())
             {
                 bool ret = false;
                 for (int i = 0; i < wrapProperty1.getValueCount(); i++)
                 {
                     object value1 = wrapProperty1.getValue(i);
                     object value2 = wrapProperty2.getValue(i);
                     // equals
                     if (object.Equals(value1, value2))
                     {
                         // Debug.Log ("equal value, continue");
                     }
                     else
                     {
                         // if data?
                         if (value1 != null && value2 != null)
                         {
                             if (value1.GetType() != value2.GetType())
                             {
                                 ret = true;
                                 break;
                             }
                             else
                             {
                                 if (value1 is Data && value2 is Data)
                                 {
                                     Data data1 = value1 as Data;
                                     Data data2 = value2 as Data;
                                     if (DataUtils.IsDifferent(data1, data2))
                                     {
                                         ret = true;
                                         break;
                                     }
                                 }
                                 else
                                 {
                                     ret = true;
                                     break;
                                 }
                             }
                         }
                         else
                         {
                             Logger.LogError("why value null when compare");
                         }
                     }
                 }
                 return(ret);
             }
             else
             {
                 Logger.LogError("different value count: " + wrapProperty1 + "; " + wrapProperty2);
                 return(true);
             }
         }
         else
         {
             Logger.LogError("not the same type: " + wrapProperty1 + "; " + wrapProperty2);
             return(true);
         }
     }
     else
     {
         Logger.LogError("the same property: " + wrapProperty1 + "; " + wrapProperty2);
         return(false);
     }
 }
Esempio n. 19
0
 public abstract void onUpdateSync <T>(WrapProperty wrapProperty, List <Sync <T> > syncs);