/// <summary> /// 开始接收键盘数据 /// </summary> /// <param name="pType">数据类型</param> /// <param name="pData">数据</param> /// <param name="pCommand">键盘命令</param> void temp_OnReceivedKeyData(KeyDataType pType, string pData, KeyCommand pCommand) { if (OnReceivedKeyData != null) { OnReceivedKeyData(pType, pData, pCommand); } }
/// <summary> /// Public constructor(can be used for ordered keys) /// </summary> /// <param name="keyDataType"> </param> /// <param name="keyType"> </param> /// <param name="name"> </param> /// <param name="isOrdered"> </param> public KeyInfo(KeyDataType keyDataType, KeyType keyType, string name, bool isOrdered) { KeyDataType = keyDataType; KeyType = keyType; Name = name; IsOrdered = isOrdered; }
/// <summary> /// </summary> /// <param name="propertyName"></param> /// <param name="keyType"></param> /// <param name="keyDataType"></param> /// <param name="order"></param> public PropertyDescription(string propertyName, KeyType keyType, KeyDataType keyDataType, bool order) { PropertyName = propertyName; Ordered = order; KeyType = keyType; KeyDataType = keyDataType; }
void ikb_OnReceivedKeyData(KeyDataType pType, string pData, KeyCommand pCommand) { if (pType == KeyDataType.COMMAND)//表示命令 { ikb.Stop(); ikb.Close(); if (pCommand == KeyCommand.OK)//按了确定键 { IsOk = true; // this.Close(); } else { IsOk = false; // this.Close(); } System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { this.Close(); })); } else if (pType == KeyDataType.DATA)//按了取消键 { } }
public Search(string express, object key1, object key2, KeyDataType datatype = KeyDataType.Date) { this.Keys = new string[] { key1.ToString(), key2.ToString() }; this.Values = new List <object>(); this.Express = express; this.DataType = datatype; }
/// <summary> /// 获取键盘数据的方法 /// </summary> /// <param name="pType">数据类型</param> /// <param name="pData">数据内容</param> /// <param name="pCommand">命令</param> private void OnGetKeyData(KeyDataType pType, string pData, KeyCommand pCommand) { if (OnReceivedKeyData != null) { OnReceivedKeyData(pType, pData, pCommand); } }
/// <summary> /// Public constructor for non ordered keys /// </summary> /// <param name="keyDataType"> </param> /// <param name="keyType"> </param> /// <param name="name"> </param> /// <param name="isOrdered"></param> /// <param name="isFullText"></param> public KeyInfo(KeyDataType keyDataType, KeyType keyType, string name, bool isOrdered = false, bool isFullText = false) { KeyDataType = keyDataType; KeyType = keyType; Name = name; IsOrdered = isOrdered; IsFullTextIndexed = isFullText; }
public override int GetHashCode() { var result = Info.GetHashCode(); result = 29 * result + KeyType.GetHashCode(); result = 29 * result + KeyDataType.GetHashCode(); return(result); }
/// <summary> /// </summary> /// <param name="propertyName"></param> /// <param name="keyType"></param> /// <param name="keyDataType"></param> /// <param name="ordered"></param> /// <param name="fullTextIndexed"></param> public PropertyDescription(string propertyName, KeyType keyType, KeyDataType keyDataType, bool ordered, bool fullTextIndexed) { PropertyName = propertyName; Ordered = ordered; KeyType = keyType; KeyDataType = keyDataType; FullTextIndexed = fullTextIndexed; }
public override int GetHashCode() { var result = KeyDataType.GetHashCode(); result = 29 * result + KeyType.GetHashCode(); result = 29 * result + Name.GetHashCode(); result = 29 * result + IsOrdered.GetHashCode(); return(result); }
/// <summary> /// 非标准键盘响应事件对应的方法 /// </summary> /// <param name="pType">数据类型</param> /// <param name="pData">数据(数据类型为命令时,pData为空。)</param> /// <param name="pCommand">键盘命令</param> void ikb_OnReceivedKeyData(KeyDataType pType, string pData, KeyCommand pCommand) { if (pType == KeyDataType.COMMAND)//表示命令 { bool isCloseForm = false; if (pCommand == KeyCommand.OK)//按了确定键 { isCloseForm = true; IsOk = true; } else if (pCommand == KeyCommand.CANCEL)//按了取消键 { isCloseForm = true; IsOk = false; } else if (pCommand == KeyCommand.CLEAR)//按了清空键 { this.businessNoTextBlock.Text = string.Empty; } else if (pCommand == KeyCommand.DELETE)//按了删除键 { if (this.businessNoTextBlock.Text.Trim().Length >= 2) { string curBusinessNo = this.businessNoTextBlock.Text.Trim(); this.businessNoTextBlock.Text = curBusinessNo.Substring(0, curBusinessNo.Length - 1); } else { this.businessNoTextBlock.Text = string.Empty; } } else if (pCommand == KeyCommand.HELP)//按了求助键 { isCloseForm = true; IsHelp = true; } if (isCloseForm) { ikb.Stop(); ikb.Close(); this.BussinessNo = this.businessNoTextBlock.Text.Trim(); System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { this.Close(); })); } } else if (pType == KeyDataType.DATA)//按了键盘中的数字键 { this.businessNoTextBlock.Text = this.businessNoTextBlock.Text.Trim() + pData; } }
/// <summary> /// Build from PropertyInfo /// The complementary information is stored as <see cref="PropertyDescription" /> /// </summary> /// <param name="propertyInfo"> </param> /// <param name="propertyDescription"> contains indexing information for this property </param> public ClientSideKeyInfo(PropertyInfo propertyInfo, PropertyDescription propertyDescription) { if (propertyDescription == null) { throw new ArgumentNullException(nameof(propertyDescription)); } _propertyInfo = propertyInfo; KeyType = propertyDescription.KeyType; _keyDataType = propertyDescription.KeyDataType; _isOrdered = propertyDescription.Ordered; }
/// <summary> /// Build from PropertyInfo /// The complementary information is stored as <see cref="PropertyDescription" /> /// </summary> /// <param name="propertyInfo"> </param> /// <param name="propertyDescription"> contains indexing information for this property </param> public ClientSideKeyInfo(PropertyInfo propertyInfo, PropertyDescription propertyDescription) { if (propertyDescription == null) { throw new ArgumentNullException(nameof(propertyDescription)); } _propertyInfo = propertyInfo; Getter = _propertyInfo.CompileGetter(); KeyType = propertyDescription.KeyType; _keyDataType = propertyDescription.KeyDataType; _isOrdered = propertyDescription.Ordered; IndexedAsFulltext = propertyDescription.FullTextIndexed; AsKeyInfo = new KeyInfo(_keyDataType, KeyType, Info.Name, _isOrdered, IndexedAsFulltext); }
//public byte[] Tag //{ // get // { // //if (ForSerialize) // // return tag; // IDescriptor descriptor = GetDescriptor(this); // tag = descriptor.Tag; // return tag; // } // set // { // //this.ForSerialize = true; // //this.tag = value; // //IDescriptor descriptor = SetDescriptor(this); // //tag = descriptor.Tag; // //this.ForSerialize = false; // } //} #endregion public void Serialize(BinaryWriter writer) { CountCompression.Serialize(writer, (ulong)ID); writer.Write(Name); CountCompression.Serialize(writer, (ulong)StructureType); KeyDataType.Serialize(writer); RecordDataType.Serialize(writer); CountCompression.Serialize(writer, (ulong)CreateTime.Ticks); CountCompression.Serialize(writer, (ulong)ModifiedTime.Ticks); CountCompression.Serialize(writer, (ulong)AccessTime.Ticks); if (Tag == null) { CountCompression.Serialize(writer, 0); } else { CountCompression.Serialize(writer, (ulong)Tag.Length + 1); writer.Write(Tag); } }
/// <summary> /// Helper method. Directly add a property description /// </summary> /// <param name="propertyName"></param> /// <param name="keyType"></param> /// <param name="keyDataType"></param> /// <param name="b"></param> /// <param name="fullTextIndexed"></param> public void Add(string propertyName, KeyType keyType, KeyDataType keyDataType, bool ordered = false, bool fullTextIndexed = false) { _keys.Add(propertyName, new PropertyDescription(propertyName, keyType, keyDataType, ordered, fullTextIndexed)); }
/// <summary> /// </summary> /// <param name="keyDataType">int or string key</param> public PrimaryKeyAttribute(KeyDataType keyDataType) { KeyDataType = keyDataType; }
/// <summary> /// Build from PropertyInfo /// The complementary information is stored as custom attributes /// </summary> /// <param name="propertyInfo"> </param> public ClientSideKeyInfo(PropertyInfo propertyInfo) { try { _propertyInfo = propertyInfo; Getter = _propertyInfo.CompileGetter(); // full text indexation can be applied to any type of key or event to non indexed properties var fullText = propertyInfo.GetCustomAttributes(typeof(FullTextIndexationAttribute), true) .FirstOrDefault(); if (fullText != null) { IndexedAsFulltext = true; } //check if primary key var attributes = propertyInfo.GetCustomAttributes(typeof(PrimaryKeyAttribute), true); if (attributes.Length == 1) { KeyType = KeyType.Primary; if (attributes[0] is PrimaryKeyAttribute attr) { _keyDataType = attr.KeyDataType; } return; } //check if unique key attributes = propertyInfo.GetCustomAttributes(typeof(KeyAttribute), true); if (attributes.Length == 1) { KeyType = KeyType.Unique; if (attributes[0] is KeyAttribute attr) { _keyDataType = attr.KeyDataType; } return; } //check if index attributes = propertyInfo.GetCustomAttributes(typeof(IndexAttribute), true); if (attributes.Length > 0) { // Index attribute may be applied to scalar types or collections if (propertyInfo.PropertyType == typeof(string)) { // the string is IEnumerable but it should be treated as scalar KeyType = KeyType.ScalarIndex; } else { KeyType = typeof(IEnumerable).IsAssignableFrom(propertyInfo.PropertyType) ? KeyType.ListIndex : KeyType.ScalarIndex; } if (attributes[0] is IndexAttribute attr) { _keyDataType = attr.KeyDataType; _isOrdered = attr.Ordered; } return; } KeyType = KeyType.None; } finally { AsKeyInfo = new KeyInfo(_keyDataType, KeyType, Info.Name, _isOrdered, IndexedAsFulltext); } }
/// <summary> /// Public constructor for non ordered keys /// </summary> /// <param name="keyDataType"> </param> /// <param name="keyType"> </param> /// <param name="name"> </param> public KeyInfo(KeyDataType keyDataType, KeyType keyType, string name) { KeyDataType = keyDataType; KeyType = keyType; Name = name; }
/// <summary> /// </summary> /// <param name="propertyName"></param> /// <param name="keyType"></param> /// <param name="keyDataType"></param> public PropertyDescription(string propertyName, KeyType keyType, KeyDataType keyDataType) : this(propertyName, keyType, keyDataType, false) { }
/// <summary> /// Build a unique key having the specified data type /// </summary> /// <param name="keyDataType"></param> public KeyAttribute(KeyDataType keyDataType) { KeyDataType = keyDataType; }
private void InternalSerialize(BinaryWriter writer) { lock (SyncRoot) { writer.Write(VERSION); writer.Write(ID); if (ID == Locator.MIN.ID) { return; } writer.Write(IsDeleted); writer.Write(Name); writer.Write(checked ((byte)StructureType)); //data types KeyDataType.Serialize(writer); RecordDataType.Serialize(writer); //types if (!DataTypeUtils.IsAnonymousType(KeyType)) { writer.Write(KeyType.FullName); } else { writer.Write(""); } if (!DataTypeUtils.IsAnonymousType(RecordType)) { writer.Write(RecordType.FullName); } else { writer.Write(""); } //key & record members WriteMembers(writer, keyMembers); WriteMembers(writer, recordMembers); //times writer.Write(CreateTime.Ticks); writer.Write(ModifiedTime.Ticks); writer.Write(AccessTime.Ticks); //tag if (Tag == null) { writer.Write(false); } else { writer.Write(true); CountCompression.Serialize(writer, (ulong)Tag.Length); writer.Write(Tag); } } }
/// <summary> /// Build from PropertyInfo /// The complementary information is stored as custom attributes /// </summary> /// <param name="propertyInfo"> </param> public ClientSideKeyInfo(PropertyInfo propertyInfo) { _propertyInfo = propertyInfo; //check if primary key var attributes = propertyInfo.GetCustomAttributes(typeof(PrimaryKeyAttribute), true); if (attributes.Length == 1) { KeyType = KeyType.Primary; if (attributes[0] is PrimaryKeyAttribute attr) { _keyDataType = attr.KeyDataType; } return; } //check if unique key attributes = propertyInfo.GetCustomAttributes(typeof(KeyAttribute), true); if (attributes.Length == 1) { KeyType = KeyType.Unique; if (attributes[0] is KeyAttribute attr) { _keyDataType = attr.KeyDataType; } return; } //check if index attributes = propertyInfo.GetCustomAttributes(typeof(IndexAttribute), true); if (attributes.Length > 0) { // Index attribute may be applied to scalar types or collections if (propertyInfo.PropertyType == typeof(string)) { // the string is IEnumerable but it should be treated as scalar KeyType = KeyType.ScalarIndex; } else { KeyType = typeof(IEnumerable).IsAssignableFrom(propertyInfo.PropertyType) ? KeyType.ListIndex : KeyType.ScalarIndex; } if (attributes[0] is IndexAttribute attr) { _keyDataType = attr.KeyDataType; _isOrdered = attr.Ordered; } return; } KeyType = KeyType.None; }
/// <summary> /// </summary> /// <param name="keyDataType">int or string key</param> public IndexAttribute(KeyDataType keyDataType) : this(keyDataType, false) { }
/// <summary> /// </summary> /// <param name="keyDataType">int or string key</param> /// <param name="ordered">if true, comparison operators can be applied</param> public IndexAttribute(KeyDataType keyDataType, bool ordered) { KeyDataType = keyDataType; Ordered = ordered; }
public Search(string express, object key, KeyDataType datatype = KeyDataType.String) { this.Key = key.ToString(); this.Express = express; this.DataType = datatype; }