コード例 #1
0
            /// <summary>
            /// Create for ExpandoObject <br />
            /// 为 ExpandoObject 创建对象访问器
            /// </summary>
            /// <param name="initialValues"></param>
            /// <param name="repeatable"></param>
            /// <param name="strictMode"></param>
            /// <returns></returns>
            public static IObjectVisitor CreateForExpandoObject(IDictionary <string, object> initialValues, bool repeatable = RpMode.REPEATABLE, bool strictMode = StMode.NORMALE)
            {
                var type    = typeof(ExpandoObject);
                var options = ObjectVisitor.FillWith(AlgorithmKind.Precision, repeatable, strictMode);
                var handler = (ExpandoObjectSlimObjectCaller)DynamicServiceTypeHelper.Create(type);

                return(new FutureInstanceVisitor(handler, type, options, initialValues));
            }
コード例 #2
0
            /// <summary>
            /// Create for ExpandoObject <br />
            /// 为 ExpandoObject 创建对象访问器
            /// </summary>
            /// <param name="instance"></param>
            /// <param name="repeatable"></param>
            /// <param name="strictMode"></param>
            /// <returns></returns>
            public static IObjectVisitor CreateForExpandoObject(ExpandoObject instance, bool repeatable = RpMode.REPEATABLE, bool strictMode = StMode.NORMALE)
            {
                var type    = typeof(ExpandoObject);
                var options = ObjectVisitor.FillWith(AlgorithmKind.Precision, repeatable, strictMode);
                var handler = ((ExpandoObjectSlimObjectCaller)DynamicServiceTypeHelper.Create(type)).AndSetExpandoObject(instance);

                return(new InstanceVisitor(handler, type, options));
            }
コード例 #3
0
            /// <summary>
            /// Create for ExpandoObject <br />
            /// 为 DynamicObject 创建对象访问器
            /// </summary>
            /// <param name="type"></param>
            /// <param name="initialValues"></param>
            /// <param name="repeatable"></param>
            /// <param name="strictMode"></param>
            /// <returns></returns>
            public static IObjectVisitor CreateForDynamicObject(Type type, IDictionary <string, object> initialValues, bool repeatable = RpMode.REPEATABLE, bool strictMode = StMode.NORMALE)
            {
                var options = ObjectVisitor.FillWith(AlgorithmKind.Precision, repeatable, strictMode);
                var handler = DynamicServiceTypeHelper.Create(type);

                if (type.IsAbstract && type.IsSealed)
                {
                    return(new StaticTypeObjectVisitor(handler, type, options));
                }
                return(new FutureInstanceVisitor(handler, type, options, initialValues));
            }
コード例 #4
0
            /// <summary>
            /// Create for ExpandoObject <br />
            /// 为 DynamicObject 创建对象访问器
            /// </summary>
            /// <param name="repeatable"></param>
            /// <param name="strictMode"></param>
            /// <typeparam name="T"></typeparam>
            /// <returns></returns>
            public static IObjectVisitor CreateForDynamicObject <T>(bool repeatable = RpMode.REPEATABLE, bool strictMode = StMode.NORMALE)
                where T : DynamicObject, new()
            {
                var options = ObjectVisitor.FillWith(AlgorithmKind.Precision, repeatable, strictMode);
                var handler = DynamicServiceTypeHelper.Create <T>();
                var type    = typeof(T);

                if (type.IsAbstract && type.IsSealed)
                {
                    return(new StaticTypeObjectVisitor <T>(handler, options));
                }
                return(new FutureInstanceVisitor <T>(handler, options));
            }