public VariantVariantMap(VariantVariantMap other) : this(AppUtilPINVOKE.new_VariantVariantMap__SWIG_1(VariantVariantMap.getCPtr(other)), true)
 {
     if (AppUtilPINVOKE.SWIGPendingException.Pending)
     {
         throw AppUtilPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public VariantVariantMapEnumerator(VariantVariantMap collection)
 {
     this.collectionRef = collection;
     this.keyCollection = new List <Variant>(collection.Keys);
     this.currentIndex  = -1;
     this.currentObject = null;
     this.currentSize   = this.collectionRef.Count;
 }
Beispiel #3
0
        public VariantVariantMap map()
        {
            VariantVariantMap result = new VariantVariantMap(AppUtilPINVOKE.Variant_map__SWIG_0(this.swigCPtr), false);

            if (AppUtilPINVOKE.SWIGPendingException.Pending)
            {
                throw AppUtilPINVOKE.SWIGPendingException.Retrieve();
            }
            return(result);
        }
        public static IDictionary <string, object> ToStringVariantMap(this VariantVariantMap originalMap, VariantExtension.KeyOptions options)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            foreach (KeyValuePair <Variant, Variant> current in originalMap)
            {
                string key;
                if (current.Key.is_string())
                {
                    key = current.Key.string_value();
                }
                else
                {
                    if (!current.Key.is_fundamental_type())
                    {
                        throw new InvalidCastException("Unable to convert dictionary keys to string");
                    }
                    key = current.Key.AsString().string_value();
                }
                object value = current.Value.ToObject(options);
                dictionary[key] = value;
            }
            return(dictionary);
        }
Beispiel #5
0
 public static Variant FromObject(object o)
 {
     if (o == null)
     {
         return(Variant.Null());
     }
     if (o is string)
     {
         return(Variant.FromString((string)o));
     }
     if (o is long)
     {
         return(Variant.FromInt64((long)o));
     }
     if (o is double)
     {
         return(Variant.FromDouble((double)o));
     }
     if (o is bool)
     {
         return(Variant.FromBool((bool)o));
     }
     if (o is byte[])
     {
         return(Variant.FromBlob((byte[])o));
     }
     if (o is IList)
     {
         IList       list        = (IList)o;
         Variant     variant     = Variant.EmptyVector();
         VariantList variantList = variant.vector();
         IEnumerator enumerator  = list.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 object o2 = enumerator.Current;
                 variantList.Add(Variant.FromObject(o2));
             }
         }
         finally
         {
             IDisposable disposable;
             if ((disposable = (enumerator as IDisposable)) != null)
             {
                 disposable.Dispose();
             }
         }
         return(variant);
     }
     if (o is IDictionary)
     {
         IDictionary           dictionary        = (IDictionary)o;
         Variant               variant2          = Variant.EmptyMap();
         VariantVariantMap     variantVariantMap = variant2.map();
         IDictionaryEnumerator enumerator2       = dictionary.GetEnumerator();
         try
         {
             while (enumerator2.MoveNext())
             {
                 object          obj             = enumerator2.Current;
                 DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
                 Variant         key             = Variant.FromObject(dictionaryEntry.Key);
                 Variant         value           = Variant.FromObject(dictionaryEntry.Value);
                 variantVariantMap[key] = value;
             }
         }
         finally
         {
             IDisposable disposable2;
             if ((disposable2 = (enumerator2 as IDisposable)) != null)
             {
                 disposable2.Dispose();
             }
         }
         return(variant2);
     }
     if (o is byte || o is short || o is int || o is sbyte || o is ushort || o is uint)
     {
         return(Variant.FromInt64(Convert.ToInt64(o)));
     }
     if (o is float)
     {
         return(Variant.FromDouble(Convert.ToDouble(o)));
     }
     throw new ArgumentException("Invalid type " + o.GetType() + " for conversion to Variant");
 }
 public static IDictionary <string, object> ToStringVariantMap(this VariantVariantMap originalMap)
 {
     return(originalMap.ToStringVariantMap(VariantExtension.KeyOptions.UseObjectKeys));
 }
 internal static HandleRef getCPtr(VariantVariantMap obj)
 {
     return((obj != null) ? obj.swigCPtr : new HandleRef(null, IntPtr.Zero));
 }