コード例 #1
0
 public ScheduleTabPresenter(IScheduleTabView view, IBatchRepository repository)
 {
     ArgumentChecker.ThrowIfNull(view, "view");
     ArgumentChecker.ThrowIfNull(repository, "repository");
     this.view       = view;
     this.repository = repository;
 }
コード例 #2
0
ファイル: SetContext.cs プロジェクト: gahadzikwa/GAPP
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
            checker.CheckForNumberOfArguments(ref args, 1, 1);

            string arg = args[0].ToString();

            if (String.Equals(arg.Substring(0, 3), "Deg", StringComparison.OrdinalIgnoreCase))
            {
                ctx.TrigonometricMeasure = ExecutionContext.TrigonometricBase.Degree;
            }
            else if (String.Equals(arg.Substring(0, 3), "Rad", StringComparison.OrdinalIgnoreCase))
            {
                ctx.TrigonometricMeasure = ExecutionContext.TrigonometricBase.Radians;
            }
            else if (String.Equals(arg.Substring(0, 4), "Grad", StringComparison.OrdinalIgnoreCase))
            {
                ctx.TrigonometricMeasure = ExecutionContext.TrigonometricBase.Grad;
            }
            else
            {
                throw new ArgumentOutOfRangeException();
            };

            return "";
        }
コード例 #3
0
        public ISecurity GetSecurity(ExternalIdBundle bundle)
        {
            ArgumentChecker.NotEmpty(bundle.Identifiers, "bundle");

            Tuple <string, string>[] parameters = UriEncoding.GetParameters(bundle);
            return(_restTarget.Resolve("securitySearches").Resolve("single", parameters).Get <ISecurity>());
        }
コード例 #4
0
        public GetJoggingRoutesQueryHandler(IMapper mapper, JoggingTrackerDbContext dbContext)
        {
            ArgumentChecker.CheckNotNull(new { mapper, dbContext });

            this._mapper    = mapper;
            this._dbContext = dbContext;
        }
コード例 #5
0
        public UpdateJoggingRouteCommandValidator(IHttpContextAccessor httpContextAccessor)
        {
            ArgumentChecker.CheckNotNull(new { httpContextAccessor });

            var userIdentity = UserIdentity.FromPrincipal(httpContextAccessor.HttpContext.User);

            this.Custom(command =>
            {
                if (userIdentity.IsAdmin || userIdentity.Id == command.UserId)
                {
                    return(null);
                }

                throw new UnauthorizedAccessException();
            });

            this.RuleFor(r => r.DistanceKilometers)
            .NotNull()
            .GreaterThan(0);

            this.RuleFor(r => r.StartTime)
            .NotNull()
            .LessThan(r => r.EndTime)
            .WithMessage("'Start time' must be less than 'End time'");

            this.RuleFor(r => r.EndTime)
            .NotNull()
            .GreaterThan(r => r.StartTime)
            .WithMessage("'End time' must be greater than 'Start time'");
        }
コード例 #6
0
        public Decimal GetCurrentACLimit(long clientId, int userId, DateTime date)
        {
            ArgumentChecker.ThrowIfNull(clientId, "clientId");
            ArgumentChecker.ThrowIfNull(userId, "userId");

            DataEntry.Clients            mClient = new DataEntry.Clients();
            System.Collections.ArrayList arrPar  = new System.Collections.ArrayList();
            Int16 isNow = 0;

            if (DateTime.Compare(date, DateTime.Today) != 0)
            {
                isNow = -1;
            }
            int yrmth = Convert.ToInt32(date.Year.ToString() + date.Month.ToString().PadLeft(2, '0'));

            //int yrmth = Convert.ToInt32(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0'));
            arrPar.Add(0);
            arrPar.Add(clientId);
            arrPar.Add(yrmth);
            arrPar.Add(date);
            arrPar.Add(userId);
            arrPar.Add(isNow);
            System.Data.DataSet theDS = mClient.CACrLimitFromDrMgt(arrPar);
            if (theDS != null)
            {
                DataRow DR = theDS.Tables[0].Rows[0];
                return(Convert.ToDecimal(DR["limit"]));
            }
            else
            {
                return(0);
            }
        }
