Exemple #1
0
 public SqlWriter(Notation notation)
 {
     ProviderHelper = new DataProviderHelper();
     this.notation = notation;
     sb = new StringBuilder();
     newLineFlag = false;
 }
Exemple #2
0
        public Consolery(Type targetType, object target, string[] args, IMessenger messenger, Notation notationType)
        {
            Contract.Requires(targetType != null);
            Contract.Requires(args != null);
            Contract.Requires(messenger != null);

            _target = target;
            _targetType = targetType;
            _args = args;
            _messenger = messenger;

            _actionMethods = _targetType
                .GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance)
                .Where(method => method.GetCustomAttributes(false).OfType<ActionAttribute>().Any())
                .ToList();

            _metadata = new Metadata(_actionMethods);
            _metadataValidator = new MetadataValidator(_targetType, _actionMethods, _metadata);
            if (notationType == Notation.Windows)
            {
                _notation = new WindowsNotationStrategy(_args, _messenger, _metadata, _targetType, _actionMethods);
            }
            else
            {
                _notation = new LinuxNotationStrategy(_args, _messenger, _metadata);
            }
        }
 /// <summary>
 /// Default Application Constructor
 /// </summary>
 public MainWindow()
 {
     InitializeComponent();
     GridStack = new Stack<Grid>();
     TokenStack = new Stack<String>();
     Token_Counter = 0;
     OperatorPopCounter = 0;
     AnimationSpeed = 1;
     CurrentlyAnimating = false;
     notation = Notation.Postfix;
     StackSize = (int)StackCanvas.Height/RECTANGLE_HEIGHT;
 }
Exemple #4
0
 private void ProcessQueryExp(Notation notation, Symbol qexpr, QueryContext context)        
 {
     Notation.Record[] recs = notation.Select(qexpr,
         new Descriptor[] { Descriptor.Union, Descriptor.Except }, 2);
     if (recs.Length > 0)
     {
         ProcessQueryExp(notation, recs[0].Arg0, context);
         ProcessQueryTerm(notation, recs[0].Arg1, context);
     }
     else
         ProcessQueryTerm(notation, qexpr, context);
     ConfirmBindings(notation, qexpr, context);
 }
Exemple #5
0
 /// <summary>
 /// Runs an appropriate Action method
 /// </summary>
 /// <param name="targetType">Type where to search for Action methods</param>
 /// <param name="args">Arguments that will be converted to Action method arguments</param>
 /// <param name="messenger">Uses for writing messages instead of Console class methods</param>
 /// <param name="notationType">Switch for command line syntax. Windows: /param:value Linux: -param value</param>
 public static void Run(Type targetType, string[] args, IMessenger messenger, Notation notationType = Notation.Windows)
 {
     try
     {
         new Consolery(targetType, null, args, messenger, notationType).RunAction();
     }
     catch (NConsolerException e)
     {
         messenger.Write(e.Message);
         const int genericErrorExitCode = 1;
         Environment.ExitCode = genericErrorExitCode;
     }
 }
