示例#1
0
 public override void Init(PipelineContext ctx, XmlNode node)
 {
     base.Init(ctx, node, Encoding.Default);
     maxToRead = node.ReadInt("@maxread", int.MaxValue);
     mode      = node.ReadEnum <_Mode>("@mode", _Mode.values);
     lenient   = node.ReadBool("@lenient", false);
 }
示例#2
0
        public MailReporter(XmlNode node)
        {
            String[] to = node.ReadStr("@to").Split(';');

            MailTo = new MailAddress[to.Length];
            for (int i = 0; i < to.Length; i++)
            {
                MailTo[i] = new MailAddress(to[i]);
            }

            String from = node.ReadStr("@from", null);

            MailFrom = from == null ? new MailAddress(MailTo[0].Address, "Noreply") : new MailAddress(from);

            MailSubject = node.ReadStr("@subject", "[Import {1}] {2}");
            MailServer  = node.ReadStr("@server");
            int ix = MailServer.IndexOf(':');

            if (ix < 0)
            {
                Port = 25;
            }
            else
            {
                Port       = Invariant.ToInt32(MailServer.Substring(ix + 1));
                MailServer = MailServer.Substring(0, ix);
            }
            Mode = node.ReadEnum("@mode", _Mode.Errors);
        }
示例#3
0
        private void SetMode(_Mode mode)
        {
            if (mode != _Mode.mode_Move)
            {
                selected.Clear();
            }

            cur_mode = mode;
            toolStripStatusLabel1.Text = "mode: " + cur_mode.ToString();
            pictureBox1.Invalidate();
        }
        public BankTransection(_Mode mode, string ledgerID, string ledgerName)
        {
            InitializeComponent();
            mMode              = mode;
            mLedgerID          = ledgerID;
            lblBankLedger.Text = ledgerName;
            GenerateSlNo();
            switch (mMode)
            {
            case _Mode.Deposit:
                rbtnDeposit.Checked = true;
                break;

            case _Mode.Withdrawal:
                rbtnWithdrawal.Checked = true;
                break;

            default:
                break;
            }
            cmbCashLedger.ADDCashLedgers();
        }
        /// <summary>
        /// Sets up a drop-down menu to allow file-system selection.
        /// </summary>
        private void _Setup(string Path, ToolStripMenuItem Item, _Mode Mode, Action<string> OnSelect)
        {
            if (Mode == _Mode.Save)
            {
                ToolStripTextBox textbox = new ToolStripTextBox();
                Item.DropDownItems.Add(textbox);
                textbox.ToolTipText = "Type a file name here. Press Enter to save, or Control + Enter to make a new folder.";
                textbox.KeyDown += delegate(object sender, KeyEventArgs e)
                {
                    if (e.KeyCode == Keys.Enter)
                    {
                        if (e.Control)
                        {
                            string dirname = textbox.Text;
                            string dirpath = Path + System.IO.Path.DirectorySeparatorChar + dirname;
                            Directory.CreateDirectory(dirpath);
                            ToolStripMenuItem item = new ToolStripMenuItem(dirname);
                            this._Setup(dirpath, item, _Mode.Save, OnSelect);
                            Item.DropDownItems.Insert(1, item);
                            textbox.Clear();
                        }
                        else
                        {
                            this.HideDropDown();
                            OnSelect(Path + System.IO.Path.DirectorySeparatorChar + textbox.Text + this.Extension);
                        }
                    }
                };

                Item.DropDownOpening += delegate
                {
                    this._Populate(Path, Item, Mode, OnSelect);
                };
                Item.DropDownClosed += delegate
                {
                    textbox.Clear();
                    Item.DropDownItems.Clear();
                    Item.DropDownItems.Add(textbox);
                };
            }
            else
            {
                ToolStripMenuItem dummy = new ToolStripMenuItem("(Nothing Here)");
                dummy.Enabled = false;
                Item.DropDownItems.Add(dummy);
                Item.DropDownOpening += delegate
                {
                    if (this._Populate(Path, Item, Mode, OnSelect))
                    {
                        Item.DropDownItems.Remove(dummy);
                    }
                };
                Item.DropDownClosed += delegate
                {
                    Item.DropDownItems.Clear();
                    Item.DropDownItems.Add(dummy);
                };
            }
        }
 /// <summary>
 /// Recursively a drop-down menu item with files from the given directory.
 /// </summary>
 private bool _Populate(string Path, ToolStripMenuItem Item, _Mode Mode, Action<string> OnSelect)
 {
     if (Directory.Exists(Path))
     {
         bool has = false;
         foreach (string file in System.IO.Directory.GetFiles(Path))
         {
             if (System.IO.Path.GetExtension(file) == this.Extension)
             {
                 string path = file;
                 ToolStripItem item = Item.DropDownItems.Add(System.IO.Path.GetFileNameWithoutExtension(path));
                 item.Click += delegate
                 {
                     this.HideDropDown();
                     OnSelect(path);
                 };
                 has = true;
             }
         }
         foreach (string directory in System.IO.Directory.GetDirectories(Path))
         {
             string path = directory;
             ToolStripMenuItem item = new ToolStripMenuItem(System.IO.Path.GetFileName(path));
             Item.DropDownItems.Add(item);
             if (Mode == _Mode.Delete) item.Click += delegate
             {
                 this.HideDropDown();
                 OnSelect(path);
             };
             this._Setup(path, item, Mode, OnSelect);
             has = true;
         }
         return has;
     }
     else
     {
         Directory.CreateDirectory(Path);
         return false;
     }
 }