コード例 #7
0
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);

            if (ctx.Core.ActiveGeocache != null)
            {
                string codeToSearch = (args.Length == 0)
                    ? ctx.Core.ActiveGeocache.Code
                    : args[0].ToString();

                if (codeToSearch.Length == 0)
                {
                    codeToSearch = ctx.Core.ActiveGeocache.Code;
                }

                // Geocache Code
                if (codeToSearch == ctx.Core.ActiveGeocache.Code)
                {
                    return(GetPostion(ctx.Core.ActiveGeocache));
                }

                // Waypoints
                var wpt = Utils.DataAccess.GetWaypointsFromGeocache(ctx.Core.ActiveGeocache.Database, ctx.Core.ActiveGeocache.Code)
                          .FirstOrDefault(w => w.Code == args[0].ToString());
                if ((wpt != null) && (wpt.Lat != null) && (wpt.Lon != null))
                {
                    return(GetPosition(wpt));
                }

                // UserWaypoints
            }
            return("");
        }
コード例 #8
0
        public CffUserActivation ApproveUser(Guid mKey, Guid uKey)
        {
            ArgumentChecker.ThrowIfGuidEmpty(mKey, "mKey");
            ArgumentChecker.ThrowIfGuidEmpty(uKey, "uKey");
            CffUserActivation record = null;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "ApproveUserAccess", CreateAccessActionParameter(mKey, uKey)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        int nStatus = cleverReader.ToInteger("Status");
                        if (nStatus > 0)
                        { //valid - UKey must pickup from customer-id
                            record = new CffUserActivation(cleverReader.ToString("Name"), "", "", cleverReader.ToString("USERMAIL"), nStatus);
                        }
                        else
                        { //invalid
                            record = new CffUserActivation("", "", "", "", nStatus);
                        }
                    }
                }
            }
            return(record);
        }
コード例 #9
0
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);

            checker.CheckForNumberOfArguments(ref args, 1, null);
            return(new string(args[0].ToString().ToCharArray().Reverse().ToArray()));
        }
コード例 #10
0
        public void LoadTransactionHistoryForAllClients(DateRange dateRange, FacilityType facilityType, bool isSalvageIncluded)
        {
            ArgumentChecker.ThrowIfNull(dateRange, "dateRange");
            ArgumentChecker.ThrowIfNull(facilityType, "facilityType");

            view.ShowTransactionHistory(repository.LoadTransactionHistoryForAllClients(dateRange, facilityType, isSalvageIncluded));
        }
 public AccountTransactionTabPresenter(IAccountTransactionsView view, IReportRepository repository)
 {
     ArgumentChecker.ThrowIfNull(view, "view");
     ArgumentChecker.ThrowIfNull(repository, "repository");
     this.repository = repository;
     this.view       = view;
 }
コード例 #12
0
 public RepurchasesTabPresenter(IRepurchasesTabView view, IBatchRepository repository)
 {
     ArgumentChecker.ThrowIfNull(view, "view");
     ArgumentChecker.ThrowIfNull(repository, "repository");
     this.repository = repository;
     this.view       = view;
 }
コード例 #13
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="resolverTypeName"></param>
 public DependencyContainerFactory(string resolverTypeName)
 {
     ArgumentChecker.IsNotEmpty(resolverTypeName, "resolverTypeName");
     _resolverType = Type.GetType(resolverTypeName, true, true);
     //Assembly asm=  Assembly.Load(resolverTypeName.Split(',')[1]);
     //_resolverType = asm.GetType(resolverTypeName.Split(',')[0], true, true);
 }
