コード例 #1
0
        }// ValidateData

        internal override bool ApplyData()
        {
            // Make sure this page has been displayed before we apply data to it
            if (m_dg != null)
            {
                // Let's build a binding policy structure
                BindingPolicy bp = new BindingPolicy();
                bp.scBaseVersion     = new StringCollection();
                bp.scRedirectVersion = new StringCollection();

                // Let's jump to a new cell, to make sure the current cell we
                // were editing has it's changes 'saved'
                m_dg.CurrentCell = new DataGridCell(0, 1);
                m_dg.CurrentCell = new DataGridCell(0, 0);


                // We need to do a try/catch block here since we getting the count of
                // rows from the data table isn't completely accurate, so we'll just loop
                // until the data grid throws us an exception about accessing an invalid row.
                int nRow = 0;

                while (nRow <= m_dt.Rows.Count)
                {
                    if (isValidRow(nRow))
                    {
                        bp.scBaseVersion.Add((String)m_dg[nRow, 0]);
                        bp.scRedirectVersion.Add((String)m_dg[nRow, 1]);
                    }
                    nRow++;
                }

                String sSetSettingString = "BindingPolicyFor" + m_bri.Name + "," + m_bri.PublicKeyToken;
                if (m_sConfigFile != null)
                {
                    sSetSettingString += "," + m_sConfigFile;
                }


                if (!CConfigStore.SetSetting(sSetSettingString, bp))
                {
                    return(false);
                }

                CNodeManager.GetNode(m_iCookie).RefreshResultView();

                return(true);
            }
            return(false);
        }// ApplyData
コード例 #2
0
        }// onDeleteEntireRow

        private void PutValuesinPage()
        {
            // Get info that we'll need from the node
            CNode node = CNodeManager.GetNode(m_iCookie);
            // This should be ok now, but if we need this functionality
            // off of different nodes.....
            CVersionPolicy vp = (CVersionPolicy)node;


            String sGetSettingString = "BindingPolicyFor" + m_bri.Name + "," + m_bri.PublicKeyToken;

            // If we are getting this from an App config file, let's add that info
            m_sConfigFile = vp.ConfigFile;

            if (m_sConfigFile != null)
            {
                sGetSettingString += "," + m_sConfigFile;
            }

            BindingPolicy bp = (BindingPolicy)CConfigStore.GetSetting(sGetSettingString);

            int iLen = bp.scBaseVersion.Count;

            for (int i = 0; i < iLen; i++)
            {
                DataRow newRow;
                newRow = m_dt.NewRow();
                newRow["Requested Version"] = bp.scBaseVersion[i];
                newRow["New Version"]       = bp.scRedirectVersion[i];
                m_dt.Rows.Add(newRow);
            }

            // We want to have at least 1 row
            while (m_dt.Rows.Count < 1)
            {
                DataRow newRow;
                newRow = m_dt.NewRow();
                newRow["Requested Version"] = "";
                newRow["New Version"]       = "";
                m_dt.Rows.Add(newRow);
            }
            m_dg.CurrentCell = new DataGridCell(iLen, 0);
        }// PutValuesinPage
