public PropertyValidateFacetViaMethod(MethodInfo method, ISpecification holder, ILogger <PropertyValidateFacetViaMethod> logger)
     : base(holder)
 {
     this.method    = method;
     this.logger    = logger;
     methodDelegate = LogNull(DelegateUtils.CreateDelegate(method), logger);
 }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            string fileName = DelegateUtils.GetVirtualPath() + @"Template\task.tplt";
            string content  = fileMgr.Load(fileName);

            ContentTextBox.Text = content;
        }
 public TitleFacetViaToStringMethod(MethodInfo maskMethod, ISpecification holder, ILogger <TitleFacetViaToStringMethod> logger)
     : base(holder)
 {
     this.maskMethod = maskMethod;
     this.logger     = logger;
     maskDelegate    = maskMethod == null ? null : LogNull(DelegateUtils.CreateDelegate(maskMethod), logger);
 }
 public HideForContextFacet(MethodInfo method, ISpecification holder, ILogger <HideForContextFacet> logger)
     : base(typeof(IHideForContextFacet), holder)
 {
     this.method    = method;
     this.logger    = logger;
     methodDelegate = LogNull(DelegateUtils.CreateDelegate(method), logger);
 }
 public ActionValidationFacet(MethodInfo method, ISpecification holder, ILogger <ActionValidationFacet> logger)
     : base(typeof(IActionValidationFacet), holder)
 {
     this.method    = method;
     this.logger    = logger;
     methodDelegate = LogNull(DelegateUtils.CreateDelegate(method), logger);
 }
Example #6
0
        void IoServiceSupport.FireSessionCreated(IoSession session)
        {
            if (session.Service is IoConnector)
            {
                // If the first connector session, fire a virtual service activation event.
                Boolean firstSession = _managedSessions.IsEmpty;
                if (firstSession)
                {
                    ((IoServiceSupport)this).FireServiceActivated();
                }
            }

            // If already registered, ignore.
            if (!_managedSessions.TryAdd(session.Id, session))
            {
                return;
            }

            // Fire session events.
            IoFilterChain filterChain = session.FilterChain;

            filterChain.FireSessionCreated();
            filterChain.FireSessionOpened();

            if (_hasHandler)
            {
                DelegateUtils.SafeInvoke(SessionCreated, this, new IoSessionEventArgs(session));
            }
        }
 public OnPersistingErrorCallbackFacetViaMethod(MethodInfo method, ISpecification holder, ILogger <OnPersistingErrorCallbackFacetViaMethod> logger)
     : base(holder)
 {
     this.method    = method;
     this.logger    = logger;
     methodDelegate = LogNull(DelegateUtils.CreateDelegate(method), logger);
 }
 public ActionDefaultsFacetViaMethod(MethodInfo method, ISpecification holder, ILogger <ActionDefaultsFacetViaMethod> logger)
     : base(holder)
 {
     this.method    = method;
     this.logger    = logger;
     MethodDelegate = LogNull(DelegateUtils.CreateDelegate(method), logger);
 }
Example #9
0
 public AutoCompleteFacet(MethodInfo autoCompleteMethod, int pageSize, int minLength, ISpecification holder)
     : this(holder) {
     method         = autoCompleteMethod;
     PageSize       = pageSize == 0 ? DefaultPageSize : pageSize;
     MinLength      = minLength;
     methodDelegate = DelegateUtils.CreateDelegate(method);
 }
Example #10
0
 public IconFacetViaMethod(MethodInfo method, ISpecification holder, string iconName)
     : base(holder)
 {
     this.method    = method;
     this.iconName  = iconName;
     methodDelegate = DelegateUtils.CreateDelegate(method);
 }