コード例 #14
0
        public ContactsPresenter(IContactsView view, IContactsRepository contactsRepository)
        {
            ArgumentChecker.ThrowIfNull(contactsRepository, "contactsRepository");

            this.view = view;
            this.contactsRepository = contactsRepository;
        }
コード例 #15
0
 public RetentionRepurchasesClaimedTabPresenter(IRetentionRepurchasesClaimedTabView view, IRetentionRepository repository)
 {
     ArgumentChecker.ThrowIfNull(view, "view");
     ArgumentChecker.ThrowIfNull(repository, "repository");
     this.view       = view;
     this.repository = repository;
 }
コード例 #16
0
        public OverdueChargesReport LoadOverdueChargesReportForCustomer(Date endDate, int clientId, CffCustomer customer, TransactionStatus status, int ClientFacilityType)
        {
            ArgumentChecker.ThrowIfNull(endDate, "endDate");
            ArgumentChecker.ThrowIfNull(status, "status");

            return(repository.LoadOverdueChargesReportForCustomer(endDate, clientId, customer, status, ClientFacilityType));
        }
コード例 #17
0
ファイル: Waypoint.cs プロジェクト: gahadzikwa/GAPP
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
            if (ctx.Core.ActiveGeocache != null)
            {
                string codeToSearch = (args.Length == 0)
                    ? ctx.Core.ActiveGeocache.Code
                    : args[0].ToString();

                if (codeToSearch.Length == 0)
                {
                    codeToSearch = ctx.Core.ActiveGeocache.Code;
                }

                // Geocache Code
                if (codeToSearch == ctx.Core.ActiveGeocache.Code)
                {
                    return GetPostion(ctx.Core.ActiveGeocache);
                }

                // Waypoints
                var wpt = Utils.DataAccess.GetWaypointsFromGeocache(ctx.Core.ActiveGeocache.Database, ctx.Core.ActiveGeocache.Code)
                    .FirstOrDefault(w => w.Code == args[0].ToString());
                if ((wpt != null) && (wpt.Lat != null) && (wpt.Lon != null))
                {
                    return GetPosition(wpt);
                }

                // UserWaypoints
            }
            return "";
        }
コード例 #18
0
ファイル: Rom2Dec.cs プロジェクト: JensFF/GSAKWrapper
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);

            checker.CheckForNumberOfArguments(ref args, 1, null);
            return(Roman2Decimal(Convert.ToString(args[0])));
        }
コード例 #19
0
ファイル: AlphaPos.cs プロジェクト: gahadzikwa/GAPP
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 1, null);
     CharMapAlphabet map = new CharMapAlphabet();
     return map.GetCharacterCode(args[0].ToString()[0]);
 }
コード例 #20
0
ファイル: EventScheduler.cs プロジェクト: xforever1313/sethcs
        /// <summary>
        /// Schedules a recurring event to be run.
        /// </summary>
        /// <param name="interval">The interval to fire the event at.</param>
        /// <param name="action">The action to perform after the delay.</param>
        /// <param name="startRightAway">
        /// If set to false, the event will not start executing until <see cref="StartEvent(int)"/> is called.
        /// </param>
        /// <returns>The id of the event which can be used to start or stop it</returns>
        public int ScheduleRecurringEvent(TimeSpan interval, Action action, bool startRightAway = true)
        {
            CheckDisposed();

            ArgumentChecker.IsNotNull(interval, nameof(interval));
            ArgumentChecker.IsNotNull(action, nameof(action));

            int id = this.NextId;

            void Timer_Elapsed(object sender, ElapsedEventArgs e)
            {
                action();
            }

            var timer = new Timer(interval.TotalMilliseconds);

            timer.Elapsed  += Timer_Elapsed;
            timer.AutoReset = true;

            if (startRightAway)
            {
                timer.Start();
            }
            else
            {
                timer.Stop();
            }

            lock (this.events)
            {
                this.events.Add(id, timer);
            }

            return(id);
        }
