Ejemplo n.º 1
0
 public SupportedNode(IResultValue normalForce = null, IResultValue shearForce = null, IResultValue rotation = null)
 {
     NormalForce   = normalForce ?? new NormalForce();
     ShearForce    = shearForce ?? new ShearForce();
     LeftRotation  = rotation ?? new Rotation();
     RightRotation = LeftRotation;
 }
        public override IResultValue Evaluate()
        {
            IResultValue first  = First.Evaluate();
            IResultValue second = Second.Evaluate();

            return(new ResultString(First.Evaluate().ToString() + Second.Evaluate().ToString()));
        }
Ejemplo n.º 3
0
 public SupportedNodeWithHinge(IResultValue normalForce = null, IResultValue shearForce = null, IResultValue leftRotation = null, IResultValue rightRotation = null)
 {
     NormalForce   = normalForce ?? new NormalForce();
     ShearForce    = shearForce ?? new ShearForce();
     LeftRotation  = leftRotation ?? new Rotation();
     RightRotation = rightRotation ?? new Rotation();
 }
Ejemplo n.º 4
0
 public ConvertingSettings(IConvertingPackageSettings convertingPackageSettings,
                           IResultValue <IPrintersInformation> printersInformation)
     : this(convertingPackageSettings.PersonId, convertingPackageSettings.PdfNamingType,
            convertingPackageSettings.ConvertingModeTypes, convertingPackageSettings.UseDefaultSignature,
            printersInformation)
 {
 }
Ejemplo n.º 5
0
 public ConvertingSettings(string personId, PdfNamingType pdfNamingType,
                           IEnumerable <ConvertingModeType> convertingModeTypes, bool useDefaultSignature,
                           IResultValue <IPrintersInformation> printersInformation)
     : base(personId, pdfNamingType, convertingModeTypes, useDefaultSignature)
 {
     PrintersInformation = printersInformation;
 }
 /// <summary>
 /// Выполнить действие, вернуть результирующий ответ
 /// </summary>
 public static IResultValue <TValue> ResultValueVoidOkBad <TValue>(this IResultValue <TValue> @this,
                                                                   Action <TValue> actionOk,
                                                                   Action <IReadOnlyCollection <IErrorResult> > actionBad) =>
 @this.
 VoidWhere(_ => @this.OkStatus,
           actionOk: _ => actionOk.Invoke(@this.Value),
           actionBad: _ => actionBad.Invoke(@this.Errors));
Ejemplo n.º 7
0
 /// <summary>
 /// Преобразовать коллекцию ответов в ответ с коллекцией
 /// </summary>
 public static IResultCollection <T> ToResultCollection <T>(this IResultValue <IEnumerable <T> > @this, IErrorCommon errorNull = null) =>
 @this != null
         ? new ResultCollection <T>(@this.OkStatus
                                          ? @this.Value
                                          : @this.Value ?? Enumerable.Empty <T>(),
                                    @this.Errors, errorNull)
         : throw new ArgumentNullException(nameof(@this));
Ejemplo n.º 8
0
 public FreeNode(IResultValue horizontalDeflection = null, IResultValue verticalDeflection = null,
                 IResultValue rotation             = null)
 {
     HorizontalDeflection = horizontalDeflection ?? new HorizontalDeflection();
     VerticalDeflection   = verticalDeflection ?? new VerticalDeflection();
     LeftRotation         = rotation ?? new Rotation();
     RightRotation        = LeftRotation;
 }
 /// <summary>
 /// Логгирование авторизации
 /// </summary>
 private static void LogAuthorize(IResultValue <string> resultToken, IAuthorizeRestService service,
                                  IBoutiqueLogger boutiqueLogger) =>
 resultToken.
 ResultValueVoidOkBad(_ => boutiqueLogger.
                      Void(_ => boutiqueLogger.ShowMessage($"Токен сервиса [{service.GetType().Name}] получен")),
                      errors => errors.
                      Void(_ => boutiqueLogger.ShowMessage($"Ошибка авторизации в сервисе [{service.GetType().Name}]")).
                      Void(_ => boutiqueLogger.ShowErrors(errors)));
Ejemplo n.º 10
0
 public Hinge(IResultValue horizontalDeflection = null, IResultValue verticalDeflection = null,
              IResultValue leftRotation         = null, IResultValue rightRotation = null)
 {
     HorizontalDeflection = horizontalDeflection ?? new VerticalDeflection();
     VerticalDeflection   = verticalDeflection ?? new VerticalDeflection();
     LeftRotation         = leftRotation ?? new Rotation();
     RightRotation        = rightRotation ?? new Rotation();
 }
        /// <summary>
        /// Перезагрузить ресурсы
        /// </summary>
        public async Task ReloadResources()
        {
            _signatureNames = await GetSignatureNames();

            _signaturesMicrostation = await GetSignaturesMicrostation();

            _stampMicrostation = await GetStampsMicrostation();
        }
