Example #1
0
 public TrieSymbolTable(string _name, Trie trie)
 {
     name         = _name;
     this.trie    = trie;
     codeTable    = new SortedDictionary <int, TrieNode>();
     nullValues   = new InputNullValues("one", this);
     valueCounter = 1;
 }
        /// <summary>
        /// Retrieves the user input from the value control and assigns it to Value
        /// </summary>
        internal override void ControlToValue()
        {
            //set value to null by default
            Value = null;

            //null values
            if (string.IsNullOrWhiteSpace(ValueControl.Text))
            {
                return;
            }

            //search primary KeyNotFoundException string at the end of the Text, betewwn parenthesis
            //example: My Company Inc. (id=34)
            try
            {
                string pkString = ValueControl.Text.Substring(ValueControl.Text.IndexOf('(') + 1);
                pkString = pkString.TrimEnd(')');
                pkString = pkString.Trim();

                DataObject dobj = DataObject.From(this.ValueType);
                TypeConverter.ToDataValueInstances(pkString, dobj.PrimaryKey);

                Value = dobj;
            }
            catch { }

            //if last attempt was succesfull, load selected from database and exit
            if (!NullValues.IsNull(Value))
            {
                //if select operation returns null, set value to null again
                if (DataBase.Current.Select((DataObject)Value) == null)
                {
                    Value = null;
                }

                //otherwise value is already selected and loaded, so exit
                else
                {
                    return;
                }
            }

            //otherwise search in the database for a match
            DataObjectCollection found = DataBase.Current.Search(ValueType, ValueControl.Text);

            //if found a match, get the first result, otherwise, set Value to null
            if (found.Count > 0)
            {
                Value = found[0];
            }
            else
            {
                Value = null;
            }
        }
Example #3
0
 public HashSymbolTable(string _name)
 {
     name           = _name;
     category       = SymbolTable_Fields.NA;
     type           = SymbolTable_Fields.STRING;
     symbolCodeMap  = new HashMap <string, int>();
     codeSymbolMap  = new HashMap <int, string>();
     symbolValueMap = new HashMap <string, double>();
     nullValues     = new InputNullValues("one", this);
     valueCounter   = 1;
 }
Example #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public TrieSymbolTable(String _name, Trie _trie, int _category, String nullValueStrategy) throws org.maltparser.core.exception.MaltChainedException
        public TrieSymbolTable(string _name, Trie _trie, int _category, string nullValueStrategy)
        {
            name      = _name;
            trie      = _trie;
            category  = _category;
            codeTable = new SortedDictionary <int, TrieNode>();
            if (category != SymbolTable_Fields.OUTPUT)
            {
                nullValues = new OutputNullValues(nullValueStrategy, this);
            }
            else
            {
                nullValues = new InputNullValues(nullValueStrategy, this);
            }
            valueCounter = nullValues.NextCode;
        }
Example #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public HashSymbolTable(String _name, int _category, int _type, String nullValueStrategy) throws org.maltparser.core.exception.MaltChainedException
        public HashSymbolTable(string _name, int _category, int _type, string nullValueStrategy)
        {
            name           = _name;
            category       = _category;
            type           = _type;
            symbolCodeMap  = new HashMap <string, int>();
            codeSymbolMap  = new HashMap <int, string>();
            symbolValueMap = new HashMap <string, double>();
            if (category == SymbolTable_Fields.OUTPUT)
            {
                nullValues = new OutputNullValues(nullValueStrategy, this);
            }
            else
            {
                nullValues = new InputNullValues(nullValueStrategy, this);
            }
            valueCounter = nullValues.NextCode;
        }
        /// <summary>
        /// Assings the Value to the valuecontrol input
        /// </summary>
        internal override void ValueToControl()
        {
            if (!NullValues.IsNull(Value))
            {
                DataObject selected;

                selected = (DataObject)Value;
                if (!selected.IsSaved)
                {
                    selected.Select();
                }

                ValueControl.Text = selected.ToString() + " (" + TypeConverter.ToString(selected.PrimaryKey) + ")";
            }
            else
            {
                ValueControl.Text = null;
            }
        }
Example #7
0
        /// <summary>
        /// Determines whether the specified object is null.
        /// </summary>
        public static bool IsNull <T>(this T arg)
        {
#pragma warning disable IDE0041 // Use 'is null' check
            if (ReferenceEquals(null, arg))
            {
                return(true);
            }
#pragma warning restore IDE0041 // Use 'is null' check
            Type t = typeof(T);
            if (t.IsGenericType && ((t.IsGenericTypeDefinition && t.Equals(StaticTypes.nullableTypeDefinition)) || t.GetGenericTypeDefinition().Equals(StaticTypes.nullableTypeDefinition)))
            {
                PropertyInfo hasValueProperty = t.GetProperty("HasValue");
                return(!(bool)hasValueProperty.GetValue(arg));
            }
            if (NullTypes.Any(type => !(type is null) && t.IsAssignableFrom(type)))
            {
                return(true);
            }
            if (NullValues.Any(value => ReferenceEquals(value, arg) || arg.Equals(value) || (value is IEquatable <T> equatable && equatable.Equals(arg))))
            {
                return(true);
            }
            return(false);
        }
 /// <summary>
 /// Determines whether a default value definition is a null value.
 /// </summary>
 /// <param name="defaultValue">A column's default value.</param>
 /// <returns><c>true</c> if the provided default value is a null value; otherwise, <c>false</c>.</returns>
 protected static bool IsNullDefaultValue(string defaultValue)
 {
     return(!defaultValue.IsNullOrWhiteSpace() &&
            NullValues.Contains(defaultValue));
 }