コード例 #21
0
        public StatusReport LoadStatusReport(Date endDate, int clientId, TransactionStatus status, int ClientFacilityType)
        {
            ArgumentChecker.ThrowIfNull(endDate, "endDate");
            ArgumentChecker.ThrowIfNull(status, "status");

            return(repository.LoadStatusReport(endDate, clientId, status, ClientFacilityType));
        }
コード例 #22
0
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
            if (!string.IsNullOrEmpty(Settings.Settings.Default.ActiveGeocacheCode))
            {
                string codeToSearch = (args.Length == 0)
                    ? Settings.Settings.Default.ActiveGeocacheCode
                    : args[0].ToString();

                if (codeToSearch.Length == 0)
                {
                    codeToSearch = Settings.Settings.Default.ActiveGeocacheCode;
                }

                // Geocache Code
                if (codeToSearch == Settings.Settings.Default.ActiveGeocacheCode)
                {
                    return GetGeocachePostion(Settings.Settings.Default.ActiveGeocacheCode);
                }

                // Waypoints
                return GetWaypointPostion(codeToSearch);
            }
            return "";
        }
コード例 #23
0
        public GetJoggingRoutesQueryValidator(IHttpContextAccessor httpContextAccessor)
        {
            ArgumentChecker.CheckNotNull(new { httpContextAccessor });

            var userIdentity = UserIdentity.FromPrincipal(httpContextAccessor.HttpContext.User);

            this.Custom(query =>
            {
                if (userIdentity.IsAdmin || userIdentity.Id == query.UserId)
                {
                    return(null);
                }

                throw new UnauthorizedAccessException();
            });

            this.Custom(query =>
            {
                if (!query.FromDate.HasValue || !query.UntilDate.HasValue || (query.FromDate <= query.UntilDate))
                {
                    return(null);
                }

                return(new ValidationFailure(
                           propertyName: string.Empty,
                           error: "'From date' must be less than or equal to 'Until date'"));
            });
        }
コード例 #24
0
        public CffUserActivation ActivateUser(Guid uid, String pKey)
        {
            ArgumentChecker.ThrowIfNull(pKey, "pKey");
            ArgumentChecker.ThrowIfGuidEmpty(uid, "uid");
            CffUserActivation record = null;

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure, "ActivateNewUser", CreateActivationParameter(uid, pKey)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        int nStatus = cleverReader.ToInteger("Status");
                        if (nStatus == 1)
                        { //valid - UKey must pickup from customer-id
                            record = new CffUserActivation(cleverReader.ToString("Name"), cleverReader.ToString("MngtEmail"), cleverReader.ToGuid("UKey").ToString(), cleverReader.ToString("USERMAIL"), nStatus);
                        }
                        else
                        { //invalid
                            record = new CffUserActivation("", "", "", "", nStatus);
                        }
                    }
                }
            }
            return(record);
        }
コード例 #25
0
        private static string GetMessage(IEnumerable <IInternalSetupBase> notMatchedSetups)
        {
            ArgumentChecker.NotNull(notMatchedSetups, () => notMatchedSetups);

            StringBuilder message = new StringBuilder();

            foreach (IInternalSetupBase setup in notMatchedSetups)
            {
                if (!string.IsNullOrEmpty(message.ToString()))
                {
                    message.Append(",");
                }

                message.Append(Environment.NewLine);
                message.Append(setup.MethodCall.Method.ReflectedType);
                message.Append(".");
                message.Append(setup.MethodCall.Method.Name);
                message.Append("(");

                if (setup.MethodCall.Arguments.Count > 0)
                {
                    message.Append(string.Join(",", setup.MethodCall.Arguments));
                }

                message.Append(")");
            }

            return("Verification failed for method setups : " + message.ToString());
        }
