Пример #1
0
        /// <summary>
        ///     Get FileChange for a previewNode.
        ///     After user clicks a preview node, the preview dialog will show
        ///     content of the file this change will be applied to.  And the content
        ///     of that file will contains all the selected changes to that file and
        ///     will show user the version with changes already applied.
        /// </summary>
        /// <param name="previewNode"></param>
        /// <returns>
        ///     FileChange related to this node.  If this change is atomic change,
        ///     or the node is file node, it will return the FileChange object for
        ///     the file it is changing.
        ///     If the node is a group node, it will return null.
        /// </returns>
        public FileChange GetFileChange(PreviewChangesNode previewNode)
        {
            ArgumentValidation.CheckForNullReference(previewNode, "previewNode");

            string fileName       = null;
            var    changeProposal = previewNode.ChangeProposal;

            if (changeProposal != null)
            {
                // Preview Node for atomic change
                fileName = changeProposal.FileName;
            }
            else
            {
                // Look at direct child, if that child is an atomic change,
                // then get filename for it, otherwise, just leave the filename as null
                if (previewNode.ChildList != null &&
                    previewNode.ChildList.Count > 0)
                {
                    var proposal = previewNode.ChildList[0].ChangeProposal;
                    if (proposal != null)
                    {
                        fileName = proposal.FileName;
                    }
                }
            }

            FileChange fileChange = null;

            if (fileName != null)
            {
                _fileChanges.TryGetValue(fileName, out fileChange);
            }
            return(fileChange);
        }
Пример #2
0
        /// <summary>
        /// <para>Initializes the provider with a <see cref="SecurityConfigurationView"/>.</para>
        /// </summary>
        /// <param name="configurationView">
        /// <para>A <see cref="SecurityConfigurationView"/> object.</para>
        /// </param>
        public override void Initialize(ConfigurationView configurationView)
        {
            ArgumentValidation.CheckForNullReference(configurationView, "configurationView");
            ArgumentValidation.CheckExpectedType(configurationView, typeof(SecurityConfigurationView));

            this.securityConfigurationView = (SecurityConfigurationView)configurationView;
        }
Пример #3
0
        /// <summary>
        ///     Add a ChangeProposal to change list of a related PreviewGroup.
        /// </summary>
        /// <param name="previewGroup">Preview group this change will be added to.</param>
        /// <param name="change">The ChangeProposal.</param>
        internal void AddChange(RefactoringPreviewGroup previewGroup, ChangeProposal change)
        {
            ArgumentValidation.CheckForNullReference(previewGroup, "previewGroup");
            ArgumentValidation.CheckForNullReference(change, "change");

            // First check if changes for same location exists or not, if exist, we will not add it anymore
            var exist = false;

            foreach (var existingChanges in _changeList.Values)
            {
                if (existingChanges.Contains(change))
                {
                    exist = true;
                    break;
                }
            }
            if (!exist)
            {
                HashSet <ChangeProposal> changes = null;
                if (_changeList.TryGetValue(previewGroup, out changes) == false)
                {
                    // There is no change list for this preview group,
                    // create one and add to the dictionary.
                    changes = new HashSet <ChangeProposal>();
                    _changeList.Add(previewGroup, changes);
                }
                // Add change to the change list.
                changes.Add(change);
            }
        }
Пример #4
0
        /// <summary>
        /// <para>Create a <see cref="NpgSqlCommandWrapper"/> for a stored procedure.</para>
        /// </summary>
        /// <param name="storedProcedureName"><para>The name of the stored procedure.</para></param>
        /// <returns><para>The <see cref="NpgSqlCommandWrapper"/> for the stored procedure.</para></returns>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="storedProcedureName"/> can not be <see langword="null"/> (Nothing in Visual Basic).</para>
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <para><paramref name="storedProcedureName"/> hast not been initialized.</para>
        /// </exception>
        public override DBCommandWrapper GetStoredProcCommandWrapper(string storedProcedureName)
        {
            ArgumentValidation.CheckForNullReference(storedProcedureName, "storedProcedureName");
            ArgumentValidation.CheckForEmptyString(storedProcedureName, "storedProcedureName");

            return(new NpgSqlCommandWrapper(storedProcedureName, CommandType.StoredProcedure, ParameterToken));
        }
