Exemple #1
0
 public AddressExpansionResponse ExpandAddress(string input, AddressExpansionOptions options)
 {
     if (!IsLanguageClassifierLoaded)
     {
         LoadLanguageClassifier();
     }
     return(new AddressExpansionResponse(input, options));
 }
Exemple #2
0
        internal AddressExpansionResponse(string input, AddressExpansionOptions options)
        {
            if (ReferenceEquals(options, null))
            {
                throw new NullReferenceException();
            }
            _InputString = MarshalUTF8.StringToPtr(input);
            var native = LibPostal.UnsafeNativeMethods.ExpandAddress(_InputString, options._Native, ref _NumExpansions);

            if (native == IntPtr.Zero || native.ToPointer() == null)
            {
                return;
            }
            _Instance = native;

            Expansions = new string[_NumExpansions];
            for (int x = 0; x < (int)_NumExpansions; x++)
            {
                int offset = x * Marshal.SizeOf(typeof(IntPtr));
                Expansions[x] = MarshalUTF8.PtrToString(Marshal.ReadIntPtr(native, offset));
            }
        }