コード例 #3
0
        }// isRepeatBindingRedirInfo

        internal override int Paste(IDataObject ido)
        {
            CDO cdo = (CDO)ido;
            BindingRedirInfo bri = new BindingRedirInfo();

            // See if this is coming from the Shared Assemblies node
            if (cdo.Node is CSharedAssemblies)
            {
                CSharedAssemblies shared = (CSharedAssemblies)(cdo.Node);
                if (cdo.Data is AssemInfo)
                {
                    AddAssemInfo((AssemInfo)cdo.Data);
                }
                // This is an array list... with bunches of stuff in it
                else
                {
                    ArrayList al = (ArrayList)cdo.Data;
                    for (int i = 0; i < al.Count; i++)
                    {
                        AddAssemInfo(shared.GetAssemInfo((int)al[i] - 1));
                    }
                }
            }
            else if (cdo.Node is CApplicationDepends)
            {
                CApplicationDepends appDepends = (CApplicationDepends)(cdo.Node);
                if (cdo.Data is int)
                {
                    AddAssemInfo(appDepends.GetAssemInfo((int)cdo.Data - 1));
                }
                // This is an array list... with bunches of stuff in it
                else
                {
                    ArrayList al = (ArrayList)cdo.Data;
                    for (int i = 0; i < al.Count; i++)
                    {
                        AddAssemInfo(appDepends.GetAssemInfo((int)al[i] - 1));
                    }
                }
            }
            // This is coming from another Version Policy Node
            // We'll copy over all the binding policy this node has
            else
            {
                ArrayList      alStuff = new ArrayList();
                CVersionPolicy verpol  = (CVersionPolicy)(cdo.Node);


                if (cdo.Data is BindingRedirInfo)
                {
                    alStuff.Add(cdo.Data);
                }
                else
                {
                    // Run through and change all the indexes to BindingRedirInfos
                    ArrayList alIndexes = (ArrayList)cdo.Data;
                    for (int i = 0; i < alIndexes.Count; i++)
                    {
                        alStuff.Add(verpol.GetBindRedirInfo((int)alIndexes[i] - 1));
                    }
                }

                bool fSkipWarningDialog = false;
                for (int i = 0; i < alStuff.Count; i++)
                {
                    bri = (BindingRedirInfo)alStuff[i];

                    // Let's see if we have this item
                    bool fHaveItem = isRepeatBindingRedirInfo(bri);

                    bool fAddItem = !fHaveItem;
                    if (fHaveItem && !fSkipWarningDialog)
                    {
                        String sMessageText = "";
                        if (alStuff.Count == 1)
                        {
                            sMessageText = String.Format(CResourceStore.GetString("CVersionPolicy:ConfigInfoExistsForOneAssem"), bri.Name);
                        }
                        else
                        {
                            sMessageText = CResourceStore.GetString("CVersionPolicy:ConfigInfoExists");
                        }

                        int hr = MessageBox(sMessageText,
                                            CResourceStore.GetString("CVersionPolicy:ConfigInfoExistsTitle"),
                                            MB.ICONQUESTION | MB.YESNO);
                        if (hr == MB.IDYES)
                        {
                            fAddItem = true;
                        }
                        fSkipWarningDialog = fAddItem;
                    }

                    if (fAddItem)
                    {
                        // Set up some strings we need
                        String sFirstPartOfBinding  = "BindingPolicyFor" + bri.Name + "," + bri.PublicKeyToken;
                        String sFirstPartOfCodebase = "CodeBasesFor" + bri.Name + "," + bri.PublicKeyToken;
                        String sFirstPartOfPubPol   = "PublisherPolicyFor" + bri.Name + "," + bri.PublicKeyToken;

                        // If we are getting and writing this to an App config file,
                        // let's add that info
                        String sSecondPartOnIncoming = "";
                        if (verpol.m_sConfigFile != null)
                        {
                            sSecondPartOnIncoming = "," + verpol.m_sConfigFile;
                        }

                        String sSecondPartOnDest = "";
                        if (m_sConfigFile != null)
                        {
                            sSecondPartOnDest += "," + m_sConfigFile;
                        }

                        AddConfiguredAssembly(bri);

                        //--------------------------------------------
                        // First, read the stuff from the config store
                        //--------------------------------------------
                        // First get the binding policy
                        String        sGetSettingString = sFirstPartOfBinding + sSecondPartOnIncoming;
                        BindingPolicy bp = (BindingPolicy)CConfigStore.GetSetting(sGetSettingString);

                        // Now get the codebase info
                        sGetSettingString = sFirstPartOfCodebase + sSecondPartOnIncoming;
                        CodebaseLocations cbl = (CodebaseLocations)CConfigStore.GetSetting(sGetSettingString);

                        sGetSettingString = sFirstPartOfPubPol + sSecondPartOnIncoming;
                        bool fPubPolicy = (bool)CConfigStore.GetSetting(sGetSettingString);


                        //---------------------------------------------
                        // Now let's write this stuff to our config file
                        //---------------------------------------------

                        // First write the binding policy
                        String sSetSettingString = sFirstPartOfBinding + sSecondPartOnDest;
                        if (!CConfigStore.SetSetting(sSetSettingString, bp))
                        {
                            return(HRESULT.S_FALSE);
                        }

                        // Now Set the codebase info
                        sSetSettingString = sFirstPartOfCodebase + sSecondPartOnDest;
                        if (!CConfigStore.SetSetting(sSetSettingString, cbl))
                        {
                            return(HRESULT.S_FALSE);
                        }

                        sSetSettingString = sFirstPartOfPubPol + sSecondPartOnDest;
                        if (!CConfigStore.SetSetting(sSetSettingString, fPubPolicy))
                        {
                            return(HRESULT.S_FALSE);
                        }
                    }
                } // for loop
            }     // coming from another version policy node


            return(HRESULT.S_OK);
        }// Paste