Ejemplo n.º 1
0
        public TestCaller()
        {
            string temp = "Hello";

            Dict = new Dictionary <string, Action <CallModel, object> >();
            Type type = typeof(CallModel);

            CallerManagement.AddType(type);
            DictHandler      = DictOperator.CreateFromType(type);
            FuzzyDictHandler = FuzzyDictOperator.CreateFromType(type);
            HashDictHandler  = HashDictOperator.CreateFromType(type);
            LinkHandler      = LinkOperator.CreateFromType(type);
            FuzzyLinkHandler = FuzzyLinkOperator.CreateFromType(type);
            HashLinkHandler  = HashLinkOperator.CreateFromType(type);
            Model            = new CallModel();
            Dynamic          = new CallModel();
            DictModel        = new CallModel();
            DictHandler.New();
            FuzzyDictHandler.New();
            HashDictHandler.New();
            LinkHandler.New();
            FuzzyLinkHandler.New();
            HashLinkHandler.New();
            Dict["Name"] = NDelegate.DefaultDomain().Action <CallModel, object>("arg1.Name=(string)arg2;");
        }
Ejemplo n.º 2
0
 public TestCaller()
 {
     NatashaInitializer.InitializeAndPreheating();
     string temp = "Hello";
     Dict = new Dictionary<string, Action<CallModel, object>>();
     Type type = typeof(CallModel);
     PrecisionDict = PrecisionDictOperator.CreateFromType(type);
     FuzzyDict = FuzzyDictOperator.CreateFromType(type);
     HashDict = HashDictOperator.CreateFromType(type);
     //LinkHandler = LinkOperator.CreateFromType(type);
     //FuzzyLinkHandler = FuzzyLinkOperator.CreateFromType(type);
     //HashLinkHandler = HashLinkOperator.CreateFromType(type);
     Model = new CallModel();
     Dynamic = new CallModel();
     DictModel = new CallModel();
     PrecisionDict.New();
     FuzzyDict.New();
     HashDict.New();
     Dict["Name"] = NDelegate.DefaultDomain().Action<CallModel, object>("arg1.Name=(string)arg2;");
     for (int i = 0; i < 3000; i++)
     {
         Model.Name = "Hello";
         Dynamic.Name = "Hello";
         Dict["Name"](DictModel, "Hello");
         PrecisionDict.Set("Name", "Hello");
     }
 }
Ejemplo n.º 3
0
        public static object GetInstance(this DictBase handler)
        {
            // Get 'Instance' Field and touch from 'Instance' Field by reflection.
            //
            var fieldInfo = handler.GetType().GetField("Instance", BindingFlags.Instance | BindingFlags.Public);

            return(fieldInfo?.GetValue(handler));
        }
Ejemplo n.º 4
0
        public static TObject GetInstance <TObject>(this DictBase <TObject> handler)
        {
            // Get 'Instance' Field and touch from 'Instance' Field by reflection.
            //
            var fieldInfo = typeof(DictBase <TObject>)
                            .GetField("Instance", BindingFlags.Instance | BindingFlags.Public);

            return((TObject)fieldInfo?.GetValue(handler));
        }
Ejemplo n.º 5
0
        public StaticTypeLeoVisitor(DictBase handler, Type targetType, AlgorithmKind kind, bool liteMode = false, bool strictMode = false)
        {
            _handler       = handler ?? throw new ArgumentNullException(nameof(handler));
            _algorithmKind = kind;

            SourceType = targetType ?? throw new ArgumentNullException(nameof(targetType));
            LiteMode   = liteMode;

            _lazyMemberHandler = MemberHandler.Lazy(() => new MemberHandler(_handler, SourceType), liteMode);
            _validationContext = strictMode
                ? new CorrectContext(this, true)
                : null;
        }
Ejemplo n.º 6
0
        public InstanceVisitor(DictBase <T> handler, T instance, AlgorithmKind kind, bool repeatable,
                               bool liteMode = false, bool strictMode = false)
        {
            _handler       = handler ?? throw new ArgumentNullException(nameof(handler));
            _instance      = instance;
            _algorithmKind = kind;

            _handler.SetInstance(_instance);

            SourceType = typeof(T);
            GenericHistoricalContext = repeatable
                ? new HistoricalContext <T>(kind)
                : null;
            LiteMode = liteMode;

            _lazyMemberHandler = MemberHandler.Lazy(() => new MemberHandler(_handler, SourceType), liteMode);
            _validationContext = strictMode
                ? new CorrectContext <T>(this, true)
                : null;
        }
Ejemplo n.º 7
0
        public FutureInstanceVisitor(DictBase handler, Type sourceType, AlgorithmKind kind, bool repeatable,
                                     IDictionary <string, object> initialValues = null, bool liteMode = false, bool strictMode = false)
        {
            _handler       = handler ?? throw new ArgumentNullException(nameof(handler));
            _sourceType    = sourceType ?? throw new ArgumentNullException(nameof(sourceType));
            _algorithmKind = kind;

            _handler.New();
            NormalHistoricalContext = repeatable
                ? new HistoricalContext(sourceType, kind)
                : null;
            LiteMode = liteMode;

            _lazyMemberHandler = MemberHandler.Lazy(() => new MemberHandler(_handler, _sourceType), liteMode);
            _validationContext = strictMode
                ? new CorrectContext(this, true)
                : null;

            if (initialValues != null)
            {
                SetValue(initialValues);
            }
        }
Ejemplo n.º 8
0
 public static DictBase <TObj> With <TObj>(this DictBase handler)
 {
     return((DictBase <TObj>)handler);
 }
Ejemplo n.º 9
0
 public MemberHandler(DictBase handler, Type sourceType)
 {
     _handler     = handler ?? throw new ArgumentNullException(nameof(handler));
     _sourceType  = sourceType ?? throw new ArgumentNullException(nameof(sourceType));
     _memberNames = handler.GetMemberNames().ToList();
 }