Example #1
0
        private protected override void InitializeByRef(PropertyInfo propertyInfo, XBindingFlags flags)
        {
            base.InitializeByRef(propertyInfo, flags);

            if (_get is null || _set is null)
            {
                var getMethod = propertyInfo.GetGetMethod((flags & XBindingFlags.NonPublic) != 0);

                if (getMethod != null)
                {
                    var _ref = (RefValueHandler)Delegate.CreateDelegate(typeof(RefValueHandler), getMethod);

                    _get = (ref TStruct obj) =>
                    {
                        return(_ref(ref obj));
                    };

                    _set = (ref TStruct obj, TValue value) =>
                    {
                        _ref(ref obj) = value;
                    };

                    // TODO: AOTCheck
                }
            }
        }
Example #2
0
 public GetPropertyHandler(PropertyInfo property)
 {
     if (property.CanRead)
     {
         Get = ReflectionHandlerFactory.PropertyGetHandler(property);
     }
 }
Example #3
0
        protected virtual void AddProperty(string propertyName,
                                           string description,
                                           GetValueHandler getValueHandler,
                                           SetValueHandler setValueHandler,
                                           ValidateEnableHandler isEnableHandler,
                                           ValidateVisibleHandler isVisibleHandler,
                                           ValidateValueHandler validateHandler)
        {
            BOProperty property = new BOProperty(
                propertyName,
                description,
                getValueHandler,
                setValueHandler,
                isEnableHandler,
                isVisibleHandler,
                validateHandler
                );

            if (mProperties.ContainsKey(propertyName))
            {
                throw new Exception(string.Format("property {0} already exists", propertyName));
            }

            mProperties[propertyName] = property;
        }
 internal ExtendedPropertyInfo(PropertyInfo propertyInfo, GetValueHandler getValueHandler, SetValueHandler setValueHandler, GetQualifiedNameHandler qualifiedNameHandler)
 {
     this.realPropertyInfo = propertyInfo;
     this.OnGetValue = getValueHandler;
     this.OnSetValue = setValueHandler;
     this.OnGetXmlQualifiedName = qualifiedNameHandler;
 }
 internal ExtendedPropertyInfo(PropertyInfo propertyInfo, GetValueHandler getValueHandler, SetValueHandler setValueHandler, GetQualifiedNameHandler qualifiedNameHandler)
 {
     this.realPropertyInfo      = propertyInfo;
     this.OnGetValue            = getValueHandler;
     this.OnSetValue            = setValueHandler;
     this.OnGetXmlQualifiedName = qualifiedNameHandler;
 }
Example #6
0
 public GetPropertyHandler(PropertyInfo property)
 {
     if (property.CanRead)
     {
         this.mGetValue = ReflectionHandlerFactory.PropertyGetHandler(property);
     }
     this.mProperty = property;
     this.mName     = property.Name;
 }
Example #7
0
 public GetPropertyHandler(PropertyInfo property)
 {
     if (property.CanRead)
     {
         this.mGetValue = PropertyGetHandler(property);
     }
     this.mProperty = property;
     this.mName     = property.Name;
 }
Example #8
0
 public PropertyHandler(PropertyInfo property)
 {
     if (property.CanWrite)
     {
         this.mSetValue = ReflectionHandlerFactory.PropertySetHandler(property);
     }
     if (property.CanRead)
     {
         this.mGetValue = ReflectionHandlerFactory.PropertyGetHandler(property);
     }
     this.mProperty     = property;
     this.IndexProperty = this.mProperty.GetMethod.GetParameters().Length > 0;
 }
        public PropertyAccessor(Type ownerType, string propertyName)
        {
            PropertyInfo propertyInfo = ownerType.GetProperty(propertyName);

            if (propertyInfo.CanRead)
            {
                this._getValueHandler = this.CreateGetValueHandler(propertyInfo);
            }

            if (propertyInfo.CanWrite)
            {
                this._setValueHandler = this.CreateSetValueHandler(propertyInfo);
            }
        }
