public override IValue GetPropValue(int propNum)
        {
            var prop = _props[propNum];

            var dispId = prop.DispatchId;

            try
            {
                try
                {
                    var result = DispatchUtility.Invoke(Instance, dispId, null);
                    return(CreateIValue(result));
                }
                catch (System.Reflection.TargetInvocationException e)
                {
                    throw e.InnerException ?? e;
                }
            }
            catch (System.MissingMemberException)
            {
                throw RuntimeException.PropNotFoundException(prop.Name);
            }
            catch (System.MemberAccessException)
            {
                throw RuntimeException.PropIsNotReadableException(prop.Name);
            }
        }
        public ValueTableColumn GetColumnByIIndex(IValue index)
        {
            if (index.DataType == DataType.String)
            {
                ValueTableColumn Column = FindColumnByName(index.AsString());
                if (Column == null)
                {
                    throw RuntimeException.PropNotFoundException(index.AsString());
                }
                return(Column);
            }

            if (index.DataType == DataType.Number)
            {
                int i_index = Decimal.ToInt32(index.AsNumber());
                if (i_index < 0 || i_index >= Count())
                {
                    throw RuntimeException.InvalidArgumentValue();
                }

                ValueTableColumn Column = FindColumnByIndex(i_index);
                return(Column);
            }

            if (index is ValueTableColumn)
            {
                return(index as ValueTableColumn);
            }

            throw RuntimeException.InvalidArgumentType();
        }