コード例 #26
0
ファイル: JoinHandler.cs プロジェクト: noisynoise/Chaskis
        // -------- Constructor --------

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="response">The action to take when a user joins the channel</param>
        public JoinHandler( Action<IIrcWriter, IrcResponse> response )
        {
            ArgumentChecker.IsNotNull( response, nameof( response ) );

            this.JoinAction = response;
            this.KeepHandling = true;
        }
コード例 #27
0
ファイル: IntFunction.cs プロジェクト: gahadzikwa/GAPP
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 1, null);
     decimal d = Convert.ToDecimal(args[0]);
     return Math.Sign(d) * Math.Floor(Math.Abs(d));
 }
コード例 #28
0
        public AgedBalancesReport LoadAgedBalancesReportForAllClients(AgedBalancesReportType reportType, FacilityType facilityType, bool isSalvageIncluded, int ClientFacilityType)
        {
            ArgumentChecker.ThrowIfNull(reportType, "reportType");
            ArgumentChecker.ThrowIfNull(facilityType, "facilityType");

            return(repository.LoadAgedBalancesReportForAllClients(reportType, facilityType, isSalvageIncluded, ClientFacilityType));
        }
コード例 #29
0
        // --------------- Properties ---------------

        // --------------- Functions ---------------

        /// <summary>
        /// This will parse the handler args into a <see cref="PrivateMessageParseResult"/>.
        /// <see cref="PrivateMessageParseResult.Success"/> will return false if:
        /// - Unable to parse
        /// - The channel is in the blacklisted channel
        /// </summary>
        public PrivateMessageParseResult ParseAndCheckHandlerArgs(HandlerArgs args)
        {
            ArgumentChecker.IsNotNull(args, nameof(args));

            Match match = pattern.Match(args.Line);

            if (match.Success)
            {
                string channel = match.Groups["channel"].Value;
                if (args.BlackListedChannels.Contains(channel))
                {
                    return(new PrivateMessageParseResult());
                }

                // Otherwise, success!
                return(new PrivateMessageParseResult
                {
                    Success = true,
                    RemoteUser = match.Groups["nickOrServer"].Value,
                    Channel = channel,
                    Message = match.Groups["theIrcMessage"].Value
                });
            }
            else
            {
                return(new PrivateMessageParseResult());
            }
        }
コード例 #30
0
ファイル: JoinHandler.cs プロジェクト: noisynoise/Chaskis
        // -------- Functions --------

        /// <summary>
        /// Handles the event and sends the responses to the channel if desired.
        /// </summary>
        /// <param name="line">The RAW line from IRC to check.</param>
        /// <param name="ircConfig">The irc config to use when parsing this line.</param>
        /// <param name="ircWriter">The way to write to the irc channel.</param>
        public void HandleEvent( string line, IIrcConfig ircConfig, IIrcWriter ircWriter )
        {
            ArgumentChecker.StringIsNotNullOrEmpty( line, nameof( line ) );
            ArgumentChecker.IsNotNull( ircConfig, nameof( ircConfig ) );
            ArgumentChecker.IsNotNull( ircWriter, nameof( ircWriter ) );

            Match match = pattern.Match( line );
            if( match.Success )
            {
                string remoteUser = match.Groups["nick"].Value;

                // Don't fire if we were the ones to trigger the event.
                if( remoteUser.ToUpper() == ircConfig.Nick.ToUpper() )
                {
                    return;
                }

                IrcResponse response =
                    new IrcResponse(
                        remoteUser,
                        match.Groups["channel"].Value,
                        string.Empty
                    );

                this.JoinAction( ircWriter, response );
            }
        }