示例#7
0
        private void 打开tbl_Click(object sender, EventArgs e)
        {
            // try
            {
                OpenFileDialog ofd = new OpenFileDialog();
                ofd.FileName = "Data.TBL";
                ofd.Filter   = "AC4 and AC0 TBL(*.tbl)|*.tbl|all file(*.*)|*.*";
                if (!ofd.ShowDialog().Equals(DialogResult.OK))
                {
                    return;
                }
                cdpfilename = System.IO.Path.GetDirectoryName(ofd.FileName) + "\\" + System.IO.Path.GetFileNameWithoutExtension(ofd.FileName) + ".cdp";
                if (!File.Exists(cdpfilename))
                {
                    mode        = _Mode.AC0;
                    cdpfilename = System.IO.Path.GetDirectoryName(ofd.FileName) + "\\" + System.IO.Path.GetFileNameWithoutExtension(ofd.FileName) + ".pac";
                    if (!File.Exists(cdpfilename))
                    {
                        MessageBox.Show("Cannot find data file");
                        return;
                    }
                }
                else
                {
                    mode = _Mode.AC4;
                }
                if (string.IsNullOrEmpty(cdpfilename))
                {
                    MessageBox.Show("Cannot open TBL file");
                    return;
                }
                FileStream   fs       = new FileStream(ofd.FileName, FileMode.Open);
                BinaryReader br       = new BinaryReader(fs);
                FileInfo     fileInfo = new FileInfo(ofd.FileName);
                FileStream   fsc      = new FileStream(cdpfilename, FileMode.Open);
                BinaryReader brc      = new BinaryReader(fsc);

                uint L1Size = (uint)fileInfo.Length / 8;
                if (mode == _Mode.AC0)
                {
                    L1Size = br.ReadUInt32();
                    br.ReadUInt32();
                }
                for (int i = 0; i < L1Size; i++)
                {
                    _L1 L1 = new _L1();
                    if (mode == _Mode.AC4)
                    {
                        L1.add = br.ReadUInt32() * 0x800;
                    }
                    else
                    {
                        L1.add = br.ReadUInt32();
                    }
                    L1.size = br.ReadUInt32();
                    TreeNode tn = new TreeNode();
                    tn.Name = L1.add.ToString();
                    tn.Text = string.Format("{0:X8}", L1.add);
                    tn.Tag  = L1;
                    uint subNum = CheckAddList(L1.add, L1.size, brc, tn);
                    if (subNum > 0)
                    {
                        tn.Text = string.Format("{0:X8} {1} {2}", L1.add, subNum, Notes.Get(L1.add));
                    }
                    treeView1.Nodes.Add(tn);
                    progressBar1.Value = i * 100 / (int)L1Size;
                }
                fs.Close();
                fsc.Close();
                progressBar1.Value = 100;
            }
            //catch (Exception error)
            //{
            //    MessageBox.Show(error.Message);
            //}
        }