예제 #3
0
        public override int FindProperty(string name)
        {
            int dispId;

            if (!_dispIdCache.TryGetValue(name, out dispId))
            {
                if (DispatchUtility.TryGetDispId(_instance, name, out dispId))
                {
                    if (_dispatchedType != null)
                    {
                        var memberInfo = _dispatchedType.GetMember(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
                        if (memberInfo.Length == 0 || !(memberInfo[0].MemberType == MemberTypes.Property))
                        {
                            throw RuntimeException.PropNotFoundException(name);
                        }
                        else
                        {
                            _membersCache.Add(dispId, memberInfo[0]);
                            _dispIdCache.Add(name, dispId);
                        }
                    }
                    else
                    {
                        _dispIdCache.Add(name, dispId);
                    }
                }
                else
                {
                    throw RuntimeException.PropNotFoundException(name);
                }
            }

            return(dispId);
        }
예제 #4
0
        private List <ValueTableColumn> GetProcessingColumnList(string ColumnNames, bool EmptyListInCaseOfNull = false)
        {
            List <ValueTableColumn> processing_list = new List <ValueTableColumn>();

            if (ColumnNames != null)
            {
                if (ColumnNames.Trim().Length == 0)
                {
                    // Передали пустую строку вместо списка колонок
                    return(processing_list);
                }

                string[] column_names = ColumnNames.Split(',');
                foreach (string name in column_names)
                {
                    ValueTableColumn Column = Columns.FindColumnByName(name.Trim());

                    if (Column == null)
                    {
                        throw RuntimeException.PropNotFoundException(name.Trim());
                    }

                    processing_list.Add(Column);
                }
            }
            else if (!EmptyListInCaseOfNull)
            {
                foreach (ValueTableColumn Column in _columns)
                {
                    processing_list.Add(Column);
                }
            }
            return(processing_list);
        }
예제 #5
0
        public int GetColumnNumericIndex(IValue index)
        {
            if (index.DataType == DataType.String)
            {
                ValueTableColumn Column = FindColumnByName(index.AsString());
                if (Column == null)
                {
                    throw RuntimeException.PropNotFoundException(index.AsString());
                }
                return(Column.ID);
            }

            if (index.DataType == DataType.Number)
            {
                int iIndex = Decimal.ToInt32(index.AsNumber());
                if (iIndex < 0 || iIndex >= Count())
                {
                    throw RuntimeException.InvalidArgumentValue();
                }

                return(iIndex);
            }

            var column = index.GetRawValue() as ValueTableColumn;

            if (column != null)
            {
                return(column.ID);
            }

            throw RuntimeException.InvalidArgumentType();
        }
예제 #6
0
        internal List <ValueTreeColumn> GetProcessingColumnList(string columnNamesString)
        {
            List <ValueTreeColumn> processingList = new List <ValueTreeColumn>();

            if (columnNamesString != null)
            {
                if (columnNamesString.Trim().Length == 0)
                {
                    // Передали пустую строку вместо списка колонок
                    return(processingList);
                }

                string[] columnNames = columnNamesString.Split(',');
                foreach (string name in columnNames)
                {
                    var column = FindColumnByName(name.Trim());

                    if (column == null)
                    {
                        throw RuntimeException.PropNotFoundException(name.Trim());
                    }

                    processingList.Add(column);
                }
            }
            else
            {
                foreach (var column in _columns)
                {
                    processingList.Add(column);
                }
            }
            return(processingList);
        }
예제 #7
0
        private List <ValueTableSortRule> GetSortRules(string Columns)
        {
            string[] a_columns = Columns.Split(',');

            List <ValueTableSortRule> Rules = new List <ValueTableSortRule>();

            foreach (string column in a_columns)
            {
                string[] description = column.Trim().Split(' ');
                if (description.Count() == 0)
                {
                    throw RuntimeException.PropNotFoundException(""); // TODO: WrongColumnNameException
                }
                ValueTableSortRule Desc = new ValueTableSortRule();
                Desc.Column = this.Columns.FindColumnByName(description[0]);

                if (description.Count() > 1)
                {
                    if (String.Compare(description[1], "DESC", true) == 0 || String.Compare(description[1], "УБЫВ", true) == 0)
                    {
                        Desc.direction = -1;
                    }
                }
                else
                {
                    Desc.direction = 1;
                }

                Rules.Add(Desc);
            }

            return(Rules);
        }
        public override int FindProperty(string name)
        {
            if (!TryFindProperty(name, out var md))
            {
                throw RuntimeException.PropNotFoundException(name);
            }

            return(_props.IndexOf(md));
        }
예제 #9
0
        public int GetPropertyNumber(string name)
        {
            if (_propNumbers.TryGetValue(name, out var index))
            {
                return(index);
            }

            throw RuntimeException.PropNotFoundException(name);
        }
        public override int FindProperty(string name)
        {
            int idx = _columns.FindIndex(column => NamesComparer.Equals(name, column.Name));

            if (idx == -1)
            {
                throw RuntimeException.PropNotFoundException(name);
            }
            return(idx);
        }
예제 #11
0
        public override int FindProperty(string name)
        {
            var column = FindColumnByName(name);

            if (column == null)
            {
                throw RuntimeException.PropNotFoundException(name);
            }
            return(_columns.IndexOf(column));
        }
예제 #12
0
        public override int FindProperty(string name)
        {
            ValueTableColumn Column = FindColumnByName(name);

            if (Column == null)
            {
                throw RuntimeException.PropNotFoundException(name);
            }
            return(Column.ID);
        }
예제 #13
0
        public int FindProperty(string name)
        {
            var propNumber = NativeApiProxy.FindProp(_object, name);

            if (propNumber < 0)
            {
                throw RuntimeException.PropNotFoundException(name);
            }
            return(propNumber);
        }
예제 #14
0
        public int FindProperty(string name)
        {
            var idx = _properties.FindIndex(x => x.Name.ToLower() == name.ToLower() || x.Alias.ToLower() == name.ToLower());

            if (idx < 0)
            {
                throw RuntimeException.PropNotFoundException(name);
            }

            return(idx);
        }
예제 #15
0
 public int GetPropertyNumber(string name)
 {
     try
     {
         return(_propNumbers[name]);
     }
     catch (KeyNotFoundException)
     {
         throw RuntimeException.PropNotFoundException(name);
     }
 }
예제 #16
0
        public override int FindProperty(string name)
        {
            var idx = FindMemberIndex(name);

            if (idx < 0)
            {
                throw RuntimeException.PropNotFoundException(name);
            }

            return(idx);
        }
예제 #17
0
 public override int FindProperty(string name)
 {
     try
     {
         return(_propHolder.GetPropertyNumber(name));
     }
     catch (KeyNotFoundException)
     {
         throw RuntimeException.PropNotFoundException(name);
     }
 }
예제 #18
0
        public int FindProperty(string name)
        {
            var idx = GetPropertyIndex(name);

            if (idx < 0)
            {
                throw RuntimeException.PropNotFoundException(name);
            }

            return(idx);
        }
예제 #19
0
        public int FindProperty(string name)
        {
            int id;

            if (!_thisPropIndexes.TryGetIdOfName(name, out id))
            {
                throw RuntimeException.PropNotFoundException(name);
            }

            return(id);
        }
예제 #20
0
        public int FindProperty(string name)
        {
            Init();
            var idx = _properties.FindIndex(x => String.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase) ||
                                            String.Equals(x.Alias, name, StringComparison.OrdinalIgnoreCase));

            if (idx < 0)
            {
                throw RuntimeException.PropNotFoundException(name);
            }

            return(idx);
        }
예제 #21
0
        public int FindAnyProperty(string name)
        {
            int index;

            if (_allPropertiesSearchCache.TryGetValue(name, out index))
            {
                return(index);
            }
            else
            {
                throw RuntimeException.PropNotFoundException(name);
            }
        }
예제 #22
0
        public override int FindProperty(string name)
        {
            if (_properties.ContainsProperty(name))
            {
                return(_properties.FindProperty(name));
            }

            var cols   = Owner().Columns;
            var column = cols.FindColumnByName(name);

            if (column == null)
            {
                throw RuntimeException.PropNotFoundException(name);
            }

            return(GetColumnPropIndex(cols.IndexOf(column)));
        }
