Ejemplo n.º 1
0
        public static void InitializeProvider(this ITaskPanesReceiver receiver, object application,
                                              object ctpFactoryInst)
        {
            if (receiver == default)
            {
                throw new ArgumentNullException(nameof(receiver));
            }

            BaseProvider.AddReceiver(receiver);

            if (DryIocProvider.Application == default)
            {
                var dryIocApplication = new Application.ExcelApplication(
                    application: application,
                    ctpFactoryInst: ctpFactoryInst,
                    contentType: receiver.GetType());

                DryIocProvider.InitializeApplication(dryIocApplication);

                DryIocProvider.OnApplicationExitEvent  += OnApplicationExit;
                DryIocProvider.OnScopeClosingEvent     += OnScopeClosing;
                DryIocProvider.OnScopeInitializedEvent += OnScopeInitialized;
                DryIocProvider.OnScopeOpenedEvent      += OnScopeOpened;
                DryIocProvider.OnProviderReadyEvent    += OnProviderReady;
                DryIocProvider.OnTaskPaneChangedEvent  += OnTaskPaneChanged;
            }
        }
Ejemplo n.º 2
0
        private void UpdateEmailPassword()
        {
            CreateAlert("Send Verification Code", "", new[] { "Email" }, (resultArr) =>
            {
                var email = resultArr[0];
                BaseProvider.SendVerifyCodeWithEmail(email, AGCVerifyCodeAction.SetPassword);

                CreateAlert("Update Email Password", "", new[] { "Password", "Verification Code" }, (updateArr) =>
                {
                    var password = updateArr[0];
                    var code     = updateArr[1];

                    // update the password of the current user
                    HMFTask <NSObject> passwordReq = AGCAuth.GetInstance().CurrentUser?.UpdatePassword(password, code, (int)AGCAuthProviderType.Email);

                    passwordReq.AddOnSuccessCallback((result) =>
                    {
                        Console.WriteLine("password update success");
                    });
                    passwordReq.AddOnFailureCallback((error) =>
                    {
                        Console.WriteLine("password update failed");
                    });
                });
            });
        }