Exemple #6
0
 private void command_BeforeExecute(Command source, Notation notation, Optimizer optimizer, QueryContext context)
 {
     this.context = context;
     Notation.Record[] recs = notation.Select(Descriptor.Root, 1);
     if (recs.Length > 0)
     {
         Notation.Record[] recsd = notation.Select(recs[0].Arg0, Descriptor.Binding, 1);
         if (recsd.Length > 0)
             throw new ESQLException("Query parameters is not supported in XQueryConsole", null);
     }
     if (context.UseSampleData)
     {
         String path = Path.Combine(
             Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Data");
         if (Directory.Exists(path))
             context.DatabaseDictionary.SearchPath = path;                
     }
 }
Exemple #7
0
        public void StringToDecimal_InputTooBigValues_ThrowsOverflowException(string number, int scale)
        {
            Notation notation = new Notation(scale);

            NUnit.Framework.Assert.Throws <OverflowException>(() => StringToDecimal.ConvertingToDecimal(number, notation));
        }
Exemple #8
0
 public virtual void WriteTypeswitch(Notation.Record rec)
 {
     WriteText("typeswitch (");
     WriteExpr(rec.args[0]);
     WriteText(")");
     Symbol[] arr = Lisp.ToArray<Symbol>(rec.args[1]);
     for (int k = 0; k < arr.Length; k++)
     {
         Notation.Record[] recs = notation.Select(arr[k], new Descriptor[] { Descriptor.Case });
         if (recs.Length > 0)
         {
             WriteText(" case ");
             if (recs[0].args.Length > 2)
             {
                 WriteText('$');
                 WriteVarName((VarName)recs[0].Arg0);
                 WriteText(" as ");
                 WriteSequenceType(recs[0].Arg1);
                 WriteText(" return ");
                 WriteExprSingle(recs[0].Arg2);
             }
             else
             {
                 WriteSequenceType(recs[0].Arg0);
                 WriteText(" return ");
                 WriteExprSingle(recs[0].Arg1);
             }
         }
     }
     if (rec.args.Length > 3)
     {
         WriteText(" default $");
         WriteVarName((VarName)rec.Arg2);
         WriteText(" return ");
         WriteExprSingle(rec.Arg3);
     }
     else
     {
         WriteText(" default return ");
         WriteExprSingle(rec.Arg2);
     }
 }
Exemple #9
0
 public virtual void WriteLetOperator(Notation.Record rec)
 {
     WriteText("let ");
     Symbol[] arr = Lisp.ToArray<Symbol>(rec.args[0]);
     for (int k = 0; k < arr.Length; k++)
     {
         Notation.Record[] recs = notation.Select(arr[k], Descriptor.LetClauseOperator, 3);
         if (recs.Length > 0)
         {
             if (k > 0)
                 WriteText(", ");
             WriteText('$');
             WriteVarName((VarName)recs[0].Arg0);
             if (recs[0].Arg1 != null)
             {
                 WriteText(' ');
                 WriteTypeDecl(recs[0].Arg1);
             }
             WriteText(" := ");
             WriteExprSingle(recs[0].Arg2);
         }
     }
 }
Exemple #10
0
 public virtual void WriteOptionDecl(Notation.Record rec)
 {
     WriteText("declare option ");
     WriteQName((Qname)rec.Arg0);
     WriteText(' ');
     WriteLiteral((Literal)rec.Arg1);
 }
Exemple #11
0
 public void NotationHasDisplayValueTest([Values] Notation notation) => Assert.That(notation.GetDisplayValue(), Is.Not.Null.And.Not.Empty);
Exemple #12
0
        public virtual void WriteCopyNamespace(Notation.Record rec)
        {
            WriteText("declare copy-namespaces ");
            TokenWrapper wrapper = (TokenWrapper)rec.Arg0;
            switch (wrapper.Data)
            {
                case Token.PRESERVE:
                    WriteText("preserve");
                    break;

                case Token.NO_PRESERVE:
                    WriteText("no-preserve");
                    break;
            }
            WriteText(", ");
            wrapper = (TokenWrapper)rec.Arg1;
            switch (wrapper.Data)
            {
                case Token.INHERIT:
                    WriteText("inherit");
                    break;

                case Token.NO_INHERIT:
                    WriteText("no-inherit");
                    break;
            }
        }
Exemple #13
0
 public virtual void WriteImportModule(Notation.Record rec)
 {
     Literal[] arr;
     WriteText("import module ");
     if (rec.args.Length == 2)
     {
         WriteLiteral((Literal)rec.Arg0);
         arr = Lisp.ToArray<Literal>(rec.args[1]);
     }
     else
     {
         WriteText("namespace ");
         WriteQName((Qname)rec.Arg0);
         WriteText('=');
         WriteLiteral((Literal)rec.Arg1);
         arr = Lisp.ToArray<Literal>(rec.args[2]);
     }
     WriteText(" at ");
     for (int k = 0; k < arr.Length; k++)
     {
         if (k > 0)
             WriteText(", ");
         WriteLiteral(arr[k]);
     }
 }
Exemple #14
0
 public void NotationHasNatureTest([Values] Notation notation) => Assert.True(natures.Contains(notation.GetNature()));
Exemple #15
0
        public ActionResult Index(
            long[] matterIds,
            short characteristicLinkId,
            Notation notation,
            Feature[] features,
            string maxDifference,
            string excludeType)
        {
            return(CreateTask(() =>
            {
                if (matterIds.Length != 2)
                {
                    throw new ArgumentException("Count of selected matters must be 2.", nameof(matterIds));
                }

                long firstMatterId = matterIds[0];
                long firstParentSequenceId = db.CommonSequence.Single(c => c.MatterId == firstMatterId && c.Notation == notation).Id;
                Subsequence[] firstSequenceSubsequences = subsequenceExtractor.GetSubsequences(firstParentSequenceId, features);
                List <double> firstSequenceCharacteristics = CalculateCharacteristic(characteristicLinkId, firstSequenceSubsequences);
                Dictionary <long, AttributeValue[]> firstDbSubsequencesAttributes = sequenceAttributeRepository.GetAttributes(firstSequenceSubsequences.Select(s => s.Id));
                var firstSequenceAttributes = new List <AttributeValue[]>();
                foreach (Subsequence subsequence in firstSequenceSubsequences)
                {
                    firstDbSubsequencesAttributes.TryGetValue(subsequence.Id, out AttributeValue[] attributes);
                    attributes = attributes ?? new AttributeValue[0];
                    firstSequenceAttributes.Add(attributes);
                }

                long secondMatterId = matterIds[1];
                long secondParentSequenceId = db.CommonSequence.Single(c => c.MatterId == secondMatterId && c.Notation == notation).Id;
                Subsequence[] secondSequenceSubsequences = subsequenceExtractor.GetSubsequences(secondParentSequenceId, features);
                List <double> secondSequenceCharacteristics = CalculateCharacteristic(characteristicLinkId, secondSequenceSubsequences);
                Dictionary <long, AttributeValue[]> secondDbSubsequencesAttributes = sequenceAttributeRepository.GetAttributes(secondSequenceSubsequences.Select(s => s.Id));
                var secondSequenceAttributes = new List <AttributeValue[]>();
                foreach (Subsequence subsequence in secondSequenceSubsequences)
                {
                    secondDbSubsequencesAttributes.TryGetValue(subsequence.Id, out AttributeValue[] attributes);
                    attributes = attributes ?? new AttributeValue[0];
                    secondSequenceAttributes.Add(attributes);
                }

                double difference = double.Parse(maxDifference, CultureInfo.InvariantCulture);

                var similarSubsequences = new List <IntPair>();

                for (int i = 0; i < firstSequenceCharacteristics.Count; i++)
                {
                    for (int j = 0; j < secondSequenceCharacteristics.Count; j++)
                    {
                        if (Math.Abs(firstSequenceCharacteristics[i] - secondSequenceCharacteristics[j]) <= difference)
                        {
                            similarSubsequences.Add(new IntPair(i, j));

                            if (excludeType == "Exclude")
                            {
                                firstSequenceCharacteristics[i] = double.NaN;
                                secondSequenceCharacteristics[j] = double.NaN;
                            }
                        }
                    }
                }

                var characteristicName = characteristicTypeLinkRepository.GetCharacteristicName(characteristicLinkId, notation);

                var similarity = similarSubsequences.Count * 200d / (firstSequenceSubsequences.Length + secondSequenceSubsequences.Length);

                var firstSequenceSimilarity = similarSubsequences.Count * 100d / firstSequenceSubsequences.Length;

                var secondSequenceSimilarity = similarSubsequences.Count * 100d / secondSequenceSubsequences.Length;

                return new Dictionary <string, object>
                {
                    { "firstSequenceName", db.Matter.Single(m => m.Id == firstMatterId).Name },
                    { "secondSequenceName", db.Matter.Single(m => m.Id == secondMatterId).Name },
                    { "characteristicName", characteristicName },
                    { "similarSubsequences", similarSubsequences },
                    { "similarity", similarity },
                    { "firstSequenceSimilarity", firstSequenceSimilarity },
                    { "secondSequenceSimilarity", secondSequenceSimilarity },
                    { "firstSequenceSubsequences", firstSequenceSubsequences },
                    { "secondSequenceSubsequences", secondSequenceSubsequences },
                    { "firstSequenceAttributes", firstSequenceAttributes },
                    { "secondSequenceAttributes", secondSequenceAttributes }
                };
            }));
        }
        public ActionResult Index(
            long[] matterIds,
            OrderTransformation[] transformationsSequence,
            int iterationsCount,
            short[] characteristicLinkIds,
            Notation[] notations,
            Language?[] languages,
            Translator?[] translators,
            PauseTreatment?[] pauseTreatments,
            bool?[] sequentialTransfers,
            ImageOrderExtractor?[] trajectories)
        {
            return(CreateTask(() =>
            {
                Dictionary <long, string> mattersNames = Cache.GetInstance().Matters.Where(m => matterIds.Contains(m.Id)).ToDictionary(m => m.Id, m => m.Name);
                Chain[][] sequences = new Chain[matterIds.Length][];

                using (var db = new LibiadaWebEntities())
                {
                    var commonSequenceRepository = new CommonSequenceRepository(db);
                    long[][] sequenceIds = commonSequenceRepository.GetSequenceIds(matterIds,
                                                                                   notations,
                                                                                   languages,
                                                                                   translators,
                                                                                   pauseTreatments,
                                                                                   sequentialTransfers,
                                                                                   trajectories);
                    for (int i = 0; i < matterIds.Length; i++)
                    {
                        sequences[i] = new Chain[characteristicLinkIds.Length];
                        for (int j = 0; j < characteristicLinkIds.Length; j++)
                        {
                            sequences[i][j] = commonSequenceRepository.GetLibiadaChain(sequenceIds[i][j]);
                        }
                    }
                }

                var characteristicTypeLinkRepository = FullCharacteristicRepository.Instance;
                var sequencesCharacteristics = new SequenceCharacteristics[matterIds.Length];
                matterIds = matterIds.OrderBy(m => m).ToArray();

                for (int i = 0; i < matterIds.Length; i++)
                {
                    long matterId = matterIds[i];
                    var characteristics = new double[characteristicLinkIds.Length];
                    for (int j = 0; j < characteristicLinkIds.Length; j++)
                    {
                        Notation notation = notations[j];


                        Chain sequence = sequences[i][j];
                        for (int l = 0; l < iterationsCount; l++)
                        {
                            for (int k = 0; k < transformationsSequence.Length; k++)
                            {
                                sequence = transformationsSequence[k] == OrderTransformation.Dissimilar ? DissimilarChainFactory.Create(sequence)
                                                                     : HighOrderFactory.Create(sequence, EnumExtensions.GetLink(transformationsSequence[k]));
                            }
                        }

                        int characteristicLinkId = characteristicLinkIds[j];
                        Link link = characteristicTypeLinkRepository.GetLinkForCharacteristic(characteristicLinkId);
                        FullCharacteristic characteristic = characteristicTypeLinkRepository.GetCharacteristic(characteristicLinkId);

                        IFullCalculator calculator = FullCalculatorsFactory.CreateCalculator(characteristic);
                        characteristics[j] = calculator.Calculate(sequence, link);
                    }

                    sequencesCharacteristics[i] = new SequenceCharacteristics
                    {
                        MatterName = mattersNames[matterId],
                        Characteristics = characteristics
                    };
                }

                var characteristicNames = new string[characteristicLinkIds.Length];
                var characteristicsList = new SelectListItem[characteristicLinkIds.Length];
                for (int k = 0; k < characteristicLinkIds.Length; k++)
                {
                    characteristicNames[k] = characteristicTypeLinkRepository.GetCharacteristicName(characteristicLinkIds[k], notations[k]);
                    characteristicsList[k] = new SelectListItem
                    {
                        Value = k.ToString(),
                        Text = characteristicNames[k],
                        Selected = false
                    };
                }

                var transformations = transformationsSequence.Select(ts => ts.GetDisplayValue());

                var result = new Dictionary <string, object>
                {
                    { "characteristics", sequencesCharacteristics },
                    { "characteristicNames", characteristicNames },
                    { "characteristicsList", characteristicsList },
                    { "transformationsList", transformations },
                    { "iterationsCount", iterationsCount }
                };

                return new Dictionary <string, string> {
                    { "data", JsonConvert.SerializeObject(result) }
                };
            }));
        }
Exemple #17
0
        public JsonResult Recovery(Task task, TypeRecovery typeRecovery, IDictionary <string, string> nameAndValue, bool IsAPI = false)
        {
            #region Демо режим
            if (Platform.IsDemo)
            {
                return(Json(new Text("Операция недоступна в демо-режиме")));
            }
            #endregion

            DateTime DateRecovery = default(DateTime);

            #region Проверка данных
            if (string.IsNullOrWhiteSpace(task.Description))
            {
                return(Json(new Text("Имя задания не может быть пустым")));
            }

            if (string.IsNullOrWhiteSpace(task.Whence))
            {
                return(Json(new Text("Локальный каталог не может быть пустым")));
            }

            if (string.IsNullOrWhiteSpace(task.Where))
            {
                return(Json(new Text("Удаленный каталог не может быть пустым")));
            }

            switch (task.TypeSunc)
            {
            case TypeSunc.SFTP:
            case TypeSunc.FTP:
            {
                if (string.IsNullOrWhiteSpace(task.FTP.HostOrIP) || string.IsNullOrWhiteSpace(task.FTP.Login) || string.IsNullOrWhiteSpace(task.FTP.Passwd))
                {
                    return(Json(new Text("Настройки 'FTP/SFTP' имеют недопустимое значение")));
                }
                break;
            }

            case TypeSunc.WebDav:
            {
                if (string.IsNullOrWhiteSpace(task.WebDav.url) || string.IsNullOrWhiteSpace(task.WebDav.Login) || string.IsNullOrWhiteSpace(task.WebDav.Passwd))
                {
                    return(Json(new Text("Настройки 'WebDav' имеют недопустимое значение")));
                }
                break;
            }

            case TypeSunc.OneDrive:
            {
                if (string.IsNullOrWhiteSpace(task.OneDrive.ApplicationId) || string.IsNullOrWhiteSpace(task.OneDrive.RefreshToken))
                {
                    return(Json(new Text("Настройки 'OneDrive' имеют недопустимое значение")));
                }
                break;
            }
            }

            if (task.EncryptionAES && string.IsNullOrWhiteSpace(task.PasswdAES))
            {
                return(Json(new Text("Пароль для шифрования файлов не может быть пустым")));
            }

            if (typeRecovery == TypeRecovery.Date && nameAndValue.TryGetValue("TypeRecoveryToDate", out string DateRecoveryTostring) && !DateTime.TryParse(DateRecoveryTostring, out DateRecovery))
            {
                return(Json(new Text("Отметка бэкапа имеет неправильный формат")));
            }
            #endregion

            #region Добовляем задание в WorkNote
            CancellationToken cancellationToken = new CancellationToken();
            var WorkNoteNotation = new Notation()
            {
                TaskId   = task.Id,
                Category = "Восстановление",
                Msg      = $"Задание: {task.Description}",
                Time     = DateTime.Now,
                More     = new List <More>()
                {
                    new More("Состояние", "Выполняется поиск всех папок")
                }
            };
            CoreDB.SyncBackupWorkNote.Add(WorkNoteNotation, cancellationToken);
            #endregion

            // Выполняем задание в потоке
            ThreadPool.QueueUserWorkItem(ob =>
            {
                // Создание отчета по ошибкам
                Report report = new Report(task);

                // Выполняем задание
                Tools.Recovery(task, new RemoteServer(task.TypeSunc, task.FTP, task.WebDav, task.OneDrive, report, out _), WorkNoteNotation, out List <More> ResponseNameAndValue, typeRecovery, DateRecovery);

                // Сохраняем отчет об ошибках (если есть ошибки)
                report.SaveAndDispose(ref ResponseNameAndValue);

                // Чистим WorkNote
                CoreDB.SyncBackupWorkNote.Take(cancellationToken);

                #region Сохраняем данные задание в базе
                SqlToMode.SetMode(SqlMode.Read);
                using (CoreDB coreDB = Service.Get <CoreDB>())
                {
                    // Добовляем задание в список завершеных операций
                    coreDB.SyncBackup_Notations.Add(new Notation()
                    {
                        TaskId   = task.Id,
                        Category = "Восстановление",
                        Msg      = $"Задание: {task.Description}",
                        Time     = DateTime.Now,
                        More     = ResponseNameAndValue,
                    });

                    // Сохраняем базу
                    coreDB.SaveChanges();
                }
                SqlToMode.SetMode(SqlMode.ReadOrWrite);
                #endregion
            });

            // Отдаем ответ
            if (IsAPI)
            {
                return(Json(new TrueOrFalse(true)));
            }
            return(Json(new Text("Задание добавлено на обработку")));
        }
Exemple #18
0
 public void NotationHasDescriptionTest([Values] Notation notation) => Assert.That(notation.GetDescription(), Is.Not.Null.And.Not.Empty);
Exemple #19
0
        public void StringToDecimal_InpotNullOrEmptyValues_ThrowsNullException(string number, int scale)
        {
            Notation notation = new Notation(scale);

            NUnit.Framework.Assert.Throws <ArgumentNullException>(() => StringToDecimal.ConvertingToDecimal(number, notation));
        }
Exemple #20
0
        public virtual void WriteDefaultNamespaceDecl(Notation.Record rec)
        {
            switch (rec.descriptor)
            {
                case Descriptor.DefaultElement:
                    WriteText("declare default element namespace ");
                    break;

                case Descriptor.DefaultFunction:
                    WriteText("declare default function namespace ");
                    break;
            }
            WriteLiteral((Literal)rec.Arg0);
        }
Exemple #21
0
        private void WriteDefaultOrder(Notation.Record rec)
        {
            WriteText("declare default order ");
            TokenWrapper wrapper = (TokenWrapper)rec.Arg0;
            switch (wrapper.Data)
            {
                case Token.EMPTY_GREATEST:
                    WriteText("empty greatest");
                    break;

                case Token.EMPTY_LEAST:
                    WriteText("empty least");
                    break;
            }
        }
Exemple #22
0
 public virtual void WriteFuncDecl(Notation.Record rec)
 {
     WriteText("declare function ");
     WriteQName((Qname)rec.Arg0);
     WriteText('(');
     WriteParamList(rec.args[1]);
     WriteText(')');
     if (rec.args.Length > 3)
     {
         WriteText(" as ");
         WriteSequenceType(rec.Arg2);
         if (rec.args[3] == null)
             WriteText(" external");
         else
         {
             SmartNewLine();
             WriteText('{');
             SmartNewLine();
             WriteExpr(rec.args[3]);
             SmartNewLine();
             WriteText('}');
         }
     }
     else
     {
         if (rec.args[2] == null)
             WriteText(" external");
         else
         {
             SmartNewLine();
             WriteText('{');
             SmartNewLine();
             WriteExpr(rec.args[2]);
             SmartNewLine();
             WriteText('}');
         }
     }
 }
Exemple #23
0
 public virtual void WriteImportSchema(Notation.Record rec)
 {
     WriteText("import schema ");
     if (rec.Arg0 != null)
     {
         Notation.Record[] recs = notation.Select(rec.Arg0, Descriptor.Namespace, 1);
         if (recs.Length > 0)
         {
             WriteQName((Qname)recs[0].Arg0);
             WriteText("=");
         }
         else
         {
             recs = notation.Select(rec.Arg0, Descriptor.DefaultElement, 0);
             if (recs.Length > 0)
                 WriteText("default element namespace ");
             else
                 throw new InvalidOperationException();
         }
     }
     WriteLiteral((Literal)rec.Arg1);
     if (rec.args[2] != null)
     {
         WriteText(" at ");
         Literal[] arr = Lisp.ToArray<Literal>(rec.args[2]);
         for (int k = 0; k < arr.Length; k++)
         {
             if (k > 0)
                 WriteText(", ");
             WriteLiteral(arr[k]);
         }
     }
 }
Exemple #24
0
 public void NotationNamesTest(Notation notation, string name) => Assert.AreEqual(name, notation.GetName());
Exemple #25
0
 public virtual void WriteNamespaceDecl(Notation.Record rec)
 {
     WriteText("declare namespace ");
     WriteQName((Qname)rec.Arg0);
     WriteText('=');
     WriteLiteral((Literal)rec.Arg1);
 }
Exemple #26
0
 public virtual void WriteAttributeTest(Notation.Record rec)
 {
     WriteText("attribute(");
     if (rec.Arg0.Tag == Tag.TokenWrapper)
     {
         if (((TokenWrapper)rec.Arg0).Data == '*')
             WriteText('*');
     }
     else
         WriteQName((Qname)rec.Arg0);
     if (rec.args.Length > 1)
     {
         WriteText(", ");
         WriteTypeName(rec.Arg1);
     }
     WriteText(")");
 }
Exemple #27
0
 public virtual void WriteVarDecl(Notation.Record rec)
 {
     WriteText("declare variable $");
     WriteVarName((VarName)rec.Arg0);
     if (rec.Arg1 != null)
     {
         WriteText(' ');
         WriteTypeDecl(rec.Arg1);
     }
     WriteText(" := ");
     if (rec.args.Length > 2)
         WriteExprSingle(rec.Arg2);
     else
         WriteText("external");
 }
Exemple #28
0
 public virtual void WriteSchemaElementTest(Notation.Record rec)
 {
     WriteText("schema-element(");
     WriteQName((Qname)rec.Arg0);
     WriteText(")");
 }
Exemple #29
0
 public XQueryAbstractWriter(Notation notation)
 {
     this.notation = notation;
 }
Exemple #30
0
 public virtual void WriteSchemaAttributeTest(Notation.Record rec)
 {
     WriteText("schema-attribute(");
     WriteQName((Qname)rec.Arg0);
     WriteText(")");
 }
Exemple #31
0
        public virtual void WriteFLORExpr(Notation.Record rec)
        {
            Symbol[] arr = Lisp.ToArray<Symbol>(rec.args[0]);
            for (int k = 0; k < arr.Length; k++)
            {
                if (k > 0)
                    WriteText(' ');
                Notation.Record[] recs = notation.Select(arr[k]);
                switch (recs[0].descriptor)
                {
                    case Descriptor.For:
                        WriteForOperator(recs[0]);
                        break;

                    case Descriptor.Let:
                        WriteLetOperator(recs[0]);
                        break;

                    default:
                        throw new InvalidOperationException();
                }
            }
            if (rec.Arg1 != null)
                WriteWhereClause(rec.Arg1);
            if (rec.Arg2 != null)
                WriteOrderByClause(rec.Arg2);
            WriteText(" return ");
            WriteExprSingle(rec.Arg3);
        }
Exemple #32
0
 public virtual void WriteDefaultCollaction(Notation.Record rec)
 {
     WriteText("declare default collation ");
     WriteLiteral((Literal)rec.Arg0);
 }
Exemple #33
0
 public virtual void WriteQuantifiedExpr(Notation.Record rec)
 {
     switch (rec.descriptor)
     {
         case Descriptor.Some:
             WriteText("some ");
             break;
         case Descriptor.Every:
             WriteText("every ");
             break;
     }
     Symbol[] arr = Lisp.ToArray<Symbol>(rec.args[0]);
     for (int k = 0; k < arr.Length; k++)
     {
         Notation.Record[] recs = notation.Select(arr[k], Descriptor.QuantifiedExprOper, 3);
         if (recs.Length > 0)
         {
             if (k > 0)
                 WriteText(", ");
             WriteText('$');
             WriteVarName((VarName)recs[0].Arg0);
             if (recs[0].Arg1 != null)
             {
                 WriteText(' ');
                 WriteTypeDecl(recs[0].Arg1);
             }
             WriteText(" in ");
             WriteExprSingle(recs[0].Arg2);
         }
     }
     WriteText(" satisfies ");
     WriteExprSingle(rec.Arg1);
 }
Exemple #34
0
 public virtual void WriteBaseUri(Notation.Record rec)
 {
     WriteText("declare base-uri ");
     WriteLiteral((Literal)rec.Arg0);
 }
Exemple #35
0
 public virtual void WriteIfExpr(Notation.Record rec)
 {
     WriteText(" if (");
     WriteExpr(rec.args[0]);
     WriteText(") then ");
     WriteExprSingle(rec.Arg1);
     WriteText(" else ");
     WriteExprSingle(rec.Arg2);
 }
Exemple #36
0
        public virtual void WriteConstructionDecl(Notation.Record rec)
        {
            WriteText("declare construction ");
            TokenWrapper wrapper = (TokenWrapper)rec.Arg0;
            switch (wrapper.Data)
            {
                case Token.PRESERVE:
                    WriteText("preserve");
                    break;

                case Token.STRIP:
                    WriteText("strip");
                    break;
            }
        }
Exemple #37
0
 protected virtual void WriteXmlNamespaces(Notation.Record[] recs)
 {
     WriteText("XMLNAMESPACES (");
     Symbol[] arr = Lisp.ToArray<Symbol>(recs[0].args[0]);
     for (int k = 0; k < arr.Length; k++)
     {
         if (k > 0)
             WriteText(", ");
         if (arr[k] == null)
             WriteText("NO DEFAULT");
         else
         {
             Notation.Record[] recs1 = notation.Select(arr[k], Descriptor.DeclNamespace, 2);
             if (recs1.Length > 0)
                 if (recs1[0].Arg1 == null)
                 {
                     WriteText("DEFAULT ");
                     WriteUnsignedLit((Value)recs1[0].Arg0);
                 }
                 else
                 {
                     WriteUnsignedLit((Value)recs1[0].Arg0);
                     WriteText(" AS ");
                     WriteQualifiedName((Qname)recs1[0].Arg1);
                 }
             else
                 throw new InvalidOperationException();
         }
     }
     WriteText(")");
 }
Exemple #38
0
        public virtual void WriteOrdering(Notation.Record rec)
        {
            WriteText("declare ordering ");
            TokenWrapper wrapper = (TokenWrapper)rec.Arg0;
            switch (wrapper.Data)
            {
                case Token.ORDERED:
                    WriteText("ordered");
                    break;

                case Token.UNORDERED:
                    WriteText("unordered");
                    break;
            }
        }
Exemple #39
0
	    public YYParser(Notation notation)
	    {
	    	errorText = new StringWriter();	    	 
	    	this.notation = notation; 
	    } 
Exemple #40
0
        public int StringToDecimal_CorrectValues_PositiveTest(string number, int scale)
        {
            Notation notation = new Notation(scale);

            return(StringToDecimal.ConvertingToDecimal(number, notation));
        }