Example #10
0
        /// <summary>
        /// Get from cache
        /// </summary>
        /// <param name="name"></param>
        /// <param name="getValue"></param>
        /// <returns></returns>
        protected object GetFromCache(string name, GetValueHandler getValue)
        {
            object obj;

            if (_cache.TryGetValue(name, out obj))
            {
                return(obj);
            }

            if (getValue != null)
            {
                obj = getValue.Invoke();

                _cache[name] = obj;
            }

            return(obj);
        }
 public BOProperty(
     string propertyName,
     string description,
     GetValueHandler getValueHandler,
     SetValueHandler setValueHandler,
     ValidateEnableHandler isEnableHandler,
     ValidateVisibleHandler isVisibleHandler,
     ValidateValueHandler validateValueHandler
     )
 {
     this.Description             = description;
     this.PropertyName            = propertyName;
     this.mGetValueHandler        = getValueHandler;
     this.mSetValueHandler        = setValueHandler;
     this.mValidateEnableHandler  = isEnableHandler;
     this.mValidateVisibleHandler = isVisibleHandler;
     this.mValidateValueHandler   = validateValueHandler;
 }
Example #12
0
        public StatusItem(string name, string description, GetValueHandler getValue)
        {
            if (getValue == null)
            {
                throw new ArgumentNullException("getValue");
            }

            this.name        = name;
            this.description = description;
            this.GetValue    = getValue;

            object value = getValue();

            if (value == null)
            {
                lastValue = null;
            }
            else
            {
                lastValue = value.ToString();
            }
        }
Example #13
0
        public DataParameterMapping(PropertyInfo property, string name, ParameterDirection direction)
        {
            if (property.CanRead)
            {
                this.mGetValue = ReflectionHandlerFactory.PropertyGetHandler(property);
            }
            if (property.CanWrite)
            {
                this.mSetValue = ReflectionHandlerFactory.PropertySetHandler(property);
            }
            this.mType = property.PropertyType;
            TypeCode code = Type.GetTypeCode(this.mType);

            this.mConvertString = code == TypeCode.Object || code == TypeCode.DBNull || code == TypeCode.Empty;
            if ((this.mDirection == ParameterDirection.InputOutput || this.mDirection == ParameterDirection.Output) && mConvertString)
            {
                throw new LightDataException(SR.OutputParameterNotSupportObjectType);
            }
            this.mProperty  = property;
            this.mName      = string.IsNullOrEmpty(name) ? property.Name : name;
            this.mDirection = direction;
        }
Example #14
0
        private static GetValueHandler CreatePropertyGetHandler(PropertyInfo property)
        {
            DynamicMethod dynamicMethod = new DynamicMethod(string.Empty, typeof(object), new Type[] { typeof(object) }, property.DeclaringType.Module);

            ILGenerator ilGenerator = dynamicMethod.GetILGenerator();


            ilGenerator.Emit(OpCodes.Ldarg_0);


            ilGenerator.EmitCall(OpCodes.Callvirt, property.GetGetMethod(), null);


            EmitBoxIfNeeded(ilGenerator, property.PropertyType);


            ilGenerator.Emit(OpCodes.Ret);


            GetValueHandler getter = (GetValueHandler)dynamicMethod.CreateDelegate(typeof(GetValueHandler));

            return(getter);
        }
Example #15
0
        /// <summary>
        /// Export data to a stream
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="tList"></param>
        public static void ExportExcel <TBody, TBodyList>(string configFile, string tableId, string exportId, Stream stream, TBodyList tList,
                                                          DataValidatingHandler <TBody, TBodyList> dataValidater = null, ExtendDataWritingHandler <TBody, TBodyList> extendDataWriter = null, TableWritingHandler tableHeaderWriter = null,
                                                          TableWritingHandler tableFooterWriter = null, PageWritingHandler pageHeaderWriter = null, PageWritingHandler pageFooterWriter = null, GetValueHandler <TBody> getValueCallback = null)
            where TBody : class
            where TBodyList : class
        {
            NPOIExport <TBody, TBodyList> export = CreateNPOIExport <TBody, TBodyList>(configFile, tableId, exportId, dataValidater, extendDataWriter, tableHeaderWriter, tableFooterWriter, pageHeaderWriter, pageFooterWriter, getValueCallback, null);

            export.Export(stream, tList);
            export.Dispose();
        }
Example #16
0
        private static CSVExport <TBody, TBodyList> CreateCSVExport <TBody, TBodyList>(string configFile, string tableId, string exportId,
                                                                                       DataValidatingHandler <TBody, TBodyList> dataValidater, GetValueHandler <TBody> getValueCallback)
            where TBody : class
            where TBodyList : class
        {
            CSVExport <TBody, TBodyList> export = new CSVExport <TBody, TBodyList>(configFile, tableId);

            export.ExportId = exportId;

            if (dataValidater != null)
            {
                export.SourceDataValidating += dataValidater;
            }

            if (getValueCallback != null)
            {
                export.GetValueCallback += getValueCallback;
            }

            return(export);
        }
