Beispiel #1
0
        static void Main(string[] args)
        {
            Hyland.Unity.SingleSignOnAuthenticationProperties props = Application.CreateSingleSignOnAuthenticationProperties("URL", "Datasource");
            Hyland.Unity.Application app = Application.Connect(props);
            if (app != null)
            {
                DocumentType docType = app.Core.DocumentTypes.Find("Test Doc Type");
                Document     doc     = app.Core.GetDocumentByID(12345);

                KeywordType kt = app.Core.KeywordTypes.Find("test");

                //DocumentType docType = app.Core.DocumentTypes.Find("test");


                using (PageData pd = app.Core.Retrieval.Default.GetDocument(doc.Revisions[0].DefaultRendition))
                {
                    using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
                    {
                        byte[] buff = new byte[1024];
                        int    read;
                        while ((read = pd.Stream.Read(buff, 0, buff.Length)) > 0)
                        {
                            ms.Write(buff, 0, read);
                        }
                        //fileLength = ms.Length;
                    }
                }
            }
        }
Beispiel #2
0
        public KeywordUpdate(OnBaseHelper aHelper, string aKeywordType, string aOldValue, string aNewValue, DocumentType aDocumentType = null)
        {
            KeywordType lType = aHelper.GetKeywordType(aKeywordType, aDocumentType);

            OldValue = OnBaseHelper.CreateKeyword(lType, aOldValue);
            NewValue = OnBaseHelper.CreateKeyword(lType, aNewValue);
        }