Ejemplo n.º 12
0
 public FixedNode(
     IResultValue normalForce   = null,
     IResultValue shearForce    = null,
     IResultValue bendingMoment = null)
 {
     NormalForce   = normalForce ?? new NormalForce();
     ShearForce    = shearForce ?? new ShearForce();
     BendingMoment = bendingMoment ?? new BendingMoment();
 }
 /// <summary>
 /// Получить параметры подключения к базе
 /// </summary>
 public static IResultValue <DatabaseConnection> GetDatabaseConnection(IResultValue <HostConnection> hostConnection,
                                                                       IResultValue <string> database,
                                                                       IResultValue <Authorization> authorization) =>
 new ResultValue <Func <HostConnection, string, Authorization, DatabaseConnection> >(
     (hostConnectionIn, databaseIn, authorizationIn) => new DatabaseConnection(hostConnectionIn, databaseIn, authorizationIn)).
 ResultValueCurryOk(hostConnection).
 ResultValueCurryOk(database).
 ResultValueCurryOk(authorization).
 ResultValueOk(getConfiguration => getConfiguration.Invoke());
Ejemplo n.º 14
0
 /// <summary>
 /// Добавить ответ со значением
 /// </summary>
 public IResultCollection <T> ConcatResultValue(IResultValue <T> resultValue) =>
 resultValue != null ?
 new ResultCollection <T>(resultValue.Value != null
                                 ? Value.Concat(new List <T> {
     resultValue.Value
 })
                                 : Value,
                          Errors.Union(resultValue.Errors)) :
 throw new ArgumentNullException(nameof(resultValue));
Ejemplo n.º 15
0
 public SleeveNode(
     IResultValue shearForce           = null,
     IResultValue bendingMoment        = null,
     IResultValue horizontalDeflection = null)
 {
     ShearForce           = shearForce ?? new ShearForce();
     BendingMoment        = bendingMoment ?? new BendingMoment();
     HorizontalDeflection = horizontalDeflection ?? new HorizontalDeflection();
 }
Ejemplo n.º 16
0
 public TelescopeNode(
     IResultValue normalForce        = null,
     IResultValue bendingMoment      = null,
     IResultValue verticalDeflection = null)
 {
     NormalForce        = normalForce ?? new NormalForce();
     BendingMoment      = bendingMoment ?? new BendingMoment();
     VerticalDeflection = verticalDeflection ?? new VerticalDeflection();
 }
Ejemplo n.º 17
0
 public PinNode(
     IResultValue shearForce           = null,
     IResultValue horizontalDeflection = null,
     IResultValue rotation             = null)
 {
     ShearForce           = shearForce ?? new ShearForce();
     HorizontalDeflection = horizontalDeflection ?? new HorizontalDeflection();
     LeftRotation         = rotation ?? new Rotation();
     RightRotation        = LeftRotation;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Выполнить действие, вернуть результирующий ответ
        /// </summary>
        public static IResultValue <TValue> ResultVoid <TValue>(this IResultValue <TValue> @this, Action <TValue> action)
        {
            if (@this == null)
            {
                throw new ArgumentNullException(nameof(@this));
            }

            action?.Invoke(@this.Value);
            return(@this);
        }
Ejemplo n.º 19
0
        protected BaseJsonResult(IResultValue value, HttpStatusCode statusCode) : base(null, new LowerCaseJsonSerializerSettings())
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            this.value = value;
            StatusCode = (int)statusCode;
        }
Ejemplo n.º 20
0
        public override IResultValue Evaluate()
        {
            IResultValue num1 = First.Evaluate();
            IResultValue num2 = Second.Evaluate();

            double d1 = (double)num1.ToDecimal();
            double d2 = (double)num2.ToDecimal();

            return(new ResultBoolean(!d1.AlmostEqualTo(d2)));
        }
Ejemplo n.º 21
0
        protected override IResultValue CalculateAtPosition(double distanceFromLeftSide)
        {
            Result = new Reactions.BendingMoment(distanceFromLeftSide)
            {
                Value = 0
            };
            _currentLength = 0;
            CalculateBendingMoment(distanceFromLeftSide);

            return(Result);
        }
