/**
         * Builds a certificate reference expression that is an {@link ExtensionField}.
         * @param token The token used to build the field.
         * @return An {@link ExtensionField} object that represents the token.  Returns null if the token does not represent an {@link ExtensionField}.
         * @throws PolicyParseException
         */
        public IPolicyExpression BuildExtensionField(String token) //throws PolicyParseException
        {
            IPolicyExpression   retVal    = null;
            ExtensionIdentifier fieldType = ExtensionIdentifier.FromToken(token);
            bool required = token.EndsWith("+");

            if (fieldType != null)
            {
                try
                {
                    Type retType = fieldType.GetReferenceClass(token, required);
                    if (retType == null)
                    {
                        throw new PolicyParseException("ExtensionField with token name " + token + " has not been implemented yet.");
                    }
                    var ctor = retType.Ctor <bool, IPolicyExpression>();
                    retVal = ctor(required);
                }
                catch (PolicyParseException ex)
                {
                    throw ex;
                }
                catch (Exception e)
                {
                    throw new PolicyParseException("Error building ExtensionField", e);
                }
            }
            return(retVal);
        }
예제 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var    extCalculator = new ExtensionIdentifier();
            string path          = PEMLocation.Content as string;
            var    id            = extCalculator.CalculateId(path);

            ExtensionId.Text = id;
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Switchvox.Extensions.GetInfo"/> class with one or more Extension Account ID or Extension Number values.
        /// </summary>
        /// <param name="identifier">A <see cref="T:Switchvox.ExtensionIdentifier"/> value indicating whether Extension numbers or Account IDs will be used to get info for the extensions on your system</param>
        /// <param name="values">A list of Extension Account IDs or Extension Numbers to get information for</param>
        public GetInfo(ExtensionIdentifier identifier, string[] values)
            : base("switchvox.extensions.getInfo")
        {
            if (values.Length == 0)
                throw new ArgumentException("At least one Extension Account ID or Extension Number must be specified.");

            SetTagTypes(identifier);

            List<XElement> valuesList = values.Select(val => new XElement(tagInstance, val)).ToList();

            var xml = new XElement(tagGroup, valuesList);

            SetXml(xml);
        }
예제 #4
0
 private void SetTagTypes(ExtensionIdentifier identifier)
 {
     if (identifier == ExtensionIdentifier.AccountID)
     {
         tagGroup = "account_ids";
         tagInstance = "account_id";
     }
     else if (identifier == ExtensionIdentifier.Extension)
     {
         tagGroup = "extensions";
         tagInstance = "extension";
     }
     else
         throw new NotImplementedException("No handler for the value " + identifier.ToString() + " has been implemented.");
 }
예제 #5
0
 private void SetTagTypes(ExtensionIdentifier identifier)
 {
     if (identifier == ExtensionIdentifier.AccountID)
     {
         tagGroup    = "account_ids";
         tagInstance = "account_id";
     }
     else if (identifier == ExtensionIdentifier.Extension)
     {
         tagGroup    = "extensions";
         tagInstance = "extension";
     }
     else
     {
         throw new NotImplementedException($"No handler for the value '{identifier}' has been implemented.");
     }
 }
예제 #6
0
        /// <summary>
        /// Fetch basic information about the extensions on a phone system.
        /// </summary>
        /// <param name="identifier">A <see cref="ExtensionIdentifier"/> value indicating whether Extension numbers or Account IDs will be used to get info for the extensions on your system</param>
        /// <param name="values">A list of Extension Account IDs or Extension Numbers to get information for.</param>
        /// <returns>All extensions that match the specified search criteria.</returns>
        public List <ExtensionInfo> GetInfo(ExtensionIdentifier identifier, params string[] values)
        {
            if (values.Length == 0)
            {
                throw new ArgumentException("At least one Extension Account ID or Extension Number must be specified.");
            }

            SetTagTypes(identifier);

            List <XElement> valuesList = values.Select(val => new XElement(tagInstance, val)).ToList();

            var xml = new XElement(tagGroup, valuesList);

            var extensions = client.Execute <ListDeserializationLayers.Extensions>(new RequestMethod("switchvox.extensions.getInfo", xml)).Items;

            if (extensions.Count == 0)
            {
                throw new SwitchvoxRequestException("No results for the given Account ID or Extension could be found.");
            }

            return(extensions);
        }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Switchvox.Extensions.GetInfo"/> class with a single Extension Account ID or Extension Number value.
 /// </summary>
 /// <param name="identifier">A <see cref="T:Switchvox.ExtensionIdentifier"/> value indicating whether Extension numbers or Account IDs will be used to get info for the extensions on your system</param>
 /// <param name="value">An Extension Account ID or Extension Number to get information for.</param>
 public GetInfo(ExtensionIdentifier identifier, string value)
     : this(identifier, new[] { value })
 {
 }