Example #17
0
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="engine">ui engine for enumerating available fonts list.</param>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyFont(UIEngine engine, String defaultValue, String name, String group, String description, SetValueHandler<String> setter, GetValueHandler<String> getter)
     : base(defaultValue, name, group, description, setter, getter)
 {
     this.engine = engine;
     this.ControlType = TextBox.TypeName;
 }
Example #18
0
        private protected override void InitializeByValue(PropertyInfo propertyInfo, XBindingFlags flags)
        {
            base.InitializeByValue(propertyInfo, flags);

            if ((flags & XBindingFlags.RWAutoPropertyDirectRW) != 0 /* || !VersionDifferences.IsSupportEmit */)
            {
                if (TypeHelper.IsAutoProperty(propertyInfo, out var fieldInfo) && fieldInfo != null)
                {
                    try
                    {
                        var offset = TypeHelper.OffsetOf(fieldInfo);

                        _get = (obj) => Underlying.AddByteOffset(ref TypeHelper.Unbox <TValue>(obj), offset);
                        _set = (obj, value) => Underlying.AddByteOffset(ref TypeHelper.Unbox <TValue>(obj), offset) = value;

                        return;
                    }
                    catch
                    {
                    }
                }
            }

            if (_get is null)
            {
                var getMethod = propertyInfo.GetGetMethod((flags & XBindingFlags.NonPublic) != 0);

                if (getMethod != null)
                {
                    var __get = (GetValueHandler)Delegate.CreateDelegate(typeof(GetValueHandler), getMethod);

                    _get = VersionDifferences.IsSupportEmit ? __get : AOTCheck;

                    TValue AOTCheck(TClass obj)
                    {
                        try
                        {
                            return(__get(obj));
                        }
                        catch (ExecutionEngineException)
                        {
                            __get = AOT;

                            return(AOT(obj));
                        }
                        finally
                        {
                            _get = __get;
                        }
                    }

                    TValue AOT(TClass obj)
                    {
                        return((TValue)getMethod.Invoke(obj, null));
                    }
                }
            }

            if (_set is null)
            {
                var setMethod = propertyInfo.GetSetMethod((flags & XBindingFlags.NonPublic) != 0);

                if (setMethod != null)
                {
                    var __set = (SetValueHandler)Delegate.CreateDelegate(typeof(SetValueHandler), setMethod);

                    _set = VersionDifferences.IsSupportEmit ? __set : AOTCheck;

                    void AOTCheck(TClass obj, TValue value)
                    {
                        try
                        {
                            __set(obj, value);
                        }
                        catch (ExecutionEngineException)
                        {
                            __set = AOT;

                            AOT(obj, value);
                        }
                        finally
                        {
                            _set = __set;
                        }
                    }

                    void AOT(TClass obj, TValue value)
                    {
                        setMethod.Invoke(obj, new object[] { value });
                    }
                }
            }
        }
 public Condition1(ConditionHandler ch, GetValueHandler gvh)
 {
     this.ch  = ch;
     this.gvh = gvh;
 }
        /// <summary>
        /// マスタ参照値を取得する
        /// </summary>
        /// <param name="chkInfo">対象チェックリストグループ項目</param>
        /// <param name="conditions">マスタ参照条件項目リスト</param>
        /// <param name="getValueHandler">グループ項目の値を取得するデリゲート</param>
        /// <exception cref="DenshowBusinessException">EP092:接続失敗</exception>
        /// <exception cref="DenshowBusinessException">EP090:SQL文不正</exception>
        /// <returns></returns>
        public string GetReference(ChecklistInfo chkInfo, List <MasterReference> conditions, GetValueHandler getValueHandler)
        {
            // 値取得メソッドを登録する
            getValuePrivateHander = getValue;

            try
            {
                this.getValueHandler = getValueHandler;
                this.cmdParamters    = new List <OdbcParameter>();
                string sql = string.Empty;

                // 選択入力の場合
                if (string.IsNullOrEmpty(chkInfo.Query))
                {
                    sql = this.createQuery(chkInfo.TableName, chkInfo.ReferenceColumn, conditions);
                }

                // 直接入力の場合
                else
                {
                    sql = this.createQuery(chkInfo.ClId, chkInfo.Query);
                }

                // クエリーの実行
                string connString = Utility.CreateConnectionString(chkInfo.DataSourceName);
                using (OdbcConnection conn = new OdbcConnection(connString))
                {
                    try
                    {
                        conn.Open();
                    }
                    catch (OdbcException ex)
                    {
                        //接続失敗時、EP092例外をThrowする
                        throw new DenshowBusinessException(Message.EP092, ex);
                    }
                    using (var cmd = conn.CreateCommand())
                    {
                        cmd.CommandText = sql;
                        cmd.CommandType = System.Data.CommandType.Text;
                        foreach (OdbcParameter param in this.cmdParamters)
                        {
                            cmd.Parameters.Add(param);
                        }
                        using (OdbcDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                //参照データが存在する場合、一件目を取得する
                                return(convertResultValue(reader.GetValue(0)));
                            }
                            else
                            {
                                //参照データが存在しない場合
                                throw new DenshowBusinessException(Message.EP090);
                            }
                        }
                    }
                }
            }
            catch (DenshowBusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new DenshowBusinessException(Message.EP090, ex);
            }
        }
 internal ExtendedPropertyInfo(PropertyInfo propertyInfo, GetValueHandler getValueHandler, SetValueHandler setValueHandler, GetQualifiedNameHandler qualifiedNameHandler, WorkflowMarkupSerializationManager manager) : this(propertyInfo, getValueHandler, setValueHandler, qualifiedNameHandler)
 {
     this.manager = manager;
 }