Example #11
0
 public PropertySetterFacetViaModifyMethod(MethodInfo method, string name, ISpecification holder)
     : base(holder)
 {
     this.method    = method;
     methodDelegate = DelegateUtils.CreateDelegate(method);
     PropertyName   = name;
 }
 public PropertySetterFacetViaModifyMethod(MethodInfo method, string name, ISpecification holder, ILogger <PropertySetterFacetViaModifyMethod> logger)
     : base(holder)
 {
     this.method    = method;
     this.logger    = logger;
     methodDelegate = LogNull(DelegateUtils.CreateDelegate(method), logger);
     PropertyName   = name;
 }
 public IconFacetViaMethod(MethodInfo method, ISpecification holder, string iconName, ILogger <IconFacetViaMethod> logger)
     : base(holder)
 {
     this.method    = method;
     this.iconName  = iconName;
     this.logger    = logger;
     methodDelegate = LogNull(DelegateUtils.CreateDelegate(method), logger);
 }
        public void Save(string path, string content)
        {
            FileStream   fileStream   = new FileStream(DelegateUtils.GetVirtualPath() + path, FileMode.Create);
            StreamWriter streamWriter = new StreamWriter(fileStream);

            streamWriter.Write(content);
            streamWriter.Close();
        }
 public AutoCompleteFacet(MethodInfo autoCompleteMethod, int pageSize, int minLength, ISpecification holder, ILogger <AutoCompleteFacet> logger)
     : this(holder) {
     method         = autoCompleteMethod;
     this.logger    = logger;
     PageSize       = pageSize == 0 ? DefaultPageSize : pageSize;
     MinLength      = minLength;
     methodDelegate = LogNull(DelegateUtils.CreateDelegate(method), logger);
 }
Example #16
0
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (isFinish == false)
     {
         isFinish = true;
         DelegateUtils.broadcast("OnNewAbility");
     }
 }
Example #17
0
        public PropertyChoicesFacetx(MethodInfo optionsMethod, Tuple <string, IObjectSpecImmutable>[] parameterNamesAndTypes, ISpecification holder)
            : base(typeof(IPropertyChoicesFacet), holder)
        {
            method = optionsMethod;

            this.parameterNamesAndTypes = parameterNamesAndTypes;
            parameterNames = parameterNamesAndTypes.Select(pnt => pnt.Item1).ToArray();
            methodDelegate = DelegateUtils.CreateDelegate(method);
        }
Example #18
0
        public void GetFriendlyName_AnonymousLambda()
        {
            Action <int> dlg = x => {
                this.ToString();
            };
            string name = DelegateUtils.GetFriendlyName(dlg);

            Assert.IsTrue(name.StartsWith("DelegateUtilsTests."));
        }
        private static string Load(string path)
        {
            StreamReader streamReader = new StreamReader(DelegateUtils.GetVirtualPath() + path, System.Text.Encoding.Default);
            string       result       = streamReader.ReadToEnd();

            streamReader.Close();

            return(result);
        }
Example #20
0
    protected override void Initialization()
    {
        base.Initialization();

        DelegateUtils.addListener("OnNewAbility", () =>
        {
            maxAbility++;
        });
    }
Example #21
0
 void IoServiceSupport.FireServiceDeactivated()
 {
     if (Interlocked.CompareExchange(ref _active, 0, 1) == 0)
     {
         // The instance is already desactivated
         return;
     }
     DelegateUtils.SafeInvoke(Deactivated, this);
     DisconnectSessions();
 }
 public ActionChoicesFacetViaMethod(MethodInfo choicesMethod, Tuple <string, IObjectSpecImmutable>[] parameterNamesAndTypes, Type choicesType, ISpecification holder, bool isMultiple = false)
     : base(holder)
 {
     this.choicesMethod     = choicesMethod;
     this.choicesType       = choicesType;
     IsMultiple             = isMultiple;
     ParameterNamesAndTypes = parameterNamesAndTypes;
     parameterNames         = parameterNamesAndTypes.Select(pnt => pnt.Item1).ToArray();
     choicesDelegate        = DelegateUtils.CreateDelegate(choicesMethod);
 }
 public ActionInvocationFacetViaMethod(MethodInfo method, ITypeSpecImmutable onType, IObjectSpecImmutable returnType, IObjectSpecImmutable elementType, ISpecification holder, bool isQueryOnly, ILogger <ActionInvocationFacetViaMethod> logger)
     : base(holder)
 {
     this.logger    = logger;
     ActionMethod   = method;
     paramCount     = method.GetParameters().Length;
     OnType         = onType;
     ReturnType     = returnType;
     ElementType    = elementType;
     IsQueryOnly    = isQueryOnly;
     ActionDelegate = LogNull(DelegateUtils.CreateDelegate(ActionMethod), logger);
 }
Example #24
0
        private FastCall(Type delegateType, MethodInfo method)
        {
            if (delegateType == null)
            {
                throw new ArgumentNullException("method");
            }
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            this.fn = DelegateUtils.CreateDelegate(delegateType, method, true);
        }
