Ejemplo n.º 1
0
 public void Add <TService, UImpl>(string serviceName, ObjectScope scope) where UImpl : TService
 {
     AddComponentLifeStyle(serviceName, typeof(TService), typeof(UImpl),
                           EnumAdapter.GetEnumValue <LifestyleType>(scope));
     //AddComponentWithLifestyle(serviceName, typeof (TService), typeof (UImpl),
     //                          EnumAdapter.GetEnumValue<LifestyleType>(scope));
 }
Ejemplo n.º 2
0
        private bool parseToFont(string fontstr, out string fontName, out float emSize, out FontStyle fontStyle)
        {
            bool success = true;

            string[] arrFont = fontstr.Split("^".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            string[] rgbs    = arrFont[0].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            if (rgbs.Length < 2)
            {
                fontName  = "";
                emSize    = 0;
                fontStyle = FontStyle.Regular;
            }
            else
            {
                fontName  = rgbs[0].Trim();
                fontStyle = FontStyle.Regular;
                if (!float.TryParse(rgbs[1].Trim(), out emSize))
                {
                    success = false;
                }
                if (rgbs.Length > 2)
                {
                    fontStyle = EnumAdapter.GetEnum <FontStyle>(rgbs[2].Trim());
                }
            }

            return(success);
        }
 public virtual bool IsValidPair(Type abstraction, Type implementation)
 {
     return(EnumAdapter.IsAdaptable(abstraction, implementation) &&
            abstraction.Name.Equals(implementation.Name) ||
            AbstractionToImplementationAdapter.IsAdaptable(abstraction, implementation) &&
            abstraction.Name.Length == implementation.Name.Length + 1 &&
            abstraction.Name[0] == 'I' &&
            abstraction.Name.Skip(1).SequenceEqual(implementation.Name));
 }
Ejemplo n.º 4
0
        private void frmSettings_Load(object sender, EventArgs e)
        {
            txtAuthEndPoint.Text       = INIAdapter.ReadValue(Common.INI_SECTION_WEB, Common.INI_KEY_AUTH_END_POINT, Common.INI_FILE_PATH);
            cbRemindType.DataSource    = EnumAdapter.ToListItem(typeof(RemindType)).ToList();
            cbRemindType.ValueMember   = "Value";
            cbRemindType.DisplayMember = "Text";
            string s = INIAdapter.ReadValue(Common.INI_SECTION_BIZ, Common.INI_KEY_REMIND_TYPE, Common.INI_FILE_PATH);

            cbRemindType.SelectedValue = Convert.ToInt32(INIAdapter.ReadValue(Common.INI_SECTION_BIZ, Common.INI_KEY_REMIND_TYPE, Common.INI_FILE_PATH));
        }
Ejemplo n.º 5
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //
            RemindType rt = EnumAdapter.GetEnum <RemindType>(e0571.web.core.Utils.TypeConverter.ChangeString(cbRemindType.SelectedValue));

            if (SectionBizSettingsSave != null)
            {
                SectionBizSettingsSave(this, new SectionBizSettingsSaveEventArgs {
                    Type = rt, YYRemindFlag = (chkPlayYY.Checked ? 1 : 0)
                });
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Registers this instance.
        /// </summary>
        public void Register(Component component)
        {
            IKernel kernel = Kernel;

            kernel.AddComponent(component.Name, component.Service, component.Impl,
                                EnumAdapter.GetEnumValue <LifestyleType>(component.Scope));


            IHandler handler = kernel.GetHandler(component.Name);

            handler.ComponentModel.LifestyleType = EnumAdapter.GetEnumValue <LifestyleType>(component.Scope);

            kernel.RegisterCustomDependencies(component.Name, component.Parameters);

            foreach (KeyValuePair <string, string> pair in component.References)
            {
                handler.ComponentModel.Parameters.Add(pair.Key, pair.Value);
            }
        }
Ejemplo n.º 7
0
        private void ReadSettings()
        {
            string strAssistToolbarFlag = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INT_KEY_ASSIST_TOOLBAR_FLAG, Common.INI_FILE_PATH);

            if (!string.IsNullOrEmpty(strAssistToolbarFlag))
            {
                assistToolbarState = EnumAdapter.GetEnum <CheckState>(strAssistToolbarFlag);
            }
            string strAssistToolbarPositionLast = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INT_KEY_ASSIST_TOOLBAR_POSITION_LAST, Common.INI_FILE_PATH);

            if (!string.IsNullOrEmpty(strAssistToolbarPositionLast))
            {
                string[] positions = strAssistToolbarPositionLast.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                pnlAssistToolbarContainer.Location = new Point(int.Parse(positions[0]), int.Parse(positions[1]));
            }
            else
            {
                pnlAssistToolbarContainer.Location = new Point(pnlMain.Width - pnlAssistToolbarContainer.Width, 0);
            }
        }
Ejemplo n.º 8
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            //
            string     authEndPoint = formatAuthEndPoint();
            RemindType rt           = EnumAdapter.GetEnum <RemindType>(e0571.web.core.Utils.TypeConverter.ChangeString(cbRemindType.SelectedValue));
            string     connectUrl   = authEndPoint + "/";

            HttpAdapter.optionsAsyncTo(connectUrl, new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) =>
            {
                if (ret != "ok")
                {
                    MessageBoxAdapter.ShowError("无效的认证节点");
                    return;
                }

                if (SectionWebSettingsSave != null)
                {
                    SectionWebSettingsSave(this, new SectionWebSettingsSaveEventArgs {
                        AuthEndPoint = authEndPoint
                    });
                }

                if (SectionBizSettingsSave != null)
                {
                    SectionBizSettingsSave(this, new SectionBizSettingsSaveEventArgs {
                        Type = rt, YYRemindFlag = (chkPlayYY.Checked ? 1 : 0)
                    });
                }

                this.DialogResult = DialogResult.OK;

                this.UIInvoke(() =>
                {
                    this.Close();
                });
            });
        }
Ejemplo n.º 9
0
 public void Test_EnumAdapter_WithNonEnumType()
 {
     string TargetEnumValue = EnumAdapter.GetEnumValue <string>(SourceEnum.VS2005);
 }
Ejemplo n.º 10
0
 public void Test_EnumAdapter_WithInvalidEnumValue()
 {
     TargetEnum TargetEnumValue = EnumAdapter.GetEnumValue <TargetEnum>(SourceEnum.Office2007);
 }
Ejemplo n.º 11
0
        public void Test_EnumAdapter_WithValidEnumValue()
        {
            TargetEnum TargetEnumValue = EnumAdapter.GetEnumValue <TargetEnum>(SourceEnum.VS2005);

            Assert.AreEqual(TargetEnum.VS2005, TargetEnumValue);
        }