Example #22
0
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyImage(String currentValue, String name, String group, String description, SetValueHandler<String> setter, GetValueHandler<String> getter)
     : base(currentValue, name, group, description, setter, getter)
 {
     this.ControlType = FilePicker.TypeName;
 }
Example #23
0
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyImage(String currentValue, String name, String group, String description, SetValueHandler <String> setter, GetValueHandler <String> getter) : base(currentValue, name, group, description, setter, getter)
 {
     this.ControlType = FilePicker.TypeName;
 }
Example #24
0
 public PropertyColor(Color defaultValue, String name, String group, String description, SetValueHandler <Color> setter, GetValueHandler <Color> getter) : base(defaultValue, name, group, description, setter, getter, "colorPicker")
 {
 }
Example #25
0
 /// <summary>
 /// Get indexer value from cache
 /// </summary>
 /// <param name="name"></param>
 /// <param name="getValue"></param>
 /// <returns></returns>
 protected object GetIndexerFromCache(string name, GetValueHandler getValue)
 {
     return GetFromCache("this." + name, getValue);
 }
 internal ExtendedPropertyInfo(PropertyInfo propertyInfo, GetValueHandler getValueHandler, SetValueHandler setValueHandler, GetQualifiedNameHandler qualifiedNameHandler, WorkflowMarkupSerializationManager manager)
     : this(propertyInfo, getValueHandler, setValueHandler, qualifiedNameHandler)
 {
     this.manager = manager;
 }
Example #27
0
        public static void FillExcel <TBody, TBodyList, THeader>(string configFile, string tableId, string exportId, string templateFile, Stream targetStream, TBodyList tList, THeader tHeader, GetValueHandler <object> getHeaderValueCallback = null)
            where TBody : class
            where TBodyList : class
        {
            NPOIExport <TBody, TBodyList> export = CreateNPOIExport <TBody, TBodyList>(configFile, tableId, exportId, null, null, null, null, null, null, null, getHeaderValueCallback);

            export.Fill(templateFile, targetStream, tList, tHeader);
            export.Dispose();
        }
Example #28
0
        public static void ExportCSV <TBody, TBodyList>(string configFile, string tableId, string exportId, Stream targetStream, TBodyList tList,
                                                        DataValidatingHandler <TBody, TBodyList> dataValidater = null, GetValueHandler <TBody> getValueCallback = null)
            where TBody : class
            where TBodyList : class
        {
            CSVExport <TBody, TBodyList> export = CreateCSVExport <TBody, TBodyList>(configFile, tableId, exportId, dataValidater, getValueCallback);

            export.Export(targetStream, tList);
            export.Dispose();
        }
Example #29
0
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyInteger(int defaultValue, String name, String group, String description, SetValueHandler <int> setter, GetValueHandler <int> getter) :  base(defaultValue, name, group, description, setter, getter, TextBox.TypeName)
 {
 }
Example #30
0
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyList(ListType defaultValue, String name, String group, String description, SetValueHandler <ListType> setter, GetValueHandler <ListType> getter) : base(defaultValue, name, group, description, setter, getter, ComboBox.TypeName)
 {
 }