Ejemplo n.º 3
0
        private void UpdatePhone()
        {
            CreateAlert("Send Verification Code", "", new[] { "Country Code", "Phone number" }, (resultArr) =>
            {
                var countryCode = resultArr[0];
                var phoneNumber = resultArr[1];
                BaseProvider.SendVerifyCodeWithCountryCode(countryCode, phoneNumber, AGCVerifyCodeAction.RegisterLogin);
                CreateAlert("Update Phone", "", new[] { "Country code", "Phone number", "Verification Code" }, (updateArr) =>
                {
                    countryCode = updateArr[0];
                    phoneNumber = updateArr[1];
                    var code    = updateArr[2];

                    // update the phone number of the current user
                    HMFTask <NSObject> phoneReq = AGCAuth.GetInstance().CurrentUser?.UpdatePhoneWithCountryCode(countryCode, phoneNumber, code);

                    phoneReq.AddOnSuccessCallback((result) =>
                    {
                        Console.WriteLine("phone update success");
                    });
                    phoneReq.AddOnFailureCallback((error) =>
                    {
                        Console.WriteLine("phone update failed");
                    });
                });
            });
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs a new instance of the device information. Device and useragent are provided
 /// uses indexes in the providers strings collection.
 /// </summary>
 /// <param name="provider">The provider the device will be assigned to.</param>
 /// <param name="uniqueDeviceID">The unique device name.</param>
 /// <param name="userAgentStringIndex">The string index of the user agent string.</param>
 /// <param name="parent">The parent device, or null if no parent.</param>
 internal DeviceInfo(BaseProvider provider, string uniqueDeviceID, int userAgentStringIndex, DeviceInfo parent) : 
     base(provider,
         uniqueDeviceID,
         userAgentStringIndex >= 0 ? provider.Strings.Get(userAgentStringIndex) : String.Empty,
         parent) 
 {
 }
Ejemplo n.º 5
0
 public AlbumService(IConverterFactory factory, BaseProvider <Album> providerAlbum, IPhotoService photoService)
 {
     _providerAlbum = providerAlbum;
     _factory       = factory;
     _photoService  = photoService;
     _converter     = _factory.GetConverter <IAlbumConverter>();
 }
Ejemplo n.º 6
0
        private async Task <Shared.Models.CallMethodResultInfo <OperationContext> > CallMethod(TelegramClientInfo clientInfo)
        {
            Shared.Models.CallMethodResultInfo <OperationContext> result = await BaseProvider.CallMethod(clientInfo.CurrentServiceName, Guid.NewGuid().ToString(), clientInfo.CurrentMethodName, clientInfo.ParameterInfoes.ToArray()
                                                                                                         , null, clientInfo, null, _serverBase, null, x => true);

            return(result);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructs a new instance of the device information. Device and useragent are provided
 /// uses indexes in the providers strings collection.
 /// </summary>
 /// <param name="provider">The provider the device will be assigned to.</param>
 /// <param name="uniqueDeviceID">The unique device name.</param>
 /// <param name="parent">The parent device, or null if no parent.</param>
 internal DeviceInfo(BaseProvider provider, string uniqueDeviceID, DeviceInfo parent) :
     base(provider,
         uniqueDeviceID,
         String.Empty,
         parent)
 {
 }
Ejemplo n.º 8
0
        private void UpdatePhonePassword()
        {
            CreateAlert("Send Verification Code", "", new[] { "Country code", "Phone number" }, (resultArr) =>
            {
                var countryCode = resultArr[0];
                var phoneNumber = resultArr[1];
                BaseProvider.SendVerifyCodeWithCountryCode(countryCode, phoneNumber, AGCVerifyCodeAction.SetPassword);
                CreateAlert("Update Phone Password", "", new[] { "New Password", "Verification Code" }, (updateArr) =>
                {
                    var password = updateArr[0];
                    var code     = updateArr[1];

                    // update the password of the current user
                    HMFTask <NSObject> passwordReq = AGCAuth.GetInstance().CurrentUser?.UpdatePassword(password, code, (int)AGCAuthProviderType.Phone);

                    passwordReq.AddOnSuccessCallback((result) =>
                    {
                        Console.WriteLine("password update success");
                    });
                    passwordReq.AddOnFailureCallback((error) =>
                    {
                        Console.WriteLine("password update failed--" + error);
                    });
                });
            });
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates an instance of <cref see="DeviceInfo"/>.
 /// </summary>
 /// <param name="userAgent">User agent string used to identify this device.</param>
 /// <param name="deviceId">A unique Identifier of the device.</param>
 /// <param name="provider">A reference to the complete index of devices.</param>
 internal DeviceInfo(
     BaseProvider provider,
     string deviceId,
     string userAgent)
     : base(provider, deviceId, userAgent)
 {
 }
Ejemplo n.º 10
0
        private CustomTaskPane GetTaskPane(TaskPaneSettings settings)
        {
            var result = default(CustomTaskPane);

            result = ctpFactory.CreateCTP(
                cTPAxID: progId,
                cTPTitle: settings.Title,
                cTPParentWindow: taskPaneWindow) as CustomTaskPane;

            try
            {
                result.Visible              = false;
                result.DockPosition         = settings.GetDockPosition();
                result.DockPositionRestrict = settings.GetDockRestriction();

                if (result.DockPosition != MsoCTPDockPosition.msoCTPDockPositionLeft &&
                    result.DockPosition != MsoCTPDockPosition.msoCTPDockPositionRight)
                {
                    result.Height = settings.Height;
                }

                if (result.DockPosition != MsoCTPDockPosition.msoCTPDockPositionBottom &&
                    result.DockPosition != MsoCTPDockPosition.msoCTPDockPositionTop)
                {
                    result.Width = settings.Width;
                }

                result.DockPositionStateChangeEvent += (t) => BaseProvider.OnTaskPaneChanged(t);
                result.VisibleStateChangeEvent      += (t) => BaseProvider.OnTaskPaneChanged(t);
            }
            catch
            { }

            return(result);
        }
Ejemplo n.º 11
0
        public IActionResult Map()
        {
            if (ViewBag.HasConfig = BaseProvider.ConfigProvider.HasConfig())
            {
                BaseProvider.InitializeProjectSource();
                var source = BaseProvider.ProjectSource;

                var model = new List <Tuple <IProjectReference, Dictionary <Tuple <IProjectFile, IProjectInformation>, NugetDependency[]>, Dictionary <IProjectFile, NugetDefinition> > >();

                var projects = source.GetAllProjects(false);

                var tasks = new List <Task>();

                foreach (var project in projects)
                {
                    tasks.Add(FetchDependencyMapItems(source, project, model));
                }

                Task.WhenAll(tasks).Wait();

                return(View(model));
            }

            return(View((object)null));
        }
Ejemplo n.º 12
0
        public IActionResult CreateChickenNugetJson(string project)
        {
            if (ViewBag.HasConfig = BaseProvider.ConfigProvider.HasConfig())
            {
                var result = new System.Text.StringBuilder();

                BaseProvider.InitializeProjectSource();
                var source = BaseProvider.ProjectSource;

                var model = new List <Tuple <IProjectReference, IProjectFile[], bool> >();

                var projects = source.GetAllProjects(false);

                var tasks = new List <Task>();

                foreach (var proj in projects)
                {
                    if (proj.GetIdentifier() == project)
                    {
                        result.AppendLine("Found project");
                        source.CreateChickenNugetProject(proj);
                        break;
                    }
                }

                Task.WhenAll(tasks).Wait();

                result.AppendLine("Done");

                return(Content(result.ToString()));
            }

            return(Content("Fail"));
        }
 /// <summary>
 /// Calculates the current cash.
 /// </summary>
 /// <param name="payment">  the payment </param>
 /// <param name="provider">  the provider </param>
 /// <returns> the current cash </returns>
 public virtual CurrencyAmount currentCash(Payment payment, BaseProvider provider)
 {
     if (payment.Date.isEqual(provider.ValuationDate))
     {
         return(payment.Value);
     }
     return(CurrencyAmount.zero(payment.Currency));
 }
 /// <summary>
 /// Computes the forecast value of the payment.
 /// <para>
 /// The present value is zero if the payment date is before the valuation date.
 ///
 /// </para>
 /// </summary>
 /// <param name="payment">  the payment </param>
 /// <param name="provider">  the provider </param>
 /// <returns> the forecast value </returns>
 public virtual double forecastValueAmount(Payment payment, BaseProvider provider)
 {
     if (provider.ValuationDate.isAfter(payment.Date))
     {
         return(0d);
     }
     return(payment.Amount);
 }
Ejemplo n.º 15
0
 public Game(BaseProvider provider, string name, string path)
 {
     Provider      = provider;
     provider.Game = this;
     Name          = name;
     Path          = path;
     Dll           = IOPath.Combine(Path, "DummyDll", "Assembly-CSharp.dll");
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Computes the forecast value of the payment.
 /// <para>
 /// The present value is zero if the payment date is before the valuation date.
 ///
 /// </para>
 /// </summary>
 /// <param name="payment">  the payment </param>
 /// <param name="provider">  the provider </param>
 /// <returns> the forecast value </returns>
 public virtual CurrencyAmount forecastValue(Payment payment, BaseProvider provider)
 {
     if (provider.ValuationDate.isAfter(payment.Date))
     {
         return(CurrencyAmount.zero(payment.Currency));
     }
     return(payment.Value);
 }
Ejemplo n.º 17
0
 public TagService(IConverterFactory factory, BaseProvider <Tag> provider,
                   BaseProvider <PhotoToTag> providerPhotoToTag, BaseProvider <Photo> providerPhoto)
 {
     _providerTag        = provider;
     _providerPhoto      = providerPhoto;
     _providerPhotoToTag = providerPhotoToTag;
     _factory            = factory;
     _converter          = _factory.GetConverter <ITagConverter>();
 }
Ejemplo n.º 18
0
 public Game(BaseProvider provider, string name, string path)
 {
     Provider      = provider;
     provider.Game = this;
     Name          = name;
     Postfix       = char.ToLowerInvariant(name[0]);
     Path          = path;
     Dll           = IOPath.Combine(Path, "DummyDll", "Assembly-CSharp.dll");
 }
Ejemplo n.º 19
0
        public override Task Invoke(IOwinContext context)
        {
            //context.Response.Headers.Add("Access-Control-Allow-Origin", "*".Split(','));
            //context.Response.Headers.Add("Access-Control-Allow-Credentials", "true".Split(','));
            //// Added "Accept-Encoding" to this list
            //context.Response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Accept-Encoding, Content-Length, Content-MD5, Date, X-Api-Version, X-File-Name".Split(','));
            //context.Response.Headers.Add("Access-Control-Allow-Methods", "POST,GET,PUT,PATCH,DELETE,OPTIONS".Split(','));
            //// New Code Starts here
            //if (context.Request.Method == "OPTIONS")
            //{
            //    context.Response.StatusCode = (int)HttpStatusCode.OK;
            //    return Next.Invoke(context);
            //}

            string serviceName  = context.Request.Uri.PathAndQuery.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
            bool   isWebSocketd = context.Request.Headers.ContainsKey("Sec-WebSocket-Key");

            if (!BaseProvider.ExistService(serviceName, CurrentServerBase) && !isWebSocketd && !context.Request.Headers.ContainsKey("signalgo") && !context.Request.Headers.ContainsKey("signalgo-servicedetail") && context.Request.Headers["content-type"] != "SignalGo Service Reference")
            {
                return(Next.Invoke(context));
            }

            OwinClientInfo owinClientInfo = new OwinClientInfo(CurrentServerBase);

            owinClientInfo.ConnectedDateTime = DateTime.Now;
            owinClientInfo.IPAddressBytes    = IPAddress.Parse(context.Request.RemoteIpAddress).GetAddressBytes();
            owinClientInfo.ClientId          = Guid.NewGuid().ToString();
            CurrentServerBase.Clients.TryAdd(owinClientInfo.ClientId, owinClientInfo);

            owinClientInfo.OwinContext     = context;
            owinClientInfo.RequestHeaders  = context.Request.Headers;
            owinClientInfo.ResponseHeaders = context.Response.Headers;
            if (isWebSocketd)
            {
                owinClientInfo.StreamHelper = SignalGoStreamBase.CurrentBase;
                Action <IDictionary <string, object>, Func <IDictionary <string, object>, Task> > accept = context.Get <Action <IDictionary <string, object>, Func <IDictionary <string, object>, Task> > >("websocket.Accept");
                if (accept == null)
                {
                    // Bad Request
                    context.Response.StatusCode = 400;
                    context.Response.Write("Not a valid websocket request");
                    return(Task.FromResult <object>(null));
                }
                WebsocketClient websocketClient = new WebsocketClient()
                {
                    ClientInfo = owinClientInfo, CurrentServerBase = CurrentServerBase
                };
                accept(null, websocketClient.RunWebSocket);
                return(Task.FromResult <object>(null));
            }
            else
            {
                owinClientInfo.StreamHelper = SignalGoStreamBase.CurrentBase;
                owinClientInfo.ClientStream = new PipeNetworkStream(new DuplexStream(context.Request.Body, context.Response.Body));
                return(HttpProvider.AddHttpClient(owinClientInfo, CurrentServerBase, context.Request.Uri.PathAndQuery, context.Request.Method, null, null));
            }
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the future cash flow of the payment.
        /// <para>
        /// The cash flow is returned, empty if the payment has already occurred.
        ///
        /// </para>
        /// </summary>
        /// <param name="payment">  the payment </param>
        /// <param name="provider">  the provider </param>
        /// <returns> the cash flow, empty if the payment has occurred </returns>
        public virtual CashFlows cashFlows(Payment payment, BaseProvider provider)
        {
            if (provider.ValuationDate.isAfter(payment.Date))
            {
                return(CashFlows.NONE);
            }
            double   df   = provider.discountFactor(payment.Currency, payment.Date);
            CashFlow flow = CashFlow.ofForecastValue(payment.Date, payment.Currency, payment.Amount, df);

            return(CashFlows.of(flow));
        }
        /// <summary>
        /// Computes the present value of the payment by discounting.
        /// <para>
        /// The present value is zero if the payment date is before the valuation date.
        ///
        /// </para>
        /// </summary>
        /// <param name="payment">  the payment </param>
        /// <param name="provider">  the provider </param>
        /// <returns> the present value </returns>
        public virtual double presentValueAmount(Payment payment, BaseProvider provider)
        {
            // duplicated code to avoid looking up in the provider when not necessary
            if (provider.ValuationDate.isAfter(payment.Date))
            {
                return(0d);
            }
            double df = provider.discountFactor(payment.Currency, payment.Date);

            return(payment.Amount * df);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Creates an instance of DeviceInfo.
 /// </summary>
 /// <param name="userAgent">User agent string used to identify this device.</param>
 /// <param name="deviceId">A unique Identifier of the device.</param>
 /// <param name="provider">A reference to the base provider.</param>
 /// <param name="fallbackDevice">The fallback device to use for this device if any.</param>
 internal DeviceInfo(
     BaseProvider provider,
     string deviceId,
     string userAgent,
     DeviceInfo fallbackDevice)
     : base(provider, deviceId, userAgent)
 {
     if (fallbackDevice == null)
         throw new ArgumentNullException("fallbackDevice");
     _parent = fallbackDevice;
 }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Computes the present value of the payment by discounting.
        /// <para>
        /// The present value is zero if the payment date is before the valuation date.
        ///
        /// </para>
        /// </summary>
        /// <param name="payment">  the payment </param>
        /// <param name="provider">  the provider </param>
        /// <returns> the present value </returns>
        public virtual CurrencyAmount presentValue(Payment payment, BaseProvider provider)
        {
            // duplicated code to avoid looking up in the provider when not necessary
            if (provider.ValuationDate.isAfter(payment.Date))
            {
                return(CurrencyAmount.zero(payment.Currency));
            }
            double df = provider.discountFactor(payment.Currency, payment.Date);

            return(payment.Value.multipliedBy(df));
        }
Ejemplo n.º 24
0
        public new void Load()
        {
            dataProvider = Program.DataProviderPlugins
                           .First(x => x.ProviderName == Program.Configuration.Connection.ProviderName)
                           .GetDataProvider(Program.Configuration.Connection);

            selectedTables = new List <TableSelection>();
            selectedTables.AddRange(dataProvider.TableNames.OrderBy(x => x).Select(x => new TableSelection {
                TableName = x, IsSelected = false
            }));
            dgvAvailableTables.DataSource = selectedTables;
        }
Ejemplo n.º 25
0
        public void SetTaskPaneVisible(string hash, bool isVisible)
        {
            var repository = repositoryFactory.Get();

            if (repository != default)
            {
                repository.SetVisible(
                    receiverHash: hash,
                    isVisible: isVisible);

                BaseProvider.InvalidateRibbonUI();
            }
        }
Ejemplo n.º 26
0
 /// <summary>
 /// Gets embed result for a url, null if none
 /// </summary>
 /// <param name="url"></param>
 /// <param name="maxwidth"></param>
 /// <param name="maxheight"></param>
 /// <returns></returns>
 public OEmbedResult ParseURL(string url, int maxwidth, int maxheight)
 {
     foreach (Type t in Providers)
     {
         BaseProvider provider = ((BaseProvider)Activator.CreateInstance(t));
         if (provider.Supported && provider.IsMatch(url))
         {
             provider.MaxWidth  = maxwidth;
             provider.MaxHeight = maxheight;
             return(provider.GetEmbedResult(url));
         }
     }
     return(null);
 }
Ejemplo n.º 27
0
        protected virtual OEmbedResult GetEmbedResult(int width, int height)
        {
            BaseProvider provider = GetEmbedProvider();

            if (provider != null)
            {
                return(provider.GetEmbedResult(URL));
            }
            else
            {
                OEmbedEngine eng = new OEmbedEngine();
                return(eng.ParseURL(URL, width, height));
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Passed an xml string and returns a list of handlers.
        /// </summary>
        public static IList<Handler> ProcessHandlers(string xml, BaseProvider provider)
        {
            // Use different code to handle the DTD in the Xml if present.
#if VER2
            xml = Regex.Replace(xml, "<!DOCTYPE.+>", "");
            using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
#endif
#if VER4
            using (XmlReader reader = XmlReader.Create(new StringReader(xml), GetXmlReaderSettings()))
#endif
            {
                return ProcessHandlers(reader, provider);
            }
        }
Ejemplo n.º 29
0
 public PhotoService(IConverterFactory factory, BaseProvider <Photo> provider,
                     BaseProvider <Watermark> providerWatermark, BaseProvider <Tag> providerTag,
                     BaseProvider <PhotoToTag> providerPhotoToTag, BaseProvider <Album> providerAlbum)
 {
     _providerPhoto      = provider;
     _providerWatermark  = providerWatermark;
     _providerPhotoToTag = providerPhotoToTag;
     _providerTag        = providerTag;
     _factory            = factory;
     _providerAlbum      = providerAlbum;
     _converter          = _factory.GetConverter <IPhotoConverter>();
     _converterWatermark = _factory.GetConverter <IWatermarkConverter>();
     _converterTag       = _factory.GetConverter <ITagConverter>();
 }
Ejemplo n.º 30
0
        /// <inheritdoc />
        /// <summary>
        /// Note: as a result of how this is called, this will only create scoped services for the scenario service provider.
        /// </summary>
        /// <param name="serviceType"></param>
        /// <returns></returns>
        public object GetService(Type serviceType)
        {
            if (!serviceType.IsConstructedGenericType ||
                serviceType.GetGenericTypeDefinition() != typeof(IEnumerable <>)) //To support GetServices.
            {
                return(serviceType == typeof(IServiceScopeFactory)
                    ? new DefaultScopedServicesFactory(ScenarioID, BaseProvider, ScenarioProvider)
                    : ScenarioProvider.GetService(serviceType) ?? BaseProvider.GetService(serviceType));
            }

            var temphold = ((IEnumerable <object>)ScenarioProvider.GetService(serviceType));
            var baseOut  = (IEnumerable <object>)BaseProvider.GetService(serviceType);

            return(baseOut == null ? temphold : temphold.Concat(baseOut));
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Passed an open XML reader and returns a list of handlers.
 /// </summary>
 /// <param name="reader"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public static IList<Handler> ProcessHandlers(XmlReader reader, BaseProvider provider)
 {
     var handlers = new List<Handler>();
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element &&
             reader.IsStartElement("handler"))
         {
             ProcessHandler(
                 handlers,
                 CreateHandler(reader, provider),
                 reader.ReadSubtree());
         }
     }
     return handlers;
 }
Ejemplo n.º 32
0
        /// <summary>
        /// Parses a block of HTML/text using supplied Providers (defaults to all)
        /// </summary>
        /// <param name="input"></param>
        /// <param name="maxwidth"></param>
        /// <param name="maxheight"></param>
        /// <returns></returns>
        public string Parse(string input, int maxwidth, int maxheight)
        {
            string output = input;

            foreach (Type t in Providers)
            {
                BaseProvider provider = ((BaseProvider)Activator.CreateInstance(t));
                if (provider.Supported)
                {
                    provider.MaxWidth  = maxwidth;
                    provider.MaxHeight = maxheight;
                    output             = provider.Process(output);
                }
            }
            return(output);
        }
Ejemplo n.º 33
0
        PostProvider([FromBody] BaseProvider baseProv)
        {
            var         prov = mapper.Map <Provider>(baseProv);
            ReasonCRUDL r    = await CRUDL.Create(EFCtx.Inv.Providers, prov);

            switch (r)
            {
            case ReasonCRUDL.DUPLICATE:
                return(BadRequest());

            case ReasonCRUDL.CREATE:
                var provCreated = mapper.Map <IdProvider>(prov);
                return(new CreatedAtRouteResult(
                           "getProvider",
                           new { id = provCreated.Id }, provCreated
                           ));

            default:
                return(StatusCode(500));
            }
        }
Ejemplo n.º 34
0
        public OpenIdConnect(OpenIdConfig openIdConfig, TokenCache tokenCache)
        {
            if (openIdConfig is MicrosoftOnlineConfig)
            {
                _currentProviderType = Providers.MicrosoftOnline;
            }

            switch (_currentProviderType)
            {
            case Providers.Custom:
                _currentProvider = new CustomProvider(openIdConfig, tokenCache);
                break;

            case Providers.MicrosoftOnline:
                _currentProvider = new MicrosoftOnline((MicrosoftOnlineConfig)openIdConfig, tokenCache);
                break;

            default:
                _currentProvider = new CustomProvider(openIdConfig, tokenCache);
                break;
            }
        }
Ejemplo n.º 35
0
        private void LinkPhoneAccount()
        {
            CreateAlert("Send Verification Code", "", new[] { "Country code", "Phone number" }, (resultArr) =>
            {
                var countryCode = resultArr[0];
                var phoneNumber = resultArr[1];
                BaseProvider.SendVerifyCodeWithCountryCode(countryCode, phoneNumber, AGCVerifyCodeAction.RegisterLogin);
                CreateAlert("Link Phone Account", "", new[] { "Country code", "Phone number", "Password", "verification code" }, (updateArr) =>
                {
                    countryCode  = resultArr[0];
                    phoneNumber  = resultArr[1];
                    var password = updateArr[2];
                    var code     = updateArr[3];
                    AGCAuthCredential credential;
                    if (string.IsNullOrEmpty(code))
                    {
                        // Generate a credential to link phone account with password
                        credential = AGCPhoneAuthProvider.CredentialWithCountryCode(countryCode, phoneNumber, password);
                    }
                    else
                    {
                        // Generate a credential to link phone account with verification code
                        credential = AGCPhoneAuthProvider.CredentialWithCountryCode(countryCode, phoneNumber, password, code);
                    }
                    // link phone account with credential
                    var linkReq = AGCAuth.GetInstance().CurrentUser?.Link(credential);

                    linkReq.AddOnSuccessCallback((result) =>
                    {
                        Console.WriteLine("link success");
                        owner.RefreshLinkState();
                    });
                    linkReq.AddOnFailureCallback((error) =>
                    {
                        Console.WriteLine("link failed");
                    });
                });
            });
        }
Ejemplo n.º 36
0
 private void UpdateEmail()
 {
     CreateAlert("Send Verification Code", "", new[] { "Email" }, (resultArr) =>
     {
         var email = resultArr[0];
         BaseProvider.SendVerifyCodeWithEmail(email, AGCVerifyCodeAction.RegisterLogin);
         CreateAlert("Update Email", "", new[] { "Email", "Verification Code" }, (updateArr) =>
         {
             var updatedEmail            = updateArr[0];
             var code                    = updateArr[1];
             HMFTask <NSObject> emailReq = AGCAuth.GetInstance().CurrentUser?.UpdateEmail(updatedEmail, code);
             emailReq.AddOnSuccessCallback((result) =>
             {
                 Console.WriteLine("email update success");
             });
             emailReq.AddOnFailureCallback((error) =>
             {
                 Console.WriteLine("email update failed");
             });
         });
     });
 }
Ejemplo n.º 37
0
 internal SegmentHandler(BaseProvider provider, string name, string defaultDeviceId, byte confidence, bool checkUAProfs)
     : base(provider, name, defaultDeviceId, confidence, checkUAProfs)
 {
 }
Ejemplo n.º 38
0
        /// <summary>
        /// Creates a new handler based on the attributes of the current element.
        /// </summary>
        /// <param name="reader">The XML stream reader.</param>
        /// <param name="provider">The provider the handler will be associated with.</param>
        /// <returns>A new handler object.</returns>
        private static Handler CreateHandler(XmlReader reader, BaseProvider provider)
        {
            bool checkUAProf;
            byte confidence;
            string name = reader.GetAttribute("name");
            string defaultDeviceId = reader.GetAttribute("defaultDevice");
            string type = reader.GetAttribute("type");
            bool.TryParse(reader.GetAttribute("checkUAProf"), out checkUAProf);
            byte.TryParse(reader.GetAttribute("confidence"), out confidence);

            switch (type)
            {
                case "editDistance":
                    return new Handlers.EditDistanceHandler(
                        provider, name, defaultDeviceId, confidence, checkUAProf);
                case "reducedInitialString":
                    return new Handlers.ReducedInitialStringHandler(
                        provider, name, defaultDeviceId, confidence,
                        checkUAProf, reader.GetAttribute("tolerance"));
                case "regexSegment":
                    return new Handlers.RegexSegmentHandler(
                        provider, name, defaultDeviceId, confidence, checkUAProf);
            }

            throw new XmlException(String.Format("Type '{0}' is invalid.", type));
        }
 /// <summary>
 /// Constucts an instance of <see cref="ReducedInitialStringHandler"/>.
 /// </summary>
 /// <param name="provider">Reference to the provider instance the handler will be associated with.</param>
 /// <param name="name">Name of the handler for debugging purposes.</param>
 /// <param name="defaultDeviceId">The default device ID to return if no match is possible.</param>
 /// <param name="confidence">The confidence this handler should be given compared to others.</param>
 /// <param name="checkUAProfs">True if UAProfs should be checked.</param>
 /// <param name="tolerance">Regex used to calculate how many characters should be matched at the beginning of the useragent.</param>
 internal ReducedInitialStringHandler(BaseProvider provider, string name, string defaultDeviceId, byte confidence, bool checkUAProfs, string tolerance)
     : base(provider, name, defaultDeviceId, confidence, checkUAProfs)
 {
     _tolerance = new Regex(tolerance, RegexOptions.Compiled);
 }
Ejemplo n.º 40
0
        /// <summary>
        /// Constructs an instance of <see cref="Handler"/>.
        /// </summary>
        /// <param name="provider">Reference to the provider instance the handler will be associated with.</param>
        /// <param name="name">Name of the handler for debugging purposes.</param>
        /// <param name="defaultDeviceId">The default device ID to return if no match is possible.</param>
        /// <param name="confidence">The confidence this handler should be given compared to others.</param>
        /// <param name="checkUAProfs">True if UAProfs should be checked.</param>
        internal Handler(BaseProvider provider, string name, string defaultDeviceId, byte confidence, bool checkUAProfs)
        {
            if (String.IsNullOrEmpty(name))
                throw new ArgumentNullException(name);

            _provider = provider;
            _name = name;
            _defaultDeviceId = defaultDeviceId;
            _confidence = confidence > 0 ? confidence : DEFAULT_CONFIDENCE;
            _checkUAProfs = checkUAProfs;
        }
Ejemplo n.º 41
0
 /// <summary>
 /// Creates an instance of <cref see="DeviceInfo"/>.
 /// </summary>
 /// <param name="deviceId">A unique Identifier of the device.</param>
 /// <param name="provider">A reference to the complete index of devices.</param>
 internal DeviceInfo(
     BaseProvider provider,
     string deviceId)
     : base(provider, deviceId)
 {
 }