Esempio n. 1
0
        public void AddReplacing(TKey p_key, TValue p_value)
        {
            bool v_found = false;

            for (int i = 0; i < this.Count; i++)
            {
                try
                {
                    if (EqualityExtension.Equals(this[i].Key, p_key))
                    {
                        v_found = true;
                        TPair v_pair = new TPair();
                        v_pair.Value = p_value;
                        v_pair.Key   = p_key;
                        this[i]      = v_pair;
                        break;
                    }
                }
                catch { }
            }
            if (!v_found)
            {
                Add(p_key, p_value);
            }
        }
Esempio n. 2
0
 public int ObjectIndex(T p_object)
 {
     for (int i = 0; i < this.Count; i++)
     {
         if (EqualityExtension.Equals(this[i], p_object))
         {
             return(i);
         }
     }
     return(-1);
 }
Esempio n. 3
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);
 }
Esempio n. 4
0
 public bool ContainsValue(TValue p_value)
 {
     foreach (TPair v_pairValue in this)
     {
         try
         {
             if (EqualityExtension.Equals(v_pairValue.Value, p_value))
             {
                 return(true);
             }
         }
         catch { }
     }
     return(false);
 }
Esempio n. 5
0
 public bool ContainsKey(TKey p_key)
 {
     foreach (TPair v_pairValue in this)
     {
         try
         {
             if (EqualityExtension.Equals(v_pairValue.Key, p_key))
             {
                 return(true);
             }
         }
         catch { }
     }
     return(false);
 }
Esempio n. 6
0
 public TPair GetPairWithValue(TValue p_value)
 {
     foreach (TPair v_pairValues in this)
     {
         try
         {
             if (EqualityExtension.Equals(v_pairValues.Value, p_value))
             {
                 return(v_pairValues);
             }
         }
         catch { }
     }
     return(default(TPair));
 }
Esempio n. 7
0
 public TPair GetPairWithKey(TKey p_key)
 {
     foreach (TPair v_pairValues in this)
     {
         try
         {
             if (EqualityExtension.Equals(v_pairValues.Key, p_key))
             {
                 //if(p_key.Equals(v_pairValues.Comparer))
                 return(v_pairValues);
             }
         }
         catch { }
     }
     return(default(TPair));
 }
Esempio n. 8
0
 public TKey GetKeyWithValue(TValue p_value)
 {
     foreach (TPair v_pairValues in this)
     {
         try
         {
             if (EqualityExtension.Equals(v_pairValues.Value, p_value))
             {
                 //if(p_value.Equals(v_pairValues.Object))
                 return(v_pairValues.Key);
             }
         }
         catch { }
     }
     return(default(TKey));
 }
Esempio n. 9
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);
        }
Esempio n. 10
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);
            }
        }
Esempio n. 11
0
        public ArrayList <TValue> GetAllValuesWithKey(TKey p_key)
        {
            ArrayList <TValue> v_values = new ArrayList <TValue>();

            foreach (TPair v_pairValues in this)
            {
                try
                {
                    if (EqualityExtension.Equals(v_pairValues.Key, p_key))
                    {
                        //if(p_key.Equals(v_pairValues.Comparer))
                        v_values.Add(v_pairValues.Value);
                    }
                }
                catch { }
            }
            return(v_values);
        }
Esempio n. 12
0
        public bool RemoveByKey(TKey p_key)
        {
            TPair v_removePair = default(TPair);

            foreach (TPair v_pairValue in this)
            {
                try
                {
                    if (EqualityExtension.Equals(v_pairValue.Key, p_key))
                    {
                        v_removePair = v_pairValue;
                        break;
                    }
                }
                catch { }
            }
            return(this.RemoveChecking(v_removePair));
        }
Esempio n. 13
0
        public bool RemoveChecking(TValue p_value)
        {
            TPair v_removePair = default(TPair);

            foreach (TPair v_pairValue in this)
            {
                try
                {
                    if (EqualityExtension.Equals(v_pairValue.Value, p_value))
                    {
                        v_removePair = v_pairValue;
                        break;
                    }
                }
                catch { }
            }
            return(this.RemoveChecking(v_removePair));
        }
Esempio n. 14
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);
        }
Esempio n. 15
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);
        }
Esempio n. 16
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);
            }
        }
Esempio n. 17
0
        public void AddChecking(TKey p_key, TValue p_value)
        {
            bool v_found = false;

            foreach (TPair v_pair in this)
            {
                try
                {
                    if (EqualityExtension.Equals(v_pair.Value, p_value) &&
                        EqualityExtension.Equals(v_pair.Key, p_key))
                    {
                        v_found = true;
                        break;
                    }
                }
                catch { }
            }
            if (!v_found)
            {
                Add(p_key, p_value);
            }
        }
Esempio n. 18
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);
        }
Esempio n. 19
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);
 }