Example #31
0
        /// <summary>
        /// Get from cache
        /// </summary>
        /// <param name="name"></param>
        /// <param name="getValue"></param>
        /// <returns></returns>
        protected object GetFromCache(string name, GetValueHandler getValue)
        {
            object obj;
            if (_cache.TryGetValue(name, out obj))
            {
                return obj;
            }

            if (getValue != null)
            {
                obj = getValue.Invoke();

                _cache[name] = obj;
            }

            return obj;
        }
Example #32
0
 /// <summary>
 /// Constructs property object.
 /// </summary>
 /// <param name="engine">ui engine for enumerating available fonts list.</param>
 /// <param name="defaultValue">default value.</param>
 /// <param name="name">property name.</param>
 /// <param name="group">propertry group.</param>
 /// <param name="description">property description.</param>
 /// <param name="setter">property setter function.</param>
 /// <param name="getter">property getter function.</param>
 public PropertyFont(UIEngine engine, String defaultValue, String name, String group, String description, SetValueHandler <String> setter, GetValueHandler <String> getter) : base(defaultValue, name, group, description, setter, getter)
 {
     this.engine      = engine;
     this.ControlType = TextBox.TypeName;
 }
Example #33
0
        public static T GetValue <T>(string section, string key, bool isRequired, T defaultValue, GetValueHandler <T> handler)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }

            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            if (!isRequired && defaultValue == null)
            {
                throw new ArgumentException("Parameter 'defaultValue' can not be null when parameter 'isRequired' == false");
            }

            string strValue = RetrieveString(section, key);

            if (strValue == null)
            {
                if (isRequired)
                {
                    throw new ConfigMissingKeyException(section, key);
                }
                return(defaultValue);
            }

            try
            {
                return(handler(strValue));
            }
            catch (ConfigInvalidValueException exc)
            {
                throw new ConfigInvalidValueException(section, key, exc.Type);
            }
        }
Example #34
0
 public virtual string GetValue(object row)
 {
     return(GetValueHandler?.Invoke(row) ?? (row as ExportDataRow)?.GetValue(ColumnName));
 }
 internal ExtendedPropertyInfo(PropertyInfo propertyInfo, GetValueHandler getValueHandler)
 {
     this.realPropertyInfo = propertyInfo;
     this.OnGetValue = getValueHandler;
 }
Example #36
0
        private static NPOIExport <TBody, TBodyList> CreateNPOIExport <TBody, TBodyList>(string configFile, string tableId, string exportId,
                                                                                         DataValidatingHandler <TBody, TBodyList> dataValidater, ExtendDataWritingHandler <TBody, TBodyList> extendDataWriter, TableWritingHandler tableHeaderWriter,
                                                                                         TableWritingHandler tableFooterWriter, PageWritingHandler pageHeaderWriter, PageWritingHandler pageFooterWriter, GetValueHandler <TBody> getValueCallback, GetValueHandler <object> getHeaderValueCallback)
            where TBody : class
            where TBodyList : class
        {
            NPOIExport <TBody, TBodyList> export = new NPOIExport <TBody, TBodyList>(configFile, tableId);

            export.ExportId = exportId;

            if (dataValidater != null)
            {
                export.SourceDataValidating += dataValidater;
            }

            if (extendDataWriter != null)
            {
                export.ExtendDataWriting += extendDataWriter;
            }

            if (tableHeaderWriter != null)
            {
                export.TableHeaderWriting += tableHeaderWriter;
            }

            if (tableFooterWriter != null)
            {
                export.TableFooterWriting += tableFooterWriter;
            }

            if (pageHeaderWriter != null)
            {
                export.PageHeaderWriting += pageHeaderWriter;
            }

            if (pageFooterWriter != null)
            {
                export.PageFooterWriting += pageFooterWriter;
            }

            if (getValueCallback != null)
            {
                export.GetValueCallback += getValueCallback;
            }

            if (getHeaderValueCallback != null)
            {
                export.GetHeaderValueCallback += getHeaderValueCallback;
            }

            return(export);
        }
Example #37
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="expression">計算式</param>
 /// <param name="expressType">計算式の種別</param>
 /// <param name="getValueHandler">計算式の項目IDで値を取得するデリゲート</param>
 public ExpressionChecker(string expression, ExpressType expressType, GetValueHandler getValueHandler)
 {
     this.expression      = expression;
     this.expressType     = expressType;
     this.getValueHandler = getValueHandler;
 }