Exemplo n.º 1
0
                          public override bool Equals(System.Object o)
                          {
                              if (o == null || !(o is Map))
                              {
                                  return(false);
                              }
                              Map m = (Map)o;

                              if (size() != m.size())
                              {
                                  return(false);
                              }
                              for (Iterator it = keySet().iterator(); it.hasNext();)
                              {
                                  System.Object k = it.next();
                                  if (!m.containsKey(k))
                                  {
                                      return(false);
                                  }
                                  System.Object v1 = get(k);
                                  System.Object v2 = m.get(k);
                                  if (!(v1 == null ? v2 == null : v1.Equals(v2)))
                                  {
                                      return(false);
                                  }
                              }
                              return(true);
                          }
Exemplo n.º 2
0
        /// <summary>
        /// Compares the entire members of one array whith the other one.
        /// </summary>
        /// <param name="array1">The array to be compared.</param>
        /// <param name="array2">The array to be compared with.</param>
        /// <returns>Returns true if the two specified arrays of Objects are equal
        /// to one another. The two arrays are considered equal if both arrays
        /// contain the same number of elements, and all corresponding pairs of
        /// elements in the two arrays are equal. Two objects e1 and e2 are
        /// considered equal if (e1==null ? e2==null : e1.equals(e2)). In other
        /// words, the two arrays are equal if they contain the same elements in
        /// the same order. Also, two array references are considered equal if
        /// both are null.</returns>
        public static bool Equals(System.Array array1, System.Array array2)
        {
            bool result = false;

            if ((array1 == null) && (array2 == null))
            {
                result = true;
            }
            else if ((array1 != null) && (array2 != null))
            {
                if (array1.Length == array2.Length)
                {
                    int length = array1.Length;
                    result = true;
                    for (int index = 0; index < length; index++)
                    {
                        System.Object o1 = array1.GetValue(index);
                        System.Object o2 = array2.GetValue(index);
                        if (o1 == null && o2 == null)
                        {
                            continue;   // they match
                        }
                        else if (o1 == null || !o1.Equals(o2))
                        {
                            result = false;
                            break;
                        }
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public static bool IsNull(SystemObject sysObj)
        {
            if (sysObj == null || sysObj.Equals(null))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
 public virtual int indexOf(System.Object o, int index)
 {
     for (int i = index; i < this.size(); i++)
     {
         if (o == null ? (this.get(i) == null) : o.Equals(this.get(i)))
         {
             return(i);
         }
     }
     return(-1);
 }
Exemplo n.º 5
0
        protected bool SetProperty <T1>(ref T1 storage, T1 value, [CallerMemberName] string propertyName = null)
        {
            if (Object.Equals(storage, value))
            {
                return(false);
            }

            storage = value;
            OnPropertyChanged(propertyName);
            return(true);
        }
Exemplo n.º 6
0
 public virtual int lastIndexOf(System.Object o, int index)
 {
     for (int i = index; i >= 0; i--)
     {
         if (o == null ? (this.get(i) == null) : o.Equals(this.get(i)))
         {
             return(i);
         }
     }
     return(-1);
 }
Exemplo n.º 7
0
 public virtual int lastIndexOf(System.Object o)
 {
     for (int i = size() - 1; i >= 0; i--)
     {
         if (o == null ? (get(i) == null) : o.Equals(get(i)))
         {
             return(i);
         }
     }
     return(-1);
 }
Exemplo n.º 8
0
                          public virtual int indexOf(System.Object o)
                          {
                              int s = size();

                              for (int i = 0; i < s; i++)
                              {
                                  if (o == null ? (get(i) == null) : o.Equals(get(i)))
                                  {
                                      return(i);
                                  }
                              }
                              return(-1);
                          }
Exemplo n.º 9
0
                          public virtual bool contains(System.Object obj)
                          {
                              Iterator i = this.iterator();

                              while (i.hasNext())
                              {
                                  System.Object o = i.next();
                                  if (obj == null ? o == null : obj.Equals(o))
                                  {
                                      return(true);
                                  }
                              }
                              return(false);
                          }
Exemplo n.º 10
0
        private static bool IsBroken(System.Object obj)
        {
            if (obj == null || !obj.Equals(null))
            {
                return(false);
            }

            System.Type type = obj.GetType();

            FieldInfo[]    fields     = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
            PropertyInfo[] properties = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);


            foreach (FieldInfo fi in fields)
            {
                try
                {
                    System.Object value = fi.GetValue(obj) as System.Object;
                    value.Equals(null);                     // touch
                }
                catch (System.Exception e)
                {
                    if (e.GetType() == typeof(UnityEngine.MissingReferenceException))
                    {
                        return(true);
                    }
                }
            }

            foreach (PropertyInfo pi in properties)            // sprite use only properties
            {
                try
                {
                    System.Object value = pi.GetValue(obj, null) as System.Object;
                    value.Equals(null);                     // touch
                }
                catch (System.Exception e)
                {
                    if (e.GetType() == typeof(UnityEngine.MissingReferenceException))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 11
0
        void DoProcess()
        {
            if (!(owner.Value is DlibFaceLandmarkDetectorPlayMakerActions.DlibObject))
            {
                LogError("owner is not initialized. Add Action \"newClassName\".");
                return;
            }
            System.Object wrapped_owner = DlibFaceLandmarkDetectorPlayMakerActionsUtils.GetWrappedObject <DlibFaceLandmarkDetectorPlayMakerActions.DlibObject, System.Object> (owner);

            if (!(obj.Value is DlibFaceLandmarkDetectorPlayMakerActions.DlibObject))
            {
                LogError("obj is not initialized. Add Action \"newClassName\".");
                return;
            }
            System.Object wrapped_obj = DlibFaceLandmarkDetectorPlayMakerActionsUtils.GetWrappedObject <DlibFaceLandmarkDetectorPlayMakerActions.DlibObject, System.Object> (obj);

            storeResult.Value = wrapped_owner.Equals(wrapped_obj);
        }
Exemplo n.º 12
0
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.OpenCVObject))
            {
                LogError("owner is not initialized. Add Action \"newClassName\".");
                return;
            }
            System.Object wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.OpenCVObject, System.Object>(owner);

            if (!(obj.Value is OpenCVForUnityPlayMakerActions.OpenCVObject))
            {
                LogError("obj is not initialized. Add Action \"newClassName\".");
                return;
            }
            System.Object wrapped_obj = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.OpenCVObject, System.Object>(obj);

            storeResult.Value = wrapped_owner.Equals(wrapped_obj);
        }
Exemplo n.º 13
0
 public virtual bool containsValue(System.Object value)
 {
     if (hasNullKey)
     {
         if (value == null)
         {
             if (valueForNullKey == null)
             {
                 return(true);
             }
         }
         else
         {
             if (value.Equals(valueForNullKey))
             {
                 return(true);
             }
         }
     }
     return(data.ContainsValue(value));
 }
Exemplo n.º 14
0
                          public override bool Equals(System.Object b)
                          {
                              if (b == null || !(b is List))
                              {
                                  return(false);
                              }
                              int  s = this.size();
                              List l = (List)b;

                              if (s != l.size())
                              {
                                  return(false);
                              }
                              for (int i = 0; i < s; i++)
                              {
                                  System.Object e1 = this.get(i);
                                  System.Object e2 = l.get(i);
                                  if (!(e1 == null ? e2 == null : e1.Equals(e2)))
                                  {
                                      return(false);
                                  }
                              }
                              return(true);
                          }
Exemplo n.º 15
0
        private static void FindInGO(GameObject go, MissingType missing)
        {
            _goCnt++;
            Component[] components = go.GetComponents <Component>();
            for (int i = 0; i < components.Length; i++)
            {
                _componentsCnt++;
                Component comp = components[i];
                if (comp == null)
                {
                    if (missing == MissingType.Script)
                    {
                        _missingCnt++;
                        Debug.Log(FullPathToGO(go) + " has an empty script attached in position: " + i, go);
                    }
                }
                else
                {
                    if (missing == MissingType.LinkInScript || missing == MissingType.AudioLinkInScript)
                    {
                        FieldInfo[] fields = comp.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);

                        int fiCnt = fields.Length;
                        for (int fiIdx = 0; fiIdx < fiCnt; ++fiIdx)
                        {
                            FieldInfo     fi    = fields[fiIdx];
                            System.Object value = fi.GetValue(comp) as System.Object;

                            if (missing == MissingType.AudioLinkInScript)
                            {
                                System.Type elementType = fi.FieldType.GetElementType();
                                if (fi.FieldType != typeof(AudioClip) && !(fi.FieldType.IsArray && elementType == typeof(AudioClip)))
                                {
                                    continue;
                                }
                            }

                            if (IsBroken(value))
                            {
                                _missingCnt++;
                                Debug.Log(FullPathToGO(go) + " component " + comp.GetType() + " has broken link for " + fi.Name + " (" + fi.FieldType + ")", go);
                            }
                            else if (value != null && !value.Equals(null))
                            {
                                if (fi.FieldType.IsSubclassOf(typeof(IList)) || fi.FieldType.IsSubclassOf(typeof(System.Array)))
                                {
                                    IList list    = value as IList;
                                    int   listCnt = list.Count;
                                    for (int listIdx = 0; listIdx < listCnt; ++listIdx)
                                    {
                                        System.Object valueInList = list[listIdx];
                                        if (IsBroken(valueInList))
                                        {
                                            _missingCnt++;
                                            Debug.Log(FullPathToGO(go) + " component " + comp.GetType() + " has broken link in list " + fi.Name + " (" + fi.FieldType + ") on position " + listIdx, go);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Now recurse through each child GO (if there are any):
            foreach (Transform childT in go.transform)
            {
                //Debug.Log("Searching " + childT.name  + " " );
                FindInGO(childT.gameObject, missing);
            }
        }
Exemplo n.º 16
0
        /// <summary> We're going to examine rows from the middle outward, searching alternately above and below the
        /// middle, and farther out each time. rowStep is the number of rows between each successive
        /// attempt above and below the middle. So we'd scan row middle, then middle - rowStep, then
        /// middle + rowStep, then middle - (2 * rowStep), etc.
        /// rowStep is bigger as the image is taller, but is always at least 1. We've somewhat arbitrarily
        /// decided that moving up and down by about 1/16 of the image is pretty good; we try more of the
        /// image if "trying harder".
        ///
        /// </summary>
        /// <param name="image">The image to decode
        /// </param>
        /// <param name="hints">Any hints that were requested
        /// </param>
        /// <returns> The contents of the decoded barcode
        /// </returns>
        /// <throws>  ReaderException Any spontaneous errors which occur </throws>
        private Result doDecode(BinaryBitmap image, System.Collections.Hashtable hints)
        {
            int      width  = image.Width;
            int      height = image.Height;
            BitArray row    = new BitArray(width);

            int  middle    = height >> 1;
            bool tryHarder = hints != null && hints.ContainsKey(DecodeHintType.TRY_HARDER);
            int  rowStep   = System.Math.Max(1, height >> (tryHarder?7:4));
            int  maxLines;

            if (tryHarder)
            {
                maxLines = height;                 // Look at the whole image, not just the center
            }
            else
            {
                maxLines = 9;                 // Nine rows spaced 1/16 apart is roughly the middle half of the image
            }

            for (int x = 0; x < maxLines; x++)
            {
                // Scanning from the middle out. Determine which row we're looking at next:
                int  rowStepsAboveOrBelow = (x + 1) >> 1;
                bool isAbove   = (x & 0x01) == 0;               // i.e. is x even?
                int  rowNumber = middle + rowStep * (isAbove?rowStepsAboveOrBelow:-rowStepsAboveOrBelow);
                if (rowNumber < 0 || rowNumber >= height)
                {
                    // Oops, if we run off the top or bottom, stop
                    break;
                }

                // Estimate black point for this row and load it:
                try
                {
                    row = image.getBlackRow(rowNumber, row);
                }
                catch (ReaderException)
                {
                    continue;
                }

                // While we have the image data in a BitArray, it's fairly cheap to reverse it in place to
                // handle decoding upside down barcodes.
                for (int attempt = 0; attempt < 2; attempt++)
                {
                    if (attempt == 1)
                    {
                        // trying again?
                        row.reverse();                         // reverse the row and continue
                        // This means we will only ever draw result points *once* in the life of this method
                        // since we want to avoid drawing the wrong points after flipping the row, and,
                        // don't want to clutter with noise from every single row scan -- just the scans
                        // that start on the center line.
                        if (hints != null && hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK))
                        {
                            System.Collections.Hashtable   newHints = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());                           // Can't use clone() in J2ME
                            System.Collections.IEnumerator hintEnum = hints.Keys.GetEnumerator();
                            //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
                            while (hintEnum.MoveNext())
                            {
                                //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
                                System.Object key = hintEnum.Current;
                                if (!key.Equals(DecodeHintType.NEED_RESULT_POINT_CALLBACK))
                                {
                                    newHints[key] = hints[key];
                                }
                            }
                            hints = newHints;
                        }
                    }
                    try
                    {
                        // Look for a barcode
                        Result result = decodeRow(rowNumber, row, hints);
                        // We found our barcode
                        if (attempt == 1)
                        {
                            // But it was upside down, so note that
                            result.putMetadata(ResultMetadataType.ORIENTATION, (System.Object) 180);
                            // And remember to flip the result points horizontally.
                            ResultPoint[] points = result.ResultPoints;
                            points[0] = new ResultPoint(width - points[0].X - 1, points[0].Y);
                            points[1] = new ResultPoint(width - points[1].X - 1, points[1].Y);
                        }
                        return(result);
                    }
                    catch (ReaderException)
                    {
                        // continue -- just couldn't decode this row
                    }
                }
            }

            throw ReaderException.Instance;
        }
Exemplo n.º 17
0
 public static bool IsNull(System.Object aObj)
 {
     return(aObj == null || aObj.Equals(null));
 }
Exemplo n.º 18
0
        /**
         * Applies a given attribute to the given range of this string.
         *
         * @param attribute
         *            the attribute that will be applied to this string.
         * @param value
         *            the value of the attribute that will be applied to this
         *            string.
         * @param start
         *            the start of the range where the attribute will be applied.
         * @param end
         *            the end of the range where the attribute will be applied.
         * @throws IllegalArgumentException
         *             if {@code start < 0}, {@code end} is greater than the length
         *             of this string, or if {@code start >= end}.
         * @throws NullPointerException
         *             if {@code attribute} is {@code null}.
         */
        public void addAttribute(AttributedCharacterIteratorNS.Attribute attribute,
                                 System.Object value, int start, int end)
        {
            if (null == attribute)
            {
                throw new java.lang.NullPointerException();
            }
            if (start < 0 || end > text.Length || start >= end)
            {
                throw new java.lang.IllegalArgumentException();
            }

            if (value == null)
            {
                return;
            }

            java.util.List <IAC_Range> ranges = attributeMap.get(attribute);
            if (ranges == null)
            {
                ranges = new java.util.ArrayList <IAC_Range>(1);
                ranges.add(new IAC_Range(start, end, value));
                attributeMap.put(attribute, ranges);
                return;
            }
            java.util.ListIterator <IAC_Range> it = ranges.listIterator();
            while (it.hasNext())
            {
                IAC_Range range = it.next();
                if (end <= range.start)
                {
                    it.previous();
                    break;
                }
                else if (start < range.end ||
                         (start == range.end && value.Equals(range.value)))
                {
                    IAC_Range r1 = null, r3;
                    it.remove();
                    r1 = new IAC_Range(range.start, start, range.value);
                    r3 = new IAC_Range(end, range.end, range.value);

                    while (end > range.end && it.hasNext())
                    {
                        range = it.next();
                        if (end <= range.end)
                        {
                            if (end > range.start ||
                                (end == range.start && value.Equals(range.value)))
                            {
                                it.remove();
                                r3 = new IAC_Range(end, range.end, range.value);
                                break;
                            }
                        }
                        else
                        {
                            it.remove();
                        }
                    }

                    if (value.Equals(r1.value))
                    {
                        if (value.Equals(r3.value))
                        {
                            it.add(new IAC_Range(r1.start <start?r1.start : start,
                                                           r3.end> end ? r3.end : end, r1.value));
                        }
                        else
                        {
                            it.add(new IAC_Range(r1.start < start ? r1.start : start,
                                                 end, r1.value));
                            if (r3.start < r3.end)
                            {
                                it.add(r3);
                            }
                        }
                    }
                    else
                    {
                        if (value.Equals(r3.value))
                        {
                            if (r1.start < r1.end)
                            {
                                it.add(r1);
                            }
                            it.add(new IAC_Range(start, r3.end > end ? r3.end : end,
                                                 r3.value));
                        }
                        else
                        {
                            if (r1.start < r1.end)
                            {
                                it.add(r1);
                            }
                            it.add(new IAC_Range(start, end, value));
                            if (r3.start < r3.end)
                            {
                                it.add(r3);
                            }
                        }
                    }
                    return;
                }
            }
            it.add(new IAC_Range(start, end, value));
        }
Exemplo n.º 19
0
 public virtual bool test(System.Object o)
 {
     return(tobj == null ? o == null : tobj.Equals(o));
 }