Ejemplo n.º 1
0
        public async Task <string> UpdateIbxObject <T>(T ibxObject, bool RemoveEmpty = true) where T : RefObject
        {
            if (InfobloxSDKExtensionMethods.IsInfobloxType <T>())
            {
                if (ibxObject != null)
                {
                    PropertyInfo prop = ibxObject.GetType().GetTypeInfo().GetProperty("_ref");

                    if (prop != null)
                    {
                        string reference = prop.GetValue(ibxObject) as string;

                        if (!String.IsNullOrEmpty(reference))
                        {
                            string Json = InfobloxSDKExtensionMethods.PrepareObjectForSend(ibxObject, RemoveEmpty);

                            return(await this.PutAsync(reference, Json));
                        }
                        else
                        {
                            throw new ArgumentNullException("ibxObject._ref", "The _ref property cannot be null or empty.");
                        }
                    }
                    else
                    {
                        throw new ArgumentException("The updated object must contain a valid _ref property data cannot be null.");
                    }
                }
                else
                {
                    throw new ArgumentNullException("ibxObject", "The updated object cannot be null.");
                }
            }
            else
            {
                throw new ArgumentException(String.Format("The type must be a valid infoblox object type, {0} was provided.", typeof(T).Name));
            }
        }
Ejemplo n.º 2
0
 public async Task <string> NewIbxObject(dynamic ibxObject)
 {
     if (ibxObject != null)
     {
         if (InfobloxSDKExtensionMethods.IsInfobloxType(ibxObject.GetType()))
         {
             return(await this.PostAsync(InfobloxSDKExtensionMethods.GetNameAttribute(ibxObject), InfobloxSDKExtensionMethods.PrepareObjectForSend(ibxObject, true)));
         }
         else
         {
             throw new ArgumentException($"The type must be a valid infoblox object type, {ibxObject.GetType().FullName} was provided.");
         }
     }
     else
     {
         throw new ArgumentNullException("ibxObject", "The ibxObject parameter cannot be null.");
     }
 }