コード例 #1
0
ファイル: EditCommand.cs プロジェクト: s2quake/JSSoft.Crema
        public override string[] GetCompletions(CommandCompletionContext completionContext)
        {
            var domain    = this.Content.Dispatcher.Invoke(() => this.Content.Domain);
            var tableInfo = this.Content.Dispatcher.Invoke(() => this.Content.Table.TableInfo);

            return(domain.Dispatcher.Invoke(() =>
            {
                var dataSet = domain.Source as CremaDataSet;
                var dataTable = dataSet.Tables[tableInfo.Name];

                if (completionContext.Arguments.Length >= dataTable.PrimaryKey.Length)
                {
                    return null;
                }

                var expItems = new List <string>();
                for (var i = 0; i < completionContext.Arguments.Length; i++)
                {
                    expItems.Add($"{dataTable.PrimaryKey[i].ColumnName}='{completionContext.Arguments[i]}'");
                }

                var expression = string.Join(" AND ", expItems);
                var query = from item in dataTable.Select(expression)
                            let value = CremaConvert.ChangeType(item[dataTable.PrimaryKey[completionContext.Arguments.Length]], typeof(string)) as string
                                        select value;
                return query.ToArray();
            }));
        }
コード例 #2
0
 public override string[] GetCompletions(CommandCompletionContext completionContext)
 {
     if (completionContext.MemberDescriptor == null || completionContext.MemberDescriptor.DescriptorName == nameof(Path) == true)
     {
         return(this.CommandContext.GetCompletion(completionContext.Find));
     }
     return(base.GetCompletions(completionContext));
 }
コード例 #3
0
ファイル: UnlockCommand.cs プロジェクト: s2quake/JSSoft.Crema
 public override string[] GetCompletions(CommandCompletionContext completionContext)
 {
     if (completionContext.MemberDescriptor is CommandMemberDescriptor memberDescriptor && memberDescriptor.DescriptorName == nameof(this.Path))
     {
         return(this.CommandContext.GetCompletion(completionContext.Find, true));
     }
     return(base.GetCompletions(completionContext));
 }
コード例 #4
0
ファイル: KickCommand.cs プロジェクト: teize001/Crema
 public override string[] GetCompletions(CommandCompletionContext completionContext)
 {
     if (completionContext.MemberDescriptor != null && completionContext.MemberDescriptor.DescriptorName == nameof(this.UserID))
     {
         return(this.GetUserList());
     }
     return(base.GetCompletions(completionContext));
 }
コード例 #5
0
ファイル: NotifyCommand.cs プロジェクト: teize001/Crema
 public override string[] GetCompletions(CommandCompletionContext completionContext)
 {
     return(this.UserContext.Dispatcher.Invoke(() =>
     {
         var query = from item in this.UserContext.Users
                     select item.ID;
         return query.ToArray();
     }));
 }
コード例 #6
0
 public void OnCompleted(CommandCompletionContext context)
 {
     if (context.Result is IEnumerable <Stream> streams)
     {
         foreach (var stream in streams)
         {
             if (stream != null)
             {
                 stream.Close();
             }
         }
     }
     else if (context.Result is Stream stream)
     {
         stream.Close();
     }
 }
コード例 #7
0
 public override string[] GetCompletions(CommandCompletionContext completionContext)
 {
     return(this.CommandContext.GetCompletion(completionContext.Find));
 }