Пример #5
0
        /// <summary>
        /// <para>When overridden by a class, initializes the provider with a <see cref="ExceptionHandlingConfigurationView"/>.</para>
        /// </summary>
        /// <param name="configurationView">
        /// <para>A <see cref="ExceptionHandlingConfigurationView"/> object.</para>
        /// </param>
        public override void Initialize(ConfigurationView configurationView)
        {
            ArgumentValidation.CheckForNullReference(configurationView, "configurationView");
            ArgumentValidation.CheckExpectedType(configurationView, typeof(ExceptionHandlingConfigurationView));

            exceptionHandlingConfigurationView = (ExceptionHandlingConfigurationView)configurationView;
        }
Пример #6
0
        public override void Validate(object instance, PropertyInfo propertyInfo, ValidationErrorCollection errors)
        {
            ArgumentValidation.CheckForNullReference(instance, "instance");
            ArgumentValidation.CheckForNullReference(propertyInfo, "propertyInfo");
            ArgumentValidation.CheckForNullReference(errors, "errors");

            object propertyValue = propertyInfo.GetValue(instance, null);
            Regex  expression    = null;

            if (this.compiledRegexType != null)
            {
                if (this.optionsSpecified)
                {
                    expression = (Regex)Activator.CreateInstance(this.compiledRegexType, new object[] { this.options });
                }
                else
                {
                    expression = (Regex)Activator.CreateInstance(this.compiledRegexType);
                }
            }
            else if (this.optionsSpecified)
            {
                expression = new Regex(this.pattern, this.options);
            }
            else
            {
                expression = new Regex(this.pattern);
            }

            if (!expression.IsMatch((string)propertyValue))
            {
                errors.Add(instance, propertyInfo.Name, SR.RegExErrorMessage(propertyValue.ToString()));
            }
        }
Пример #7
0
        /// <summary>
        /// <para>Adds an <see cref="InstanceData"/> into the collection.</para>
        /// </summary>
        /// <param name="instanceData">
        /// <para>The <see cref="InstanceData"/> to add. The value can not be a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </param>
        /// <remarks>
        /// <para>If a reference already exists in the collection by <seealso cref="InstanceData.Name"/>, it will be replaced with the new reference.</para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="instanceData"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// <para><seealso cref="InstanceData.Name"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        public void Add(InstanceData instanceData)
        {
            ArgumentValidation.CheckForNullReference(instanceData, "instanceData");
            ArgumentValidation.CheckForInvalidNullNameReference(instanceData.Name, typeof(InstanceData).FullName);

            BaseAdd(instanceData.Name, instanceData);
        }
Пример #8
0
        /// <summary>
        /// Used by a test step to log a test error, this will be logged in the test output.
        /// </summary>
        /// <param name="text">The text to be written to the output.</param>
        /// <param name="args">Array of arguments to be formatted with the text.</param>
        ///
        /// <remarks>
        /// The following example demonstrates how to use the method:
        ///
        /// <code escaped="true">
        ///	public void Execute(XmlNode testConfig, Context context)
        ///	{
        ///
        ///		...
        ///		context.Log(LogLevel.ERROR,  "The request failed with the folowing error: {0}", requestErrorText );
        ///	</code>
        ///
        ///	</remarks>
        public void LogError(string text, params object[] args)
        {
            ArgumentValidation.CheckForNullReference(text, "text");
            ArgumentValidation.CheckForNullReference(args, "args");

            _logger.Log(LogLevel.ERROR, text, args);
        }