コード例 #31
0
        public GetSingleUserQueryValidator(JoggingTrackerDbContext dbContext, IHttpContextAccessor httpContextAccessor)
        {
            ArgumentChecker.CheckNotNull(new { dbContext, httpContextAccessor });

            var userIdentity = UserIdentity.FromPrincipal(httpContextAccessor.HttpContext.User);

            this.Custom(command =>
            {
                if (userIdentity.IsAdmin || userIdentity.IsUserManager || userIdentity.Id == command.Id)
                {
                    return(null);
                }

                throw new UnauthorizedAccessException();
            });

            this.CustomAsync(async query =>
            {
                if (await dbContext.Users.AnyAsync(u => u.Id == query.Id))
                {
                    return(null);
                }

                throw new ObjectNotFoundException($"{nameof(User)} not found.");
            });
        }
コード例 #32
0
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);

            checker.CheckForNumberOfArguments(ref args, 1, null);
            return(Evaluate(Convert.ToInt32(args[0])));
        }
コード例 #33
0
 public TaxonRepository(CactusGuruEntities context, TranslatorBase <Taxon, tblTaxon> translator)
 {
     ArgumentChecker.CheckNull(context);
     ArgumentChecker.CheckNull(translator);
     _context    = context;
     _translator = translator;
 }
コード例 #34
0
        public CreateJoggingRouteCommandHandler(IMapper mapper, JoggingTrackerDbContext dbContext)
        {
            ArgumentChecker.CheckNotNull(new { mapper, dbContext });

            this._mapper    = mapper;
            this._dbContext = dbContext;
        }
コード例 #35
0
        internal Parameter(TypeReference parameterType, int index)
        {
            ArgumentChecker.NotNull(parameterType, () => parameterType);

            ParameterType = parameterType;
            Index         = index;
        }
コード例 #36
0
ファイル: RoundFunction.cs プロジェクト: gahadzikwa/GAPP
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 1, null);
     decimal value = Convert.ToDecimal(args[0]);
     int decimals = (args.Length > 1) ? Convert.ToInt32(args[1]) : 0;
     return Math.Round(value, decimals);
 }
コード例 #37
0
ファイル: PrimeIndex.cs プロジェクト: gahadzikwa/GAPP
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     UInt64? value = null;
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 1, null);
     value = checker.GetRangedUInt64(ref args[0], 2, 10000000);
     return (value != null)? FindNumberOfPrime(Convert.ToUInt64(value)): 0;
 }
コード例 #38
0
ファイル: PrimeNumber.cs プロジェクト: gahadzikwa/GAPP
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
            UInt64? nth = null;

            checker.CheckForNumberOfArguments(ref args, 1, null);
            nth = checker.GetRangedUInt64(ref args[0], 0, 664579);

            return (nth != null)? FindNthPrimeNumber(10000000, Convert.ToUInt32(nth)).ToString(): "";
        }
コード例 #39
0
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 1, 1);
     Utils.Location ll = Utils.Conversion.StringToLocation(args[0].ToString());
     if (ll != null)
     {
         return ll.Lat.ToString("G", CultureInfo.InvariantCulture);
     }
     return "";
 }
コード例 #40
0
ファイル: PhoneCode.cs プロジェクト: gahadzikwa/GAPP
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 1, null);
     
     if (!checker.ArgumentZeroSize(ref args[0]))
     {
         CharMapPhoneCode map = new CharMapPhoneCode();
         return map.GetCharacterCode(args[0].ToString()[0]);
     }
     return 0;
 }
コード例 #41
0
ファイル: AlphaSum.cs プロジェクト: gahadzikwa/GAPP
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     int sum = 0;
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 1, null);
     CharMapAlphabet map = new CharMapAlphabet();
     String s = args[0].ToString();
     for (int i = 0; i < s.Length; ++i)
     {
         sum += map.GetCharacterCode(s[i]);
     }
     return sum;
 }
コード例 #42
0
ファイル: PowerFunction.cs プロジェクト: gahadzikwa/GAPP
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
            checker.CheckForNumberOfArguments(ref args, 2, 2);
            double b = Convert.ToDouble(args[0]);
            double ex = Convert.ToDouble(args[1]);

            if ((b == 0) && (ex == -1))
            {
                throw new ArgumentRangeException(StrRes.GetString(StrRes.STR_DIV_BY_ZERO));                    
            }

            return Math.Pow(b, ex);
        }