예제 #23
0
        private bool CheckFilterCriteria(ValueTableRow Row, StructureImpl Filter)
        {
            foreach (KeyAndValueImpl kv in Filter)
            {
                ValueTableColumn Column = Columns.FindColumnByName(kv.Key.AsString());
                if (Column == null)
                {
                    throw RuntimeException.PropNotFoundException(kv.Key.AsString());
                }

                IValue current = Row.Get(Column);
                if (!current.Equals(kv.Value))
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #24
0
        public override int FindProperty(string name)
        {
            int dispId;

            if (!_dispIdCache.TryGetValue(name, out dispId))
            {
                if (DispatchUtility.TryGetDispId(_instance, name, out dispId))
                {
                    _dispIdCache.Add(name, dispId);
                }
                else
                {
                    throw RuntimeException.PropNotFoundException(name);
                }
            }

            return(dispId);
        }
예제 #25
0
        public override void SetPropValue(int propNum, IValue newVal)
        {
            var prop = _props[propNum];

            var dispId = prop.DispatchId;

            try
            {
                try
                {
                    object argToPass;
                    if (newVal.DataType == Machine.DataType.Date)
                    {
                        var date = newVal.AsDate();
                        if (date == DateTime.MinValue)
                        {
                            argToPass = new DateTime(100, 1, 1); // Min OLEAuth Date
                        }
                        else
                        {
                            argToPass = MarshalIValue(newVal);
                        }
                    }
                    else
                    {
                        argToPass = MarshalIValue(newVal);
                    }
                    DispatchUtility.InvokeSetProperty(Instance, dispId, argToPass);
                }
                catch (System.Reflection.TargetInvocationException e)
                {
                    throw e.InnerException ?? e;
                }
            }
            catch (System.MissingMemberException)
            {
                throw RuntimeException.PropNotFoundException(prop.Name);
            }
            catch (System.MemberAccessException)
            {
                throw RuntimeException.PropIsNotWritableException(prop.Name);
            }
        }
예제 #26
0
        public override int FindProperty(string name)
        {
            var idx = FindOwnProperty(name);

            if (idx >= 0)
            {
                return(idx);
            }
            else
            {
                int index;
                if (_propertySearchCache.TryGetValue(name, out index))
                {
                    return(index);
                }
                else
                {
                    throw RuntimeException.PropNotFoundException(name);
                }
            }
        }
예제 #27
0
 public override void SetPropValue(int propNum, IValue newVal)
 {
     try
     {
         try
         {
             object argToPass;
             if (newVal.DataType == Machine.DataType.Date)
             {
                 var date = newVal.AsDate();
                 if (date == DateTime.MinValue)
                 {
                     argToPass = new DateTime(100, 1, 1); // Min OLEAuth Date
                 }
                 else
                 {
                     argToPass = MarshalIValue(newVal);
                 }
             }
             else
             {
                 argToPass = MarshalIValue(newVal);
             }
             DispatchUtility.InvokeSetProperty(_instance, propNum, argToPass);
         }
         catch (System.Reflection.TargetInvocationException e)
         {
             throw e.InnerException;
         }
     }
     catch (System.MissingMemberException)
     {
         throw RuntimeException.PropNotFoundException("dispid[" + propNum.ToString() + "]");
     }
     catch (System.MemberAccessException)
     {
         throw RuntimeException.PropIsNotWritableException("dispid[" + propNum.ToString() + "]");
     }
 }
예제 #28
0
        public override int FindProperty(string name)
        {
            var idx = FindOwnProperty(name);

            if (idx >= 0)
            {
                return(idx);
            }
            else
            {
                var propsFound = _module.ExportedProperies.Where(x => String.Compare(x.SymbolicName, name, true) == 0)
                                 .Select(x => x.Index).ToArray();
                if (propsFound.Length > 0)
                {
                    return(propsFound[0]);
                }
                else
                {
                    throw RuntimeException.PropNotFoundException(name);
                }
            }
        }
예제 #29
0
 public override void SetPropValue(int propNum, IValue newVal)
 {
     try
     {
         try
         {
             DispatchUtility.InvokeSetProperty(_instance, propNum, MarshalIValue(newVal));
         }
         catch (System.Reflection.TargetInvocationException e)
         {
             throw e.InnerException;
         }
     }
     catch (System.MissingMemberException)
     {
         throw RuntimeException.PropNotFoundException("dispid[" + propNum.ToString() + "]");
     }
     catch (System.MemberAccessException)
     {
         throw RuntimeException.PropIsNotWritableException("dispid[" + propNum.ToString() + "]");
     }
 }
예제 #30
0
 public override IValue GetPropValue(int propNum)
 {
     try
     {
         try
         {
             var result = DispatchUtility.Invoke(_instance, propNum, null);
             return(CreateIValue(result));
         }
         catch (System.Reflection.TargetInvocationException e)
         {
             throw e.InnerException;
         }
     }
     catch (System.MissingMemberException)
     {
         throw RuntimeException.PropNotFoundException("dispid[" + propNum.ToString() + "]");
     }
     catch (System.MemberAccessException)
     {
         throw RuntimeException.PropIsNotReadableException("dispid[" + propNum.ToString() + "]");
     }
 }