Esempio n. 1
0
        public static IWebSecurityAddIn Create(WebSecurityAddInData.WebSecurityAddInsRow addIn, StateBag viewStateContext, string languageCode)
        {
            IWebSecurityAddIn @in = null;

            try
            {
                if (addIn.TypeAssembly == null)
                {
                    throw new InvalidCastException();
                }
                @in           = (IWebSecurityAddIn)Assembly.Load(addIn.TypeAssembly).CreateInstance(addIn.TypeNameSpace);
                @in.AddInDbId = addIn.WebSecurityAddInId;
                @in.Disabled  = addIn.Disabled;
                string str = ResourceManager.GetString(addIn.Description);
                @in.Description  = (str == null) ? addIn.Description : str;
                @in.SurveyId     = addIn.SurveyID;
                @in.ViewState    = viewStateContext;
                @in.Order        = addIn.AddInOrder;
                @in.LanguageCode = languageCode;
///             return @in;
            }
            catch (NullReferenceException)
            {
                throw new InvalidCastException("specfied type " + addIn.TypeNameSpace + " could not be found in the specifed assembly " + addIn.TypeAssembly);
            }
            catch (InvalidCastException)
            {
                throw new InvalidCastException("specfied type " + addIn.TypeNameSpace + " must implement the IWebSecurityAddIn interface");
            }
            return(@in);
        }
Esempio n. 2
0
        private void AddAddinButton_Click(object sender, System.EventArgs e)
        {
            new SecurityAddIn().AddSecurityAddInToSurvey(SurveyId,
                                                         int.Parse(SecurityAddInDropDownList.SelectedValue), _addInOrder);

            WebSecurityAddInData.WebSecurityAddInsRow addInRow =
                (WebSecurityAddInData.WebSecurityAddInsRow) new SecurityAddIns().GetAddInById(SurveyId, int.Parse(SecurityAddInDropDownList.SelectedValue)).WebSecurityAddIns.Rows[0];
            try
            {
                IWebSecurityAddIn addedAddin = WebSecurityAddInFactory.Create(addInRow, ViewState, null);
                addedAddin.InitOnSurveyAddition();
            }
            catch (Exception)
            {
                new SecurityAddIn().DeleteWebSecurityAddIn(SurveyId, int.Parse(SecurityAddInDropDownList.SelectedValue));
                throw;
            }
            UINavigator.NavigateToSurveySecurity(SurveyId, MenuIndex);
        }