コード例 #43
0
ファイル: Distance.cs プロジェクト: gahadzikwa/GAPP
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     string res = "";
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 2, null);
     Core.Data.Location ll1 = Utils.Conversion.StringToLocation(args[0].ToString());
     Core.Data.Location ll2 = Utils.Conversion.StringToLocation(args[1].ToString());
     if ((ll1 != null) && (ll2 != null))
     {
         GeodeticMeasurement gm = Utils.Calculus.CalculateDistance(ll1.Lat, ll1.Lon, ll2.Lat, ll2.Lon);
         res = gm.PointToPointDistance.ToString("0");
     }
     return res;
 }
コード例 #44
0
ファイル: Crossbearing.cs プロジェクト: gahadzikwa/GAPP
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
            checker.CheckForNumberOfArguments(ref args, 4, null);
            Intersection intersection = new Intersection();
            Projection projection = new Projection();

            object[] projectionArgs1 = { args[0], "1000", args[1] };
            object p1 = projection.Execute(projectionArgs1, ctx);

            object[] projectionArgs2 = { args[2], "1000", args[3] };
            object p2 = projection.Execute(projectionArgs2, ctx);

            object[] intersectionArgs = { args[0], p1, args[2], p2 };
            return intersection.Execute(intersectionArgs, ctx).ToString();;
        }
コード例 #45
0
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            UInt64 res = 1;

            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
            checker.CheckForNumberOfArguments(ref args, 1, 1);
            UInt64? value = checker.GetRangedUInt64(ref args[0], 0, 50);
            if (value != null)
            {
                for (UInt64 i = 2; i < value; ++i)
                {
                    res *= i;
                }
            }
            return res;
        }
コード例 #46
0
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            ArgumentChecker checker = new ArgumentChecker(FunctionName());
            checker.CheckForNumberOfArguments(ref args, 1, 1);
            double arg = Convert.ToDouble(args[0].ToString(), CultureInfo.InvariantCulture);

            if (ctx.TrigonometricMeasure == ExecutionContext.TrigonometricBase.Degree)
            {
                arg = arg * Math.PI / 180;
            }
            else if (ctx.TrigonometricMeasure == ExecutionContext.TrigonometricBase.Grad)
            {
                arg = arg * Math.PI / 200;
            }

            return ExecuteTrigFunction(arg);
        }
コード例 #47
0
ファイル: Mid.cs プロジェクト: gahadzikwa/GAPP
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     string res = "";
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 2, null);
     string s = args[0].ToString();
     int start = int.Parse(args[1].ToString());
     if ((start > 0) && (start <= s.Length))
     {
         int len = 1;
         if (args.Length > 2)
         {
             len = Math.Min(int.Parse(args[2].ToString()), s.Length + 1 - start);
         }
         res = s.Substring(start - 1, len);
     }
     return res;
 }
コード例 #48
0
ファイル: Rot13.cs プロジェクト: GlobalcachingEU/GSAKWrapper
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 1, null);
     char[] array = args[0].ToString().ToCharArray();
     for (int i = 0; i < array.Length; ++i)
     {
         int number = (int)array[i];
         if (number >= 'a' && number <= 'z')
         {
             number += (number > 'm')? -13: 13;
         }
         else if (number >= 'A' && number <= 'Z')
         {
             number += (number > 'M') ? -13 : 13;
         }
         array[i] = (char)number;
     }
     return new string(array);
 }