示例#8
0
        public MethodProxy(MethodBase methodBase, object hardTarget)
        {
            this.methodBase = methodBase;
            this.hardTarget = hardTarget;

            parameters = methodBase.GetParameters();

            if (_length == null)
                _length = new Number(0) { attributes = JSObjectAttributesInternal.ReadOnly | JSObjectAttributesInternal.DoNotDelete | JSObjectAttributesInternal.DoNotEnum | JSObjectAttributesInternal.SystemObject };
            var pc = methodBase.GetCustomAttributes(typeof(Modules.ArgumentsLengthAttribute), false).ToArray();
            if (pc.Length != 0)
                _length.iValue = (pc[0] as Modules.ArgumentsLengthAttribute).Count;
            else
                _length.iValue = parameters.Length;

            for (int i = 0; i < parameters.Length; i++)
            {
                var t = parameters[i].GetCustomAttribute(typeof(Modules.ConvertValueAttribute)) as Modules.ConvertValueAttribute;
                if (t != null)
                {
                    if (paramsConverters == null)
                        paramsConverters = new Modules.ConvertValueAttribute[parameters.Length];
                    paramsConverters[i] = t;
                }
            }

            if (methodBase is MethodInfo)
            {
                var methodInfo = methodBase as MethodInfo;
                returnConverter = methodInfo.ReturnParameter.GetCustomAttribute(typeof(Modules.ConvertValueAttribute), false) as Modules.ConvertValueAttribute;

                forceInstance = methodBase.IsDefined(typeof(InstanceMemberAttribute), false);

                if (forceInstance)
                {
                    if (!methodInfo.IsStatic
                        || (parameters.Length == 0)
                        || (parameters.Length > 2)
                        || (parameters[0].ParameterType != typeof(JSObject))
                        || (parameters.Length > 1 && parameters[1].ParameterType != typeof(Arguments)))
                        throw new ArgumentException("Force-instance method \"" + methodBase + "\" have invalid signature");
                    raw = true;
                }

                if (!PartiallyTrusted
                    && !methodInfo.IsStatic
                    && (parameters.Length == 0 || (parameters.Length == 1 && parameters[0].ParameterType == typeof(Arguments)))
#if PORTABLE
 && !methodInfo.ReturnType.GetTypeInfo().IsValueType
 && !methodInfo.DeclaringType.GetTypeInfo().IsValueType)
#else
 && !methodInfo.ReturnType.IsValueType
 && !methodInfo.DeclaringType.IsValueType)
#endif
                {
                    var t = methodBase.GetCustomAttributes(typeof(AllowUnsafeCallAttribute), false).ToArray();
                    alternedTypes = new AllowUnsafeCallAttribute[t.Length];
                    for (var i = 0; i < t.Length; i++)
                        alternedTypes[i] = (AllowUnsafeCallAttribute)t[i];
                }

                #region Magic
                if (alternedTypes != null)
                {
                    if (methodInfo.ReturnType == typeof(void))
                    {
                        if (parameters.Length == 0)
                        {
#if PORTABLE
                            var methodDelegate = methodInfo.CreateDelegate(typeof(Action<>).MakeGenericType(methodBase.DeclaringType));
                            var handle = handleInfo.GetValue(methodDelegate);
                            var forceConverterConstructor = typeof(Action<object>).GetTypeInfo().DeclaredConstructors.First();
#else
                            var forceConverterConstructor = typeof(Action<object>).GetConstructors().First();
                            var handle = methodInfo.MethodHandle.GetFunctionPointer();
#endif
                            action1 = (Action<object>)forceConverterConstructor.Invoke(new object[] { null, (IntPtr)handle });
                            mode = _Mode.A1;
                        }
                        else // 1
                        {
#if PORTABLE
                            var methodDelegate = methodInfo.CreateDelegate(typeof(Action<,>).MakeGenericType(methodBase.DeclaringType, typeof(Arguments)));
                            var handle = handleInfo.GetValue(methodDelegate);
                            var forceConverterConstructor = typeof(Action<object, object>).GetTypeInfo().DeclaredConstructors.First();
#else
                            var forceConverterConstructor = typeof(Action<object, object>).GetConstructors().First();
                            var handle = methodInfo.MethodHandle.GetFunctionPointer();
#endif
                            action2 = (Action<object, object>)forceConverterConstructor.Invoke(new object[] { null, (IntPtr)handle });
                            mode = _Mode.A2;
                        }
                    }
                    else
                    {
                        if (parameters.Length == 0)
                        {
#if PORTABLE
                            var methodDelegate = methodInfo.CreateDelegate(typeof(Func<,>).MakeGenericType(methodBase.DeclaringType, methodInfo.ReturnType));
                            var handle = handleInfo.GetValue(methodDelegate);
                            var forceConverterConstructor = typeof(Func<object, object>).GetTypeInfo().DeclaredConstructors.First();
#else
                            var forceConverterConstructor = typeof(Func<object, object>).GetConstructors().First();
                            var handle = methodInfo.MethodHandle.GetFunctionPointer();
#endif
                            func1 = (Func<object, object>)forceConverterConstructor.Invoke(new object[] { getDummy(), (IntPtr)handle });
                            mode = _Mode.F1;

                        }
                        else // 1
                        {
#if PORTABLE
                            var methodDelegate = methodInfo.CreateDelegate(typeof(Func<,,>).MakeGenericType(methodBase.DeclaringType, typeof(Arguments), methodInfo.ReturnType));
                            var handle = handleInfo.GetValue(methodDelegate);
                            var forceConverterConstructor = typeof(Func<object, object, object>).GetTypeInfo().DeclaredConstructors.First();
#else
                            var forceConverterConstructor = typeof(Func<object, object, object>).GetConstructors().First();
                            var handle = methodInfo.MethodHandle.GetFunctionPointer();
#endif
                            func2 = (Func<object, object, object>)forceConverterConstructor.Invoke(new object[] { getDummy(), (IntPtr)handle });
                            mode = _Mode.F2;
                        }
                    }
                    raw = true;
                    return; // больше ничего не требуется, будет вызывать через этот путь
                }
                #endregion
#if PORTABLE
                makeMethodOverExpression(methodInfo);
#else
                makeMethodOverEmit(methodInfo);
#endif
            }
            else if (methodBase is ConstructorInfo)
            {
                makeConstructorOverExpression(methodBase as ConstructorInfo);
            }
            else
                throw new NotImplementedException();
        }