Beispiel #3
0
        private static void Send(string variable, ref StringBuilder result, KeywordType type, ScriptingAncestorComponent component)
        {
            if (variable != null)
            {
                switch (type)
                {
                case KeywordType.Description:
                    component.Description = result.ToString();
                    break;

                case KeywordType.Argument:
                    FindAndDescribe(component.Params.Input, variable, result.ToString());
                    break;

                case KeywordType.Return:
                    FindAndDescribe(component.Params.Output, variable, result.ToString());
                    break;

                case KeywordType.Help:
                    component.SpecialPythonHelpContent = result.ToString();
                    break;
                }
                result = new StringBuilder();
            }
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AppKit.TextKit.Formatter.KeywordDescriptor"/> class.
 /// </summary>
 /// <param name="type">Specifies the <c>KeywordType</c>.</param>
 /// <param name="color">Specifies the <c>NSColor</c> that this keyword will be set to.</param>
 /// <param name="toolTip">Defines the tool tip for this keyword.</param>
 public KeywordDescriptor(KeywordType type, NSColor color, string toolTip)
 {
     // Initialize
     this.Type    = type;
     this.Color   = color;
     this.Tooltip = toolTip;
 }
Beispiel #5
0
 private Keyword CreateKeywordHelper(KeywordType Keytype, string Value)
 {
     Keyword key = null;
     switch (Keytype.DataType)
     {
         case KeywordDataType.Currency:
         case KeywordDataType.Numeric20:
             decimal decVal = decimal.Parse(Value);
             key = Keytype.CreateKeyword(decVal);
             break;
         case KeywordDataType.Date:
         case KeywordDataType.DateTime:
             DateTime dateVal = DateTime.Parse(Value);
             key = Keytype.CreateKeyword(dateVal);
             break;
         case KeywordDataType.FloatingPoint:
             double dblVal = double.Parse(Value);
             key = Keytype.CreateKeyword(dblVal);
             break;
         case KeywordDataType.Numeric9:
             long lngVal = long.Parse(Value);
             key = Keytype.CreateKeyword(lngVal);
             break;
         default:
             key = Keytype.CreateKeyword(Value);
             break;
     }
     return key;
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="AppKit.TextKit.Formatter.KeywordDescriptor"/> class.
		/// </summary>
		/// <param name="type">Specifies the <c>KeywordType</c>.</param>
		/// <param name="color">Specifies the <c>NSColor</c> that this keyword will be set to.</param>
		/// <param name="toolTip">Defines the tool tip for this keyword.</param>
		public KeywordDescriptor (KeywordType type, NSColor color, string toolTip)
		{
			// Initialize
			this.Type = type;
			this.Color = color;
			this.Tooltip = toolTip;
		}
Beispiel #7
0
        public static void AddKeyword(KeywordType keywordType, string value)
        {
            _logger.Debug("Adding keyword");

            var keywords = GetKeywords();

            switch (keywordType)
            {
            case KeywordType.Folder:
                if (keywords.Directories.Contains(value))
                {
                    throw new IdenticalNameException($"Keyword with name '{value}' already exists");
                }
                keywords.Directories.Add(value);
                break;

            case KeywordType.File:
                if (keywords.Files.Contains(value))
                {
                    throw new IdenticalNameException($"Keyword with name '{value}' already exists");
                }
                keywords.Files.Add(value);
                break;
            }

            SaveToFile(keywords);
        }
Beispiel #8
0
        public List <Keyword> CreateKeywordCollection(
            IEnumerable <string> aKeywordTypeCollection, IEnumerable <string> aKeywordValueCollection,
            DocumentType aDocumentType = null
            )
        {
            if (aKeywordTypeCollection == null && aKeywordValueCollection == null)
            {
                return(new List <Keyword>());
            }
            else if (aKeywordTypeCollection.Count() != aKeywordValueCollection.Count())
            {
                throw new Exception("Keyword type and value collections have different number of elements");
            }
            List <Keyword> result = new List <Keyword>();

            foreach (KeyValuePair <string, string> item in aKeywordTypeCollection.Zip(aKeywordValueCollection, (x, y) => new KeyValuePair <string, string>(x, y)))
            {
                try
                {
                    KeywordType lType    = GetKeywordType(item.Key, aDocumentType);
                    Keyword     lKeyword = CreateKeyword(lType, item.Value);
                    result.Add(lKeyword);
                }
                catch (ArgumentOutOfRangeException)
                {
                    //skip undefined keywords
                    continue;
                }
            }
            return(result);
        }
Beispiel #9
0
        public static void CreateGrammar()
        {
            var unused = Rules.Select(r => r.Name).ToHashSet();

            // grammophone output
            //foreach (var rule in Rules)
            //    Console.WriteLine(
            //        $"{rule.Name} -> {string.Join(" ", rule.Production.Items.Select(i => i is Production.Epsilon ? "" : i is StatementType ? i : i.ToString().ToLower()).ToArray())}.");

            var ruleDictionary = new Dictionary <string, List <string> >();

            foreach (var rule in Rules)
            {
                var ruleName = rule.Name.ToString();
                if (!ruleDictionary.ContainsKey(ruleName))
                {
                    ruleDictionary[ruleName] = new List <string>();
                }
                ruleDictionary[ruleName].Add(string.Join(
                                                 "\\ ",
                                                 rule.Production.Items.Select(
                                                     i => i switch
                {
                    Production.Epsilon => "\\varepsilon",
                    StatementType _ => $"<{i}>",
                    TokenType _ => $"<{i}>",
                    KeywordType _ => $"\\texttt{{{i}}}",
                    _ => i.ToString().ToLower()
                }).ToArray())
Beispiel #10
0
 public KeywordDescription(string key, string description, KeywordType type, KeywordPriority priority, params string[] alternativeKeys)
 {
     Key             = key;
     Description     = description;
     Type            = type;
     Priority        = priority;
     AlternativeKeys = alternativeKeys;
 }
Beispiel #11
0
 public Command(GestureType gesture, KeywordType keyword, InteractableType focused, InteractableType selected)
     : this(gesture,
            keyword,
            focused,
            selected,
            StaticItem.Invariant)
 {
 }
Beispiel #12
0
 public Symbol(string keyword, int defaultParam, bool useDefaultParam, KeywordType keywordType, int index)
 {
     Keyword         = keyword;
     DefaultParam    = defaultParam;
     UseDefaultParam = useDefaultParam;
     KeywordType     = keywordType;
     Index           = index;
 }
Beispiel #13
0
 /// <summary>
 /// Preferred constructor.
 /// </summary>
 /// <param name="type">The keyword type</param>
 /// <param name="keyword">The keyword as a string</param>
 /// <param name="sourceFile">The source file being parsed</param>
 /// <param name="line">The line in the file currently being parsed</param>
 /// <param name="positionInLine">The position in the line where the keyword is located at.</param>
 public KeywordToken(KeywordType type, string keyword, FileInfo sourceFile, int line, int positionInLine)
 {
     _tokenType     = type;
     _keywordString = keyword;
     _file          = sourceFile;
     _line          = line;
     _posInLine     = positionInLine;
 }
Beispiel #14
0
        public string[] GetKeywords(KeywordType type)
        {
            if (!Keywords.TryGetValue(type, out var keywords))
            {
                return(Array.Empty <string>());
            }

            return(keywords.ToArray());
        }
Beispiel #15
0
 public KeywordItem(KeywordType type, string term)
     : this()
 {
     _type = type;
     if (!String.IsNullOrEmpty(term))
     {
         _listTerms.Add(term);
     }
 }
Beispiel #16
0
        public ObjectType GetObjectType(KeywordType type)
        {
            switch (type)
            {
            case KeywordType.Float: return(ObjectType.Floating);

            default: throw new InvalidOperationException($"unknow object type={type}");
            }
        }
        public SpeechInteractionEventArgs(SpeechInputEventArgs eventArgs)
        {
            Data  = eventArgs.Data;
            Input = eventArgs.Input;

            string keywordString = eventArgs.Keyword.ToString();

            Keyword = (KeywordType)Enum.Parse(typeof(KeywordType), keywordString, true);
        }
Beispiel #18
0
        public static Keyword CreateKeyword(KeywordType aKeywordType, string aValue)
        {
            Keyword key = null;

            if (string.IsNullOrWhiteSpace(aValue))
            {
                key = aKeywordType.CreateBlankKeyword();
            }
            else
            {
                switch (aKeywordType.DataType)
                {
                case KeywordDataType.Currency:
                case KeywordDataType.Numeric20:
                    decimal decVal = decimal.Parse(aValue);
                    key = aKeywordType.CreateKeyword(decVal);
                    break;

                case KeywordDataType.Date:
                case KeywordDataType.DateTime:
                    DateTime dateVal = DateTime.Parse(aValue);
                    key = aKeywordType.CreateKeyword(dateVal);
                    break;

                case KeywordDataType.FloatingPoint:
                    double dblVal = double.Parse(aValue);
                    key = aKeywordType.CreateKeyword(dblVal);
                    break;

                case KeywordDataType.Numeric9:
                    long lngVal = long.Parse(aValue);
                    key = aKeywordType.CreateKeyword(lngVal);
                    break;

                default:
                    key = aKeywordType.CreateKeyword(aValue);
                    break;
                }
            }
            //validate keyword dataset
            if (aKeywordType.KeywordMustExistInDataSet)
            {
                if (key.IsBlank || aKeywordType.GetKeywordDataSet().Find(x => x.Value.Equals(key.Value)) == null)
                {
                    if (key.IsBlank)
                    {
                        aValue = "<null>";
                    }

                    const string lErrorFormat = "{0} is not a valid value for keyword {1} ({2})";
                    throw new ArgumentOutOfRangeException("aValue", aValue, string.Format(lErrorFormat, aValue, aKeywordType.Name, aKeywordType.ID));
                }
            }
            return(key);
        }
Beispiel #19
0
        private void UploadDocument()
        {
            var putDocumentParams = new PutDocumentParams(long.Parse(txtDocumentTypeId.Text));

            var compassNumberKWT = new KeywordType(136, "", typeof(string), "");
            var ssnKWT           = new KeywordType(103, "", typeof(string), "");
            var firstNameKWT     = new KeywordType(104, "", typeof(string), "");
            var lastNameKWT      = new KeywordType(105, "", typeof(string), "");

            putDocumentParams.Keywords.Add(new Keyword(compassNumberKWT, txtCompassNumber.Text));
            putDocumentParams.Keywords.Add(new Keyword(ssnKWT, txtSSN.Text));
            putDocumentParams.Keywords.Add(new Keyword(firstNameKWT, txtFirstName.Text));
            putDocumentParams.Keywords.Add(new Keyword(lastNameKWT, txtLastName.Text));

            var multipartContent = new MultipartFormDataContent();

            var searlizedPutDocumentMetadata = JsonConvert.SerializeObject(putDocumentParams, new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            multipartContent.Add(new StringContent(searlizedPutDocumentMetadata, Encoding.UTF8, "application/json"), "PutDocumentParams");

            var sw = new Stopwatch();

            sw.Start();

            var counter = 1;

            foreach (var fileName in Directory.GetFiles(txtImagesFolderPath.Text))
            {
                var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                multipartContent.Add(new StreamContent(fs), "File" + counter, Path.GetFileName(fileName));
                counter++;
            }

            try
            {
                using (var response = new HttpClient().PostAsync("http://localhost/CompassDataBroker/api/Document/UploadFile", multipartContent).Result)
                {
                    var responseContent = response.Content.ReadAsStringAsync().Result;

                    sw.Stop();

                    MessageBox.Show(String.Format("Document Id: {0} \nCompleted in {1} seconds", responseContent, sw.Elapsed.TotalSeconds));

                    Trace.Write(responseContent);
                }
            }
            catch (Exception ex)
            {
                sw.Stop();
                throw;
            }
        }
Beispiel #20
0
            // Resets entry.
            private void Reset()
            {
                IsComplete = IsMalformed = false;

                Index   = -1;
                Str     = "";
                Keyword = KeywordType.None;

                Context = Id = IdPlural = null;
                Strings = null;
            }
Beispiel #21
0
 public static bool IsKeyword(KeywordType type, string keyword)
 {
     foreach (var cur in keywordsDictionary[type])
     {
         if (cur == keyword)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #22
0
 private void UpdateDepth(KeywordType keywordType)
 {
     if (keywordType == KeywordType.OpeningTag)
     {
         depth++;
     }
     else if (keywordType == KeywordType.ClosingTag)
     {
         depth--;
     }
 }
Beispiel #23
0
 public Command(GestureType gesture,
                KeywordType keyword,
                InteractableType focused,
                InteractableType selected,
                StaticItem item)
 {
     Gesture  = gesture;
     Keyword  = keyword;
     Focused  = focused;
     Selected = selected;
     Item     = item;
 }
Beispiel #24
0
 public static bool IsDefined(this DocumentType aDocumentType, KeywordType aKeywordType)
 {
     if (aKeywordType == null)
     {
         return(false);
     }
     if (aDocumentType == null)
     {
         throw new ArgumentNullException("Cannot validate keyword definition against a null document type");
     }
     return(KeywordType.Equals(aKeywordType, aDocumentType.KeywordRecordTypes.FindKeywordType(aKeywordType.ID)));
 }
Beispiel #25
0
 public static bool IsRequired(this DocumentType aDocumentType, KeywordType aKeywordType)
 {
     if (aKeywordType == null)
     {
         return(false);
     }
     if (aDocumentType == null)
     {
         throw new ArgumentNullException("Cannot validate keyword requirements against a null document type");
     }
     return(aDocumentType.KeywordTypesRequiredForArchival.Contains(aKeywordType));
 }
Beispiel #26
0
 /// <summary>
 /// Возвращает индекс первого токена с данным типом.
 /// </summary>
 public int IndexOf(KeywordType type)
 {
     for (int i = 0; i < Count; i++)
     {
         Token token = this[i];
         if (Keywords.GetKeywordType(token) == type)
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #27
0
        private TokenKeyword Consume(KeywordType keywordType)
        {
            TokenKeyword keyword = this.GetKeyword();

            if (keyword.KeywordType == keywordType)
            {
                return(keyword);
            }
            else
            {
                throw new ParseFailureException(string.Format("Expected keyword {0} but got {1}.", keywordType.ToString(), keyword.KeywordType), keyword.Location);
            }
        }
Beispiel #28
0
        private bool PeekKeyword(KeywordType keywordType)
        {
            TokenKeyword tokenKeyword = this.PeekAs <TokenKeyword>();

            if (tokenKeyword == null)
            {
                return(false);
            }
            else
            {
                return(tokenKeyword.KeywordType == keywordType);
            }
        }
Beispiel #29
0
        public static int LookUpImgIndexForKeyword(KeywordSource source, KeywordType type)
        {
            string str = Enum.GetName(typeof(KeywordSource), source) + Enum.GetName(typeof(KeywordType), type);

            if (keywordIndex.ContainsKey(str))
            {
                return(keywordIndex[str]);
            }
            else
            {
                return(-1);
            }
        }
Beispiel #30
0
        public static ConcreteSlotValueType ToConcreteSlotValueType(this KeywordType keywordType)
        {
            switch (keywordType)
            {
            case KeywordType.Boolean:
                return(ConcreteSlotValueType.Boolean);

            case KeywordType.Enum:
                return(ConcreteSlotValueType.Vector1);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public ShaderKeyword(KeywordType keywordType)
        {
            this.displayName = keywordType.ToString();
            this.keywordType = keywordType;

            // Add sensible default entries for Enum type
            if (keywordType == KeywordType.Enum)
            {
                m_Entries = new List <KeywordEntry>();
                m_Entries.Add(new KeywordEntry(1, "A", "A"));
                m_Entries.Add(new KeywordEntry(2, "B", "B"));
                m_Entries.Add(new KeywordEntry(3, "C", "C"));
            }
        }
Beispiel #32
0
        //KonohaSpace_syntax
        internal Syntax GetSyntax(KeywordType keyword, bool isnew)
        {
            Syntax syntaxParent = null;
            for (KonohaSpace ks = this; ks != null; ks = ks.parent)
            {
                if (ks.syntaxMap != null && ks.syntaxMap.ContainsKey(keyword))
                {
                    syntaxParent = ks.syntaxMap[keyword];
                    break;
                }
            }
            if (isnew == true)
            {
                Console.WriteLine("creating new syntax {0} old={1}", keyword.ToString(), syntaxParent);
                if (this.syntaxMap == null)
                {
                    this.syntaxMap = new Dictionary<KeywordType, Syntax>();
                }

                this.syntaxMap[keyword] = new Syntax();

                if (syntaxParent != null)
                {  // TODO: RCGC
                    this.syntaxMap[keyword] = syntaxParent;
                }
                else
                {
                    var syn = new Syntax()
                    {
                        KeyWord = keyword,
                        Type = KonohaType.Unknown,
                        Op1 = null,
                        Op2 = null,
                        ParseExpr = KModSugar.UndefinedParseExpr,
                        TopStmtTyCheck = ctx.kmodsugar.UndefinedStmtTyCheck,
                        StmtTyCheck = ctx.kmodsugar.UndefinedStmtTyCheck,
                        ExprTyCheck = ctx.kmodsugar.UndefinedExprTyCheck,
                    };
                    this.syntaxMap[keyword] = syn;
                }
                this.syntaxMap[keyword].Parent = syntaxParent;
                return this.syntaxMap[keyword];
            }
            return syntaxParent;
        }
 public CodeKeyword(string text, KeywordSource source, KeywordType type)
 {
     this.text = text.Trim();
     this.source = source;
     this.type = type;
 }
Beispiel #34
0
 private static void Send(string variable, ref StringBuilder result, KeywordType type, ScriptingAncestorComponent component)
 {
     if (variable != null)
       {
     switch (type)
     {
       case KeywordType.Description:
     component.Description = result.ToString();
     break;
       case KeywordType.Argument:
     FindAndDescribe(component.Params.Input, variable, result.ToString());
     break;
       case KeywordType.Return:
     FindAndDescribe(component.Params.Output, variable, result.ToString());
     break;
       case KeywordType.Help:
     component.AdditionalHelpFromDocStrings = result.ToString();
     break;
     }
     result = new StringBuilder();
       }
 }
Beispiel #35
0
 public void AddKeyword(string name, KeywordType kw)
 {
     keywordMap.Add(name, new KKeyWord() { Type = kw });
 }
 public static int LookUpImgIndexForKeyword(KeywordSource source, KeywordType type)
 {
     string str = Enum.GetName(typeof(KeywordSource), source) + Enum.GetName(typeof(KeywordType), type);
     if (keywordIndex.ContainsKey(str))
         return keywordIndex[str];
     else
         return -1;
 }
Beispiel #37
0
 public void SYN_setTopStmtTyCheck(KeywordType ks, StmtTyChecker checker)
 {
     var syn = GetSyntax(ks, true);
     syn.TopStmtTyCheck = checker;
 }
Beispiel #38
0
 internal Syntax GetSyntax(KeywordType keyword)
 {
     //return GetSyntax(keyword, true);
     return GetSyntax(keyword, false);
 }
Beispiel #39
0
 public Keyword(KeywordType t)
     : base(ElementType.Keyword)
 {
     KeywordType = t;
 }
Beispiel #40
0
		internal TokenKeyword(KeywordType type, string identifier, DocumentRange range) : base(identifier, range)
		{
			this.m_type = type;
		}
Beispiel #41
0
 public Keyword(String keyword, KeywordType type)
 {
     _keyword = keyword;
     _type = type;
 }