Пример #9
0
        /// <summary>
        /// Used to substitute wild cards into strings.
        /// </summary>
        ///
        /// <remarks>
        /// The following wild cards are suported:
        ///
        /// <code escaped="true">
        /// %DateTime% - will replace the wild card with the current date time in the format HHmmss-ddMMyyyy
        /// %ServerName% - will replace the wild card with the name of the server BizUnit is being executed on
        /// %Guid% - will be replaced by a new Guid
        ///	</code>
        ///
        ///	</remarks>
        public string SubstituteWildCards(string rawString)
        {
            ArgumentValidation.CheckForNullReference(rawString, "rawString");

            string result = rawString;

            if (result.Contains(ContextConstaints.DateTime))
            {
                result = result.Replace(ContextConstaints.DateTime, System.DateTime.Now.ToString("HHmmss-ddMMyyyy"));
            }

            if (result.Contains(ContextConstaints.DateTimeIso8601))
            {
                result = result.Replace(ContextConstaints.DateTimeIso8601, System.DateTime.Now.ToString("s"));
            }

            if (result.Contains(ContextConstaints.ServerName))
            {
                result = result.Replace(ContextConstaints.ServerName, Environment.MachineName);
            }

            if (result.Contains(ContextConstaints.Guid))
            {
                result = result.Replace(ContextConstaints.Guid, System.Guid.NewGuid().ToString());
            }

            if (result.Contains(ContextConstaints.TestStartDateTime))
            {
                var testStartTime = (DateTime)_context[TestRunner.BizUnitTestCaseStartTime];
                result = result.Replace(ContextConstaints.TestStartDateTime, testStartTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            }

            return(result);
        }
Пример #10
0
        /// <summary>
        /// Used by a test step to log Xml test Data, this will be logged in the test output.
        /// </summary>
        /// <param name="description">The description of what the data being logged is.</param>
        /// <param name="data">The data to log.</param>
        ///
        /// <remarks>
        /// The following example demonstrates how to use the method:
        ///
        /// <code escaped="true">
        ///	public void Execute(XmlNode testConfig, Context context)
        ///	{
        ///
        ///		...
        ///		context.LogXmlData( "HTTP Response:", data );
        ///	</code>
        ///
        ///	</remarks>
        public void LogXmlData(string description, string data)
        {
            ArgumentValidation.CheckForNullReference(description, "description");
            ArgumentValidation.CheckForNullReference(data, "data");

            _logger.LogXmlData(description, data);
        }
Пример #11
0
        /// <summary>
        /// Used by a test step to log a test warnings, this will be logged in the test output.
        /// </summary>
        /// <param name="text">The text to be written to the output.</param>
        /// <param name="args">Array of arguments to be formatted with the text.</param>
        ///
        /// <remarks>
        /// The following example demonstrates how to use the method:
        ///
        /// <code escaped="true">
        ///	public void Execute(XmlNode testConfig, Context context)
        ///	{
        ///
        ///		...
        ///		context.LogWarning( "The FILE was found, poll nummber: {0}, number of retries remaining: {1}", count, retriesLeft );
        ///	</code>
        ///
        ///	</remarks>
        public void LogWarning(string text, params object[] args)
        {
            ArgumentValidation.CheckForNullReference(text, "text");
            ArgumentValidation.CheckForNullReference(args, "args");

            _logger.Log(LogLevel.WARNING, string.Format(text, args));
        }
Пример #12
0
        /// <summary>
        /// <para>Validate the ranige data for the given <paramref name="instance"/> and the <paramref name="propertyInfo"/>.</para>
        /// </summary>
        /// <param name="instance">
        /// <para>The instance to validate.</para>
        /// </param>
        /// <param name="propertyInfo">
        /// <para>The property contaning the value to validate.</para>
        /// </param>
        /// <param name="errors">
        /// <para>The collection to add any errors that occur durring the validation.</para>
        /// </param>
        public override void Validate(object instance, PropertyInfo propertyInfo, ValidationErrorCollection errors)
        {
            ArgumentValidation.CheckForNullReference(instance, "instance");
            ArgumentValidation.CheckForNullReference(propertyInfo, "propertyInfo");
            ArgumentValidation.CheckForNullReference(errors, "errors");

            object propertyValue = propertyInfo.GetValue(instance, null);

            if (propertyValue == null)
            {
                return;
            }
            IComparable compareToObject            = (IComparable)propertyValue;
            int         lowerBoundGreaterThanValue = this.lowerBound.CompareTo(compareToObject);
            int         upperBoundLessThanValue    = this.upperBound.CompareTo(compareToObject);

            if ((lowerBoundGreaterThanValue == 0) && (this.lowerBoundType == RangeBoundaryType.Exclusive))
            {
                errors.Add(instance, propertyInfo.Name, SR.ValueNotInRangeErrorMessage(propertyInfo.Name));
            }
            if (lowerBoundGreaterThanValue > 0)
            {
                errors.Add(instance, propertyInfo.Name, SR.ValueNotInRangeErrorMessage(propertyInfo.Name));
            }

            if ((upperBoundLessThanValue == 0) && (this.upperBoundType == RangeBoundaryType.Exclusive))
            {
                errors.Add(instance, propertyInfo.Name, SR.ValueNotInRangeErrorMessage(propertyInfo.Name));
            }
            if (upperBoundLessThanValue < 0)
            {
                errors.Add(instance, propertyInfo.Name, SR.ValueNotInRangeErrorMessage(propertyInfo.Name));
            }
        }
Пример #13
0
        /// <summary>
        /// <para>Construct an instance of a named configuration object by the <paramref name="type"/>.</para>
        /// </summary>
        /// <param name="configurationName">
        /// <para>The name of the configuration object.</para>
        /// </param>
        /// <param name="type"><para>The <see cref="Type"/> to create.</para></param>
        /// <returns>An instance of the type.</returns>
        protected virtual object CreateObject(string configurationName, Type type)
        {
            ArgumentValidation.CheckForNullReference(type, "type");
            ArgumentValidation.CheckForNullReference(configurationName, "configurationName");
            ArgumentValidation.CheckForEmptyString(configurationName, "configurationName");

            ConstructorInfo constructor = type.GetConstructor(new Type[] {});

            if (constructor == null)
            {
                throw new ConfigurationException(SR.ExceptionProviderMissingConstructor(type.FullName));
            }
            object createdObject = null;

            try
            {
                createdObject = constructor.Invoke(null);
            }
            catch (MethodAccessException ex)
            {
                throw new ConfigurationException(ex.Message, ex);
            }
            catch (TargetInvocationException ex)
            {
                throw new ConfigurationException(ex.Message, ex);
            }
            catch (TargetParameterCountException ex)
            {
                throw new ConfigurationException(ex.Message, ex);
            }
            return(createdObject);
        }
Пример #14
0
        /// <summary>
        /// <para>Load the configured protection mechanism for the section. This is the <see cref="KeyAlgorithmPairStorageProviderData"/> to load the <see cref="KeyAlgorithmPair"/>.</para>
        /// </summary>
        /// <param name="sectionName">
        /// <para>The name of the section to encrypt.</para>
        /// </param>
        /// <param name="context">
        /// <para>A <see cref="ConfigurationContext"/> object.</para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="context"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        /// <exception cref="ConfigurationException">
        /// <para>An error occured in configuration.</para>
        /// </exception>
        public void Load(ConfigurationContext context, string sectionName)
        {
            ArgumentValidation.CheckForNullReference(context, "context");
            ArgumentValidation.CheckForNullReference(sectionName, "sectionName");
            ArgumentValidation.CheckForEmptyString(sectionName, "sectionName");

            ConfigurationSettings    settings = context.GetMetaConfiguration();
            ConfigurationSectionData data     = settings.ConfigurationSections[sectionName];

            if (null == data)
            {
                InvalidSectionExceptionBuilder builder = new InvalidSectionExceptionBuilder(sectionName, context.ConfigurationFile);
                throw builder.ThrowException();
            }

            if ((null == settings.KeyAlgorithmPairStorageProviderData) && (data.Encrypt))
            {
                throw new ConfigurationException(SR.ExceptionNoKeyAlgorithmStorageProvider);
            }

            if (data.Encrypt)
            {
                SetDataToBeEncrypted(context);
            }
        }
Пример #15
0
        /// <summary>
        /// <para>Add menu items to the user interface.</para>
        /// </summary>
        /// <param name="menuContainerService">
        /// <para>The container to add the menu items.</para>
        /// </param>
        /// <remarks>
        /// <para>This is called by the framework when the context switches to this node.</para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="menuContainerService"/> can not be a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        public void AddMenuItems(IMenuContainerService menuContainerService)
        {
            ArgumentValidation.CheckForNullReference(menuContainerService, "containerService");

            currentContainerService = menuContainerService;
            OnAddMenuItems();
        }
Пример #16
0
        /// <summary>
        /// <para>
        /// Initialize a new instance of the <see cref="ConfigurationManager"/> class with a configuration file.
        /// </para>
        /// </summary>
        /// <param name="configurationFile">
        /// <para>
        /// The file where the configuration settings are defined.
        /// </para>
        /// </param>
        public ConfigurationBuilder(string configurationFile)
        {
            ArgumentValidation.CheckForNullReference(configurationFile, "configurationFile");
            ArgumentValidation.CheckForEmptyString(configurationFile, "configurationFile");

            LoadMetaConfiguration(configurationFile);
        }
Пример #17
0
        /// <summary>
        /// <para>Add a menu item to the user interface.</para>
        /// </summary>
        /// <param name="configurationMenuItem">
        /// <para>The <see cref="ConfigurationMenuItem"/> to add.</para>
        /// </param>
        protected void AddMenuItem(ConfigurationMenuItem configurationMenuItem)
        {
            ArgumentValidation.CheckForNullReference(configurationMenuItem, "configurationMenuItem");
            Debug.Assert(currentContainerService != null, "The currentContainerService should not be null");

            currentContainerService.MenuItems.Add(configurationMenuItem);
        }
        /// <summary>
        /// <para>Adds an <see cref="OraclePackageData"/> into the collection.</para>
        /// </summary>
        /// <param name="oraclePackageData">
        /// <para>The <see cref="OraclePackageData"/> to add. The value can not be a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </param>
        /// <remarks>
        /// <para>If a reference already exists in the collection by <seealso cref="OraclePackageData.Name"/>, it will be replaced with the new reference.</para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="oraclePackageData"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// <para><seealso cref="OraclePackageData.Name"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        public void Add(OraclePackageData oraclePackageData)
        {
            ArgumentValidation.CheckForNullReference(oraclePackageData, "oraclePackageData");
            ArgumentValidation.CheckForInvalidNullNameReference(oraclePackageData.Name, typeof(OraclePackageData).FullName);

            BaseAdd(oraclePackageData.Name, oraclePackageData);
        }
Пример #19
0
        private void LoadXamlTestCaseAndInit(TestCase testCase, TestGroupPhase phase, Context ctx)
        {
            ArgumentValidation.CheckForNullReference(testCase, "testCase");
            // ctx - optional

            if (null != ctx)
            {
                _context = ctx;
                _context.Initialize(this);
            }
            else
            {
                _context = new Context(this);
                _logger  = _context.Logger;
            }

            _xamlTestCase   = testCase;
            _testGroupPhase = phase;
            _testName       = testCase.Name;
            DateTime now = DateTime.Now;

            // Validate test case...
            testCase.Validate(_context);

            if (phase == TestGroupPhase.Unknown)
            {
                _logger.TestStart(_testName, now, GetUserName());
                _context.Add(BizUnitTestCaseStartTime, now, true);
            }
            else
            {
                _logger.TestGroupStart(testCase.Name, phase, now, GetUserName());
            }
        }
Пример #20
0
        /// <summary>
        /// Creates an <see cref="ExceptionPolicy"/> object from the configuration data associated with the specified name.
        /// </summary>
        /// <param name="policyName">
        /// <para>The name of the policy to create.</para>
        /// </param>
        /// <param name="exception">
        /// <para>The <see cref="Exception"/> used when creating the policy. It will be wrapped in a ? if the policy is not found.</para>
        /// </param>
        /// <returns>An <see cref="ExceptionPolicy"/>.</returns>
        public ExceptionPolicy CreateExceptionPolicy(string policyName, Exception exception)
        {
            ArgumentValidation.CheckForNullReference(exception, "exception");

            currentException = exception;
            return((ExceptionPolicy)CreateInstance(policyName));
        }
Пример #21
0
        /// <summary>
        /// <para>Create an <see cref="NpgSqlCommandWrapper"/> for a SQL query.</para>
        /// </summary>
        /// <param name="query"><para>The text of the query.</para></param>
        /// <returns><para>The <see cref="NpgSqlCommandWrapper"/> for the SQL query.</para></returns>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="query"/> can not be <see langword="null"/> (Nothing in Visual Basic).</para>
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <para><paramref name="query"/> hast not been initialized.</para>
        /// </exception>
        public override DBCommandWrapper GetSqlStringCommandWrapper(string query)
        {
            ArgumentValidation.CheckForNullReference(query, "query");
            ArgumentValidation.CheckForEmptyString(query, "query");

            return(new NpgSqlCommandWrapper(query, CommandType.Text, ParameterToken));
        }
Пример #22
0
        /// <summary>
        /// Initializes a new instance of a <see cref="TextFormatter"></see> with the given
        /// <see cref="TextFormatterData"></see> configuration data
        /// </summary>
        /// <param name="textFormatterData">
        /// <para>A <see cref="TextFormatterData"/> object.</para>
        /// </param>
        public TextFormatter(TextFormatterData textFormatterData)
        {
            ArgumentValidation.CheckForNullReference(textFormatterData, "textFormatterData");

            this.textFormatterData = textFormatterData;
            RegisterTemplate();
        }
Пример #23
0
        /// <summary>
        /// Used to add a test step to a test case at a specific stage of the test.
        /// </summary>
        ///
        /// <param name='testStep'>The test step to add to the test case.</param>
        /// <param name='stage'>The stage of the test case in which to add the test step</param>
        /// <param name='runConcurrently'>Specifies whether the test step
        /// should run concurrently to other test steps. Defaults to false if not specified.</param>
        /// <param name='failOnError'>Specifies whether the entire test case
        /// should fail if this individual test step fails, defaults to true if not specified.</param>
        public void AddTestStep(ITestStepOM testStep, TestStage stage, bool runConcurrently, bool failOnError)
        {
            ArgumentValidation.CheckForNullReference(testStep, "testStep");
            ArgumentValidation.CheckForNullReference(stage, "stage");

            AddTestStepInternal(new BizUnitTestStepWrapper(testStep, runConcurrently, failOnError), stage);
        }
Пример #24
0
        private static void CopyFileToBuffer(string sourceFilename, IVsTextLines buffer)
        {
            ArgumentValidation.CheckForEmptyString(sourceFilename, "sourceFileName");
            ArgumentValidation.CheckForNullReference(buffer, "buffer");

            var spanDst = GetBufferSpan(buffer);

            var pContent = IntPtr.Zero;

            try
            {
                var content = RdtManager.Instance.ReadFromFile(sourceFilename);
                pContent = Marshal.StringToHGlobalAuto(content);
                buffer.ReplaceLines(
                    spanDst.iStartLine, spanDst.iStartIndex,
                    spanDst.iEndLine, spanDst.iEndIndex, pContent, content.Length, new[] { new TextSpan() });
            }
            finally
            {
                if (pContent != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(pContent);
                }
            }
        }
Пример #25
0
        /// <summary>
        ///     Sort changes based on ChangeOffset
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private static SortedList <Position, TextChangeProposal> SortChanges(FileChange file)
        {
            ArgumentValidation.CheckForNullReference(file, "file");

            var sortedChanges = new SortedList <Position, TextChangeProposal>(new PositionComparer());

            foreach (var changeList in file.ChangeList.Values)
            {
                if (changeList != null)
                {
                    foreach (var change in changeList)
                    {
                        var textChange = change as TextChangeProposal;
                        if (textChange != null)
                        {
                            var currentPosition = new Position(textChange.StartLine, textChange.StartColumn);
                            if (!sortedChanges.ContainsKey(currentPosition))
                            {
                                sortedChanges.Add(currentPosition, textChange);
                            }
                        }
                    }
                }
            }
            return(sortedChanges);
        }
Пример #26
0
        /// <summary>
        ///     Get entire TextLines buffer as a TextSpan
        /// </summary>
        /// <param name="pBuffer"></param>
        /// <returns></returns>
        private static TextSpan GetBufferSpan(IVsTextLines textBuffer)
        {
            ArgumentValidation.CheckForNullReference(textBuffer, "textBuffer");

            var lineCount = 0;
            var charCount = 0;

            // Get line count for the whole buffer.
            var result = textBuffer.GetLineCount(out lineCount);

            if (result == VSConstants.S_OK &&
                lineCount > 0)
            {
                // Get char count for last line.
                result = textBuffer.GetLengthOfLine(lineCount - 1, out charCount);
                if (result != VSConstants.S_OK)
                {
                    charCount = 0;
                }
            }
            else
            {
                lineCount = 0;
            }

            // Create a TextSpan from begin to end of the text buffer.
            var span = new TextSpan();

            span.iStartLine  = 0;
            span.iStartIndex = 0;
            span.iEndLine    = lineCount - 1 > 0 ? lineCount - 1 : 0;
            span.iEndIndex   = charCount > 0 ? charCount : 0;
            return(span);
        }
Пример #27
0
        public SqlQuery(object[] objParameters)
        {
            ArgumentValidation.CheckForNullReference(objParameters, "objParameters");
            if (objParameters.Length == 0)
            {
                throw new ArgumentException(
                          "The array objParams must be contain at least one object, i.e. the raw SQL Query text");
            }

            _rawSqlQuery = Convert.ToString(objParameters[0]);
            if (objParameters.Length > 1)
            {
                _objParams = new object[objParameters.Length - 1];
                int dst = 0;
                for (int src = 1; src < objParameters.Length; src++)
                {
                    if (objParameters[src].GetType() == typeof(DateTime))
                    {
                        // Convert to SQL Datetime
                        _objParams[dst++] = ((DateTime)objParameters[src]).ToString("yyyy-MM-dd HH:mm:ss.fff");
                    }
                    else
                    {
                        _objParams[dst++] = objParameters[src];
                    }
                }
            }
        }
Пример #28
0
        /// <summary>
        /// Persist a user's profile to the database.
        /// </summary>
        /// <param name="identity">An authenticated user's identity with a username that
        /// matches a user in the Identity table.</param>
        /// <param name="profile">Object that represents the user's profile.
        /// A single primitive, serializable object, or a dictionary of primitives and objects.</param>
        public void SetProfile(IIdentity identity, object profile)
        {
            ArgumentValidation.CheckForNullReference(identity, "identity");
            ArgumentValidation.CheckForNullReference(profile, "profile");

            Data.Database securityDb = GetSecurityDatabase();

            string userName = identity.Name;

            using (IDbConnection connection = securityDb.GetConnection())
            {
                connection.Open();
                IDbTransaction transaction = connection.BeginTransaction();
                try
                {
                    DeleteProfile(userName, securityDb, transaction);
                    InsertProfile(userName, SerializeProfile(profile), securityDb, transaction);
                }
                catch (ArgumentException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    throw new InvalidOperationException(SR.SavingProfileException(userName), e);
                }
                transaction.Commit();
            }

            SecurityProfileSaveEvent.Fire(identity.Name);
        }
Пример #29
0
        /// <summary>
        ///     Save all dirty files.
        /// </summary>
        /// <param name="dirtyFiles">A list of dirty files to save.  These must be full path.</param>
        public void SaveDirtyFiles(IList <string> dirtyFiles)
        {
            ArgumentValidation.CheckForNullReference(dirtyFiles, "dirtyFiles");

            var rdt = _runningDocumentTable;

            var fileCount = dirtyFiles.Count;

            for (var fileIndex = 0; fileIndex < fileCount; fileIndex++)
            {
                var filePath = dirtyFiles[fileIndex];
                var docData  = GetDocData(filePath) as VsShell.IVsPersistDocData;
                if (docData != null)
                {
                    var    cookie = GetRdtCookie(filePath);
                    string newdoc;
                    int    cancelled;
                    NativeMethods.ThrowOnFailure(rdt.NotifyOnBeforeSave(cookie));
                    var result = docData.SaveDocData(VsShell.VSSAVEFLAGS.VSSAVE_Save, out newdoc, out cancelled);
                    if (result != VSConstants.S_OK ||
                        cancelled != 0)
                    {
                        throw new InvalidOperationException(
                                  string.Format(
                                      CultureInfo.CurrentCulture,
                                      Resources.Exception_FailedToSaveFile, filePath));
                    }
                    NativeMethods.ThrowOnFailure(rdt.NotifyOnAfterSave(cookie));
                }
            }
        }
        /// <summary>
        /// <para>Adds an <see cref="ConnectionStringData"/> into the collection.</para>
        /// </summary>
        /// <param name="connectionStringData">
        /// <para>The <see cref="ConnectionStringData"/> to add. The value can not be a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </param>
        /// <remarks>
        /// <para>If a reference already exists in the collection by <seealso cref="ConnectionStringData.Name"/>, it will be replaced with the new reference.</para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="connectionStringData"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// <para><seealso cref="ConnectionStringData.Name"/> is a <see langword="null"/> reference (Nothing in Visual Basic).</para>
        /// </exception>
        public void Add(ConnectionStringData connectionStringData)
        {
            ArgumentValidation.CheckForNullReference(connectionStringData, "connectionStringData");
            ArgumentValidation.CheckForInvalidNullNameReference(connectionStringData.Name, typeof(ConnectionStringData).FullName);

            BaseAdd(connectionStringData.Name, connectionStringData);
        }