コード例 #49
0
ファイル: Projection.cs プロジェクト: gahadzikwa/GAPP
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            string ret = "";
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
            checker.CheckForNumberOfArguments(ref args, 3, null);
            Framework.Data.Location ll = Utils.Conversion.StringToLocation(args[0].ToString());
            double distance = Utils.Conversion.StringToDouble(args[1].ToString());
            double angle = Utils.Conversion.StringToDouble(args[2].ToString());

            if (ll != null)
            {
                GeodeticCalculator gc = new GeodeticCalculator();
                GlobalCoordinates p = gc.CalculateEndingGlobalCoordinates(Ellipsoid.WGS84, 
                    new GlobalCoordinates(new Angle(ll.Lat), new Angle(ll.Lon)), 
                    new Angle(angle), distance);
                ret = Utils.Conversion.GetCoordinatesPresentation(p.Latitude.Degrees, p.Longitude.Degrees);
            }

            return ret;
        }
コード例 #50
0
ファイル: Rom2Dec.cs プロジェクト: gahadzikwa/GAPP
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 1, null);
     return Roman2Decimal(Convert.ToString(args[0]));
 }
コード例 #51
0
ファイル: CrossTotal.cs プロジェクト: gahadzikwa/GAPP
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 1, null);
     return Evaluate(Convert.ToUInt64(args[0]));
 }
コード例 #52
0
ファイル: Intersection.cs プロジェクト: gahadzikwa/GAPP
        public override object Execute(object[] args, ExecutionContext ctx)
        {
            string ret = StrRes.GetString(StrRes.STR_NO_CROSSING);
            ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
            checker.CheckForNumberOfArguments(ref args, 4, null);

            Core.Data.Location ll0 = Utils.Conversion.StringToLocation(args[0].ToString());
            Core.Data.Location ll1 = Utils.Conversion.StringToLocation(args[1].ToString());
            Core.Data.Location ll2 = Utils.Conversion.StringToLocation(args[2].ToString());
            Core.Data.Location ll3 = Utils.Conversion.StringToLocation(args[3].ToString());

            // x -> Lon , y -> Lat
            decimal y0 = (decimal)ll0.Lat;
            decimal y1 = (decimal)ll1.Lat;
            decimal y2 = (decimal)ll2.Lat;
            decimal y3 = (decimal)ll3.Lat;

            decimal x0 = (decimal)ll0.Lon;
            decimal x1 = (decimal)ll1.Lon;
            decimal x2 = (decimal)ll2.Lon;
            decimal x3 = (decimal)ll3.Lon;

            decimal? m0 = null; // Gerade 1 senkrecht -> alle x-Werte der Geraden sind gleich
            decimal? m1 = null; // Gerade 2 senkrecht -> alle x-Werte der Geraden sind gleich
            decimal? n0 = null; 
            decimal? n1 = null;

            if (x1 != x0)
            {
                m0 = (y1 - y0) / (x1 - x0);
            }

            if (x3 != x2)
            {
                m1 = (y3 - y2) / (x3 - x2);
            }

            if (m0 != m1) 
            {
                decimal? lon = null;
                decimal? lat = null;
                if (m0 == null)
                {
                    n1 = y2 - x2 * m1;
                    lon = x0;
                    lat = m1 * x0 + n1;
                }
                else if (m1 == null)
                {
                    n0 = y0 - x0 * m0;
                    lon = x2;
                    lat = m0 * x2 + n0;
                }
                else
                {
                    n0 = y0 - x0 * m0;
                    n1 = y2 - x2 * m1;

                    lon = (n1 - n0) / (m0 - m1); // x
                    lat = lon * m0 + n0; // y
                }
                ret = Utils.Conversion.GetCoordinatesPresentation((double)lat, (double)lon);
            }
            return ret;
        }
コード例 #53
0
ファイル: Reverse.cs プロジェクト: gahadzikwa/GAPP
 public override object Execute(object[] args, ExecutionContext ctx)
 {
     ArgumentChecker checker = new ArgumentChecker(this.GetType().Name);
     checker.CheckForNumberOfArguments(ref args, 1, null);
     return new string(args[0].ToString().ToCharArray().Reverse().ToArray());
 }