Example #25
0
 void IoServiceSupport.FireServiceActivated()
 {
     if (Interlocked.CompareExchange(ref _active, 1, 0) > 0)
     {
         // The instance is already active
         return;
     }
     _activationTime      = DateTime.Now;
     _stats.LastReadTime  = _activationTime;
     _stats.LastWriteTime = _activationTime;
     _stats.LastThroughputCalculationTime = _activationTime;
     DelegateUtils.SafeInvoke(Activated, this);
 }
Example #26
0
    private void OnEnable()
    {
        _shooting = false;

        DelegateUtils.ClearDelegate(OnBulletDestroy);

        // Clear all delegates in OnBulletDestroy
        if (OnBulletDestroy != null)
        {
            var del = OnBulletDestroy.GetInvocationList();

            for (int i = 0; i < del.Length; i++)
            {
                OnBulletDestroy -= del[i] as System.Action <JIBulletController>;
            }
        }
    }
        public ActionInvocationFacetViaMethod(MethodInfo method, ITypeSpecImmutable onType, IObjectSpecImmutable returnType, IObjectSpecImmutable elementType, ISpecification holder, bool isQueryOnly)
            : base(holder)
        {
            actionMethod     = method;
            paramCount       = method.GetParameters().Length;
            this.onType      = onType;
            this.returnType  = returnType;
            this.elementType = elementType;
            this.isQueryOnly = isQueryOnly;

            try {
                actionDelegate = DelegateUtils.CreateDelegate(actionMethod);
            }
            catch (Exception e) {
                Log.WarnFormat("Failed to get Delegate for {0}:{1} reason {2}", onType, method, e.Message);
            }
        }
Example #28
0
        private void ComplieFile()
        {
            try
            {
                this.SaveFile();
                //this.SaveNpcDef();

                System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();
                System.Diagnostics.Process          Proc = new System.Diagnostics.Process();
                Info.FileName  = DelegateUtils.GetVirtualPath() + @"Gen_File\make.bat";
                Info.Arguments = DelegateUtils.GetVirtualPath() + @"Gen_File, " + this.FileName;
                Proc           = System.Diagnostics.Process.Start(Info);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #29
0
        private Func <DynamicOperations, CallSiteBinder, object, object[], object> GetInvoker(int paramCount)
        {
            Func <DynamicOperations, CallSiteBinder, object, object[], object> invoker;

            lock (_invokers) {
                if (!_invokers.TryGetValue(paramCount, out invoker))
                {
                    ParameterExpression dynOps   = Expression.Parameter(typeof(DynamicOperations));
                    ParameterExpression callInfo = Expression.Parameter(typeof(CallSiteBinder));
                    ParameterExpression target   = Expression.Parameter(typeof(object));
                    ParameterExpression args     = Expression.Parameter(typeof(object[]));
                    Type funcType                = DelegateUtils.GetObjectCallSiteDelegateType(paramCount);
                    ParameterExpression site     = Expression.Parameter(typeof(CallSite <>).MakeGenericType(funcType));
                    Expression[]        siteArgs = new Expression[paramCount + 2];
                    siteArgs[0] = site;
                    siteArgs[1] = target;
                    for (int i = 0; i < paramCount; i++)
                    {
                        siteArgs[i + 2] = Expression.ArrayIndex(args, Expression.Constant(i));
                    }

                    var getOrCreateSiteFunc = new Func <CallSiteBinder, CallSite <Func <object> > >(GetOrCreateSite <Func <object> >).Method.GetGenericMethodDefinition();
                    _invokers[paramCount] = invoker = Expression.Lambda <Func <DynamicOperations, CallSiteBinder, object, object[], object> >(
                        Expression.Block(
                            new[] { site },
                            Expression.Assign(
                                site,
                                Expression.Call(dynOps, getOrCreateSiteFunc.MakeGenericMethod(funcType), callInfo)
                                ),
                            Expression.Invoke(
                                Expression.Field(
                                    site,
                                    site.Type.GetField("Target")
                                    ),
                                siteArgs
                                )
                            ),
                        new[] { dynOps, callInfo, target, args }
                        ).Compile();
                }
            }
            return(invoker);
        }
Example #30
0
        void IoServiceSupport.FireSessionCreated(IoSession session)
        {
            // If already registered, ignore.
            if (!_managedSessions.TryAdd(session.Id, session))
            {
                return;
            }

            // Fire session events.
            IoFilterChain filterChain = session.FilterChain;

            filterChain.FireSessionCreated();
            filterChain.FireSessionOpened();

            if (_hasHandler)
            {
                DelegateUtils.SafeInvoke(SessionCreated, this, new IoSessionEventArgs(session));
            }
        }