Ejemplo n.º 22
0
 public FixedNode(
     Point position,
     IResultValue normalForce   = null,
     IResultValue shearForce    = null,
     IResultValue bendingMoment = null)
     : base(position)
 {
     NormalForce   = normalForce ?? new NormalForce();
     ShearForce    = shearForce ?? new ShearForce();
     BendingMoment = bendingMoment ?? new BendingMoment();
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Sets a variable to a value
 /// </summary>
 /// <param name="varname">Variable name</param>
 /// <param name="value">Value to set variable to</param>
 public static void Set(string varname, IResultValue value)
 {
     if (ContainsVariable(varname))
     {
         Instance[varname] = value;
     }
     else
     {
         Logger.Log(LogLevel.Error, "variable",
                    "Variable " + varname + " does not exist.");
     }
 }
Ejemplo n.º 24
0
        public override IResultValue Evaluate()
        {
            IResultValue res = Operand.Evaluate();

            if (!((double)res.ToDecimal()).IsInteger(8))
            {
                throw new EvaluationException(this,
                                              "Cannot use floating-point types in factorial calculation.");
            }

            return(new ResultNumberReal((decimal)MathPlus.Probability.Factorial(res.ToInteger())));
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Печать
 /// </summary>
 private IResultValue <IFileDataSourceServer> CreatePrintingService(IDocumentLibrary documentLibrary, IStamp stamp, IFilePath filePath,
                                                                    ConvertingModeType convertingModeType, ColorPrintType colorPrintType,
                                                                    IResultValue <IPrinterInformation> printerInformation) =>
 printerInformation.
 ResultVoidOk(printer => _messagingService.ShowMessage($"Установка принтера {printer.Name}")).
 ResultVoidOk(printer => SetDefaultPrinter(printer.Name)).
 ResultVoidOk(printer => _messagingService.ShowMessage($"Печать файла {filePath.FileNameClient}")).
 ResultValueOkBind(_ => PrintCommand(documentLibrary, stamp, filePath.FilePathServer, convertingModeType, colorPrintType,
                                     printerInformation.Value.PrefixSearchPaperSize)).
 ResultVoidOk(_ => _loggerService.LogByObject(LoggerLevel.Debug, LoggerAction.Operation, ReflectionInfo.GetMethodBase(this), filePath.FilePathServer)).
 ResultValueOk(_ => new FileDataSourceServer(filePath.FilePathServer, filePath.FilePathClient, convertingModeType,
                                             stamp.PaperSize, printerInformation.Value.Name));
Ejemplo n.º 26
0
 /// <summary>
 /// Creates a variable within the registry.
 /// </summary>
 /// <param name="varname">Name of variable to create.</param>
 /// <param name="initialValue">Value and type to initialize to</param>
 public static void Create(string varname, IResultValue initialValue)
 {
     if (!ContainsVariable(varname))
     {
         Instance.Registry.Add(varname, initialValue);
     }
     else
     {
         Logger.Log(LogLevel.Warning, "variable",
                    "Variable " + varname + " already exists.");
     }
 }
Ejemplo n.º 27
0
        protected override IResultValue CalculateAtPosition(double distanceFromLeftSide)
        {
            Result = new ShearForce(distanceFromLeftSide)
            {
                Value = 0
            };
            _currentLength = 0;

            CalculateShear(distanceFromLeftSide);

            return(Result);
        }
Ejemplo n.º 28
0
        public override IResultValue Evaluate()
        {
            IResultValue res1 = First.Evaluate();
            IResultValue res2 = Second.Evaluate();

            if (!((double)res1.ToDecimal()).IsInteger(8) || !((double)res2.ToDecimal()).IsInteger(8))
            {
                throw new EvaluationException(this,
                                              "Cannot use floating-point types in modulus calculation.");
            }

            return(new ResultNumberReal((decimal)(res1.ToInteger() % res2.ToInteger())));
        }
        public override IResultValue Evaluate()
        {
            IResultValue condition = Condition.Evaluate();

            if (condition.Type != MathType.Boolean)
            {
                throw new EvaluationException(this,
                                              "Condition part of conditional operator must be boolean.");
            }

            // See what I mean here?
            return(condition.ToBoolean() ? OnTrue.Evaluate() : OnFalse.Evaluate());
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Выполнить действие при отрицательном значении, вернуть результирующий ответ
        /// </summary>
        public static IResultValue <TValue> ResultVoidBad <TValue>(this IResultValue <TValue> @this,
                                                                   Action <IReadOnlyList <IErrorCommon> > action)
        {
            if (@this == null)
            {
                throw new ArgumentNullException(nameof(@this));
            }

            if (@this.HasErrors)
            {
                action?.Invoke(@this.Errors);
            }
            return(@this);
        }