Beispiel #1
0
 public bool ContainsNull()
 {
     for (int i = 0; i < this.Count; i++)
     {
         object v_object = this[i];
         if (EqualityExtension.IsNull(v_object))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
        public void RemoveNulls()
        {
            ArrayList <T> v_newList = new ArrayList <T>();

            for (int i = 0; i < this.Count; i++)
            {
                T v_object = this[i];
                if (!EqualityExtension.IsNull(v_object))
                {
                    v_newList.Add(v_object);
                }
            }
            this.Clear();
            foreach (T v_object in v_newList)
            {
                this.AddWithoutCallEvents(v_object);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Returns 'true' if the specified item is within the list.
        /// </summary>

        public bool Contains(T item)
        {
            if (buffer == null)
            {
                return(false);
            }
            for (int i = 0; i < Count; ++i)
            {
                if (
                    (EqualityExtension.IsNull(buffer[i]) && EqualityExtension.IsNull(item)) ||
                    (!EqualityExtension.IsNull(buffer[i]) && buffer[i].Equals(item))
                    )
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #4
0
        public bool AddChecking(T p_object)
        {
            bool v_sucess = false;

            try
            {
                if (!EqualityExtension.IsNull(p_object) &&
                    !this.Contains(p_object))
                {
                    this.Add(p_object);
                    v_sucess = true;
                }
            }
            catch
            {
                UnityEngine.Debug.Log("An error occurred when trying to AddChecking");
            }
            return(v_sucess);
        }
Beispiel #5
0
        public bool RemoveChecking(T p_object, bool p_removeNulls = true)
        {
            bool v_sucess = false;

            if (!EqualityExtension.IsNull(p_object))
            {
                if (p_removeNulls)
                {
                    RemoveNulls();
                }
                ArrayList <T> v_newList = new ArrayList <T>();
                for (int i = 0; i < this.Count; i++)
                {
                    try
                    {
                        T v_object = this[i];
                        if (!EqualityExtension.Equals(p_object, v_object))
                        {
                            v_newList.Add(v_object);
                        }
                        else
                        {
                            v_sucess = true;
                        }
                    }
                    catch
                    {
                        UnityEngine.Debug.Log("An error occurred when trying to RemoveChecking");
                        v_sucess = true;
                    }
                }
                this.Clear();
                foreach (T v_object in v_newList)
                {
                    this.AddWithoutCallEvents(v_object);
                }
            }
            if (v_sucess)
            {
                OnRemove(p_object);
            }
            return(v_sucess);
        }
Beispiel #6
0
        public void RemovePairsWithNullKeys()
        {
            ArrayList <TPair> v_newList = new ArrayList <TPair>();

            foreach (TPair v_pairValue in this)
            {
                try
                {
                    if (!EqualityExtension.IsNull(v_pairValue.Key))
                    {
                        v_newList.Add(v_pairValue);
                    }
                }
                catch { }
            }
            this.Clear();
            foreach (TPair v_pairValue in v_newList)
            {
                this.AddWithoutCallEvents(v_pairValue);
            }
        }
Beispiel #7
0
        public static object InstantiateClone(object p_objectToClone, System.Type p_newObjectType)
        {
            object v_newObject = null;

            if (!EqualityExtension.IsNull(p_objectToClone))
            {
                try
                {
                    List <Object> v_context = new List <Object>();
                    //We will Serialize the object with same type of himself to prevent kSerializer to write the type
                    Serializer v_serializer = new Serializer();
                    v_serializer.Config.TypeWriterOption = Config.TypeWriterEnum.WhenNeeded;
                    v_serializer.Context.Set(v_context);
                    v_serializer.AddConverter(new UnityObjectConverter());
                    string v_serializedObj = ToJson(p_objectToClone, false, v_serializer);
                    //We must deserialize using new type
                    v_newObject = FromJson(v_serializedObj, p_newObjectType, v_serializer);
                }
                catch { }
            }
            return(v_newObject);
        }
Beispiel #8
0
 public override bool Equals(object p_value)
 {
     if (p_value == this)
     {
         return(true);
     }
     if (!EqualityExtension.IsNull(p_value))
     {
         try
         {
             KVPair <TKey, TValue> v_castedObject = p_value as KVPair <TKey, TValue>;
             if (v_castedObject != null)
             {
                 if (((EqualityExtension.IsNull(v_castedObject.Key) && EqualityExtension.IsNull(this.Key)) || v_castedObject.Key.Equals(this.Key)) &&
                     ((EqualityExtension.IsNull(v_castedObject.Value) && EqualityExtension.IsNull(this.Value)) || v_castedObject.Value.Equals(this.Value)))
                 {
                     return(true);
                 }
             }
         }
         catch { }
     }
     return(false);
 }