Beispiel #1
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);
 }
Beispiel #2
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);
     }
 }