public void ShouldConvertToCSharpValue()
        {
            //Arrange
            var converter = new BooleanConverter();
            object value0;
            object value1;
            object value2;
            object value3;
            //Act
            bool success0 = converter.TryConvertToCSharpValue("0", out value0);
            bool success1 = converter.TryConvertToCSharpValue("1", out value1);
            bool success2 = converter.TryConvertToCSharpValue("False", out value2);
            bool success3 = converter.TryConvertToCSharpValue("True", out value3);

            //Assert
            Assert.IsTrue(success0);
            Assert.IsTrue(success1);
            Assert.IsTrue(success2);
            Assert.IsTrue(success3);
            Assert.IsFalse((bool)value0);
            Assert.IsTrue((bool)value1);
            Assert.IsFalse((bool)value2);
            Assert.IsTrue((bool)value3);

        }
예제 #2
0
        public void GetValue_InalidValue_ThrowsApplicationException()
        {
            BooleanConverter converter = new BooleanConverter("T", "F");

            Action action = ()=> converter.GetValue("True");

            Assert.Throws<ApplicationException>(action);
        }
예제 #3
0
        public void GetValue_WhenCalled_IsValid()
        {
            BooleanConverter converter = new BooleanConverter("T", "F");

            var trueResult = converter.GetValue("T");
            var falseResult = converter.GetValue("F");

            Assert.True(trueResult);
            Assert.False(falseResult);
        }
예제 #4
0
        public void GetString_WhenCalled_IsValid()
        {
            BooleanConverter converter = new BooleanConverter("T", "F");

            var trueResult = converter.GetString(true);
            var falseResult = converter.GetString(false);

            Assert.Equal("T", trueResult);
            Assert.Equal("F", falseResult);
        }
예제 #5
0
        public RequestQueryReqVM()
        {
            this.ReceiveUsers   = new List <UserInfo>();
            this.WebChannelList = CPApplication.Current.CurrentWebChannelList.ToList <UIWebChannel>();
            //修改UIWebChannelType.publicChennel 后放开
            //this.WebChannelList.Insert(0, new UIWebChannel { ChannelName = ResCommonEnum.Enum_All, ChannelType = UIWebChannelType.publicChennel });

            this.SellerTypeList = EnumConverter.GetKeyValuePairs <SellersType>(EnumConverter.EnumAppendItemType.All);

            this.YNList            = BooleanConverter.GetKeyValuePairs(EnumConverter.EnumAppendItemType.All);
            this.RequestStatusList = EnumConverter.GetKeyValuePairs <RMARequestStatus>(EnumConverter.EnumAppendItemType.All);
            this.ConfirmUsers      = new List <UserInfo>();
        }
예제 #6
0
        public void MethodParseFormattedValue()
        {
            DataGridViewCell c = new FormattedBaseCell();

            c.ValueType = typeof(bool);

            BooleanConverter bc = new BooleanConverter();
            StringConverter  sc = new StringConverter();

            object o = c.ParseFormattedValue("true", c.Style, sc, bc);

            Assert.AreEqual(true, (bool)o, "A1");
        }
예제 #7
0
        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <param name="sectionName">Name of the section.</param>
        /// <param name="keyName">Name of the key.</param>
        /// <param name="defaultValue">if set to <c>true</c> [default value].</param>
        /// <param name="booleanConverter">The boolean converter.</param>
        /// <returns></returns>
        public virtual bool GetValue(string sectionName, string keyName, bool defaultValue,
                                     BooleanConverter booleanConverter = null)
        {
            booleanConverter = booleanConverter ?? Settings.BooleanConverter;

            var booleanValue = GetRawValue <string>(sectionName, keyName, null);

            if (string.IsNullOrWhiteSpace(booleanValue))
            {
                SetValue(sectionName, keyName,
                         null == booleanConverter
                         // if some day Boolean.ToString(IFormatProvider) will work
                         // https://msdn.microsoft.com/en-us/library/s802ct92(v=vs.110).aspx#Anchor_1
                        ? defaultValue.ToString(Settings.Culture).ToLowerInvariant()
                        : booleanConverter.ConvertToString(defaultValue));
                return(defaultValue);
            }

#pragma warning disable IDE0046 // Convert to conditional expression
            foreach (var converter in YesNoBoolConverters)
            {
                if (converter.Yes.Equals(booleanValue.Trim(), StringComparison.InvariantCultureIgnoreCase) ||
                    converter.No.Equals(booleanValue.Trim(), StringComparison.InvariantCultureIgnoreCase))
                {
                    return(converter.Yes.Equals(booleanValue, StringComparison.InvariantCultureIgnoreCase));
                }
            }
#pragma warning restore IDE0046 // Convert to conditional expression

            if (bool.TryParse(booleanValue, out var parseBoolean))
            {
                return(parseBoolean);
            }

            // if some day Boolean.ToString(IFormatProvider) will work
            // https://msdn.microsoft.com/en-us/library/s802ct92(v=vs.110).aspx#Anchor_1
            if (true.ToString(Settings.Culture).ToLowerInvariant().Equals(booleanValue, StringComparison.InvariantCultureIgnoreCase))
            {
                return(true);
            }

            if (booleanConverter == null || !booleanConverter.CanConvertFrom(typeof(string)))
            {
                return(defaultValue);
            }

            var value = booleanConverter.ConvertFrom(booleanValue);
            return(value is bool convertedBoolean
                ? convertedBoolean
                : defaultValue);
        }
예제 #8
0
        private JsonFxAOT()
        {
            TypeConverter c;

            c          = new ArrayConverter();
            m_fakeFlag = c.Equals(c);
            //c = new BaseNumberConverter();
            //m_fakeFlag = c.Equals(c);
            c          = new BooleanConverter();
            m_fakeFlag = c.Equals(c);
            c          = new ByteConverter();
            m_fakeFlag = c.Equals(c);
            c          = new CollectionConverter();
            m_fakeFlag = c.Equals(c);
            c          = new ComponentConverter(typeof(int));
            m_fakeFlag = c.Equals(c);
            c          = new CultureInfoConverter();
            m_fakeFlag = c.Equals(c);
            c          = new DateTimeConverter();
            m_fakeFlag = c.Equals(c);
            c          = new DecimalConverter();
            m_fakeFlag = c.Equals(c);
            c          = new DoubleConverter();
            m_fakeFlag = c.Equals(c);
            c          = new EnumConverter(typeof(int));
            m_fakeFlag = c.Equals(c);
            c          = new ExpandableObjectConverter();
            m_fakeFlag = c.Equals(c);
            c          = new Int16Converter();
            m_fakeFlag = c.Equals(c);
            c          = new Int32Converter();
            m_fakeFlag = c.Equals(c);
            c          = new Int64Converter();
            m_fakeFlag = c.Equals(c);
            c          = new NullableConverter(typeof(object));
            m_fakeFlag = c.Equals(c);
            c          = new SByteConverter();
            m_fakeFlag = c.Equals(c);
            c          = new SingleConverter();
            m_fakeFlag = c.Equals(c);
            c          = new StringConverter();
            m_fakeFlag = c.Equals(c);
            c          = new TimeSpanConverter();
            m_fakeFlag = c.Equals(c);
            c          = new UInt16Converter();
            m_fakeFlag = c.Equals(c);
            c          = new UInt32Converter();
            m_fakeFlag = c.Equals(c);
            c          = new UInt64Converter();
            m_fakeFlag = c.Equals(c);
        }
예제 #9
0
        private void BindData()
        {
            int loadCompletedCount = 0;
            int wellLoadedCount    = 3;

            this.cmbStatus.ItemsSource             = EnumConverter.GetKeyValuePairs <SOComplainStatus>();
            this.cmbResponsibleConfirm.ItemsSource = BooleanConverter.GetKeyValuePairs(EnumConverter.EnumAppendItemType.Select);
            this.cmbApproach.ItemsSource           = EnumConverter.GetKeyValuePairs <SOComplainReplyType>();

            //获取投诉详细部门集合
            CodeNamePairHelper.GetList(ConstValue.DomainName_SO
                                       , ConstValue.Key_SOResponsibleDept
                                       , CodeNamePairAppendItemType.Select
                                       , (o, p) =>
            {
                m_csDeptList = p.Result;
                Interlocked.Increment(ref loadCompletedCount);
                if (loadCompletedCount == wellLoadedCount)
                {
                    BindPage();
                }
            });

            //读取下拉框值
            CodeNamePairHelper.GetList(ConstValue.DomainName_SO
                                       , new string[] { ConstValue.Key_ComplainType, ConstValue.Key_SOComplainSourceType }
                                       , (o, p) =>
            {
                this.cmbComplainType.ItemsSource       = p.Result[ConstValue.Key_ComplainType];
                this.cmbComplainSourceType.ItemsSource = p.Result[ConstValue.Key_SOComplainSourceType];
                Interlocked.Increment(ref loadCompletedCount);
                if (loadCompletedCount == wellLoadedCount)
                {
                    BindPage();
                }
            });

            //获取值
            m_facade.Get(int.Parse(Request.Param), (o, e) =>
            {
                if (!e.FaultsHandle())
                {
                    m_data = e.Result;
                    Interlocked.Increment(ref loadCompletedCount);
                    if (loadCompletedCount == wellLoadedCount)
                    {
                        BindPage();
                    }
                }
            });
        }
예제 #10
0
        public void ConvertsToCorrectValue(Type type, string val, object expectedConvertedVal)
        {
            // Arrange.
            IConverter converter = new BooleanConverter();

            // Act.
            object result;
            bool   converted = converter.TryConvertTo(type, val, out result);

            // Assert.
            Assert.True(converted);
            Assert.IsType(type, result);
            Assert.Equal(result, expectedConvertedVal);
        }
예제 #11
0
        public void UpperFalseConversion()
        {
            // Arrange
            IConverter converter = new BooleanConverter();
            var        value     = "False";

            // Act
            var actual = converter.Convert(value, converter.TargetType);

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <bool>(actual);
            Assert.False((bool)actual);
        }
예제 #12
0
        public void StringEmptyConversion()
        {
            // Arrange
            IConverter converter = new BooleanConverter();
            var        value     = string.Empty;

            // Act
            var actual = converter.Convert(value, converter.TargetType);

            // Assert
            Assert.NotNull(actual);
            Assert.IsType <bool>(actual);
            Assert.True((bool)actual);
        }
예제 #13
0
        bool ToBoolean(SnapshotBase snapshot, Value value, bool defaultValue)
        {
            var converter = new BooleanConverter(snapshot);
            var result    = converter.EvaluateToBoolean(value);

            if (result != null)
            {
                return(result.Value);
            }
            else
            {
                return(defaultValue);
            }
        }
        public void ShouldFailToConvertToCSharpValue()
        {
            //Arrange

            //Act
            var converter = new BooleanConverter();
            object value0;
            object value1;
            bool success0 = converter.TryConvertToCSharpValue("666", out value0);
            bool success1 = converter.TryConvertToCSharpValue("Empty", out value1);

            //Assert
            Assert.IsFalse(success0);
            Assert.IsFalse(success1);
        }
예제 #15
0
        public SqsMessageQueueTest()
        {
            AWS_ENABLED    = Environment.GetEnvironmentVariable("AWS_ENABLED") ?? "true";
            AWS_REGION     = Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-east-1";
            AWS_ACCOUNT    = Environment.GetEnvironmentVariable("AWS_ACCOUNT");
            AWS_ACCESS_ID  = Environment.GetEnvironmentVariable("AWS_ACCESS_ID") ?? "AKIAI2B3PGHEAAK4BPUQ";
            AWS_ACCESS_KEY = Environment.GetEnvironmentVariable("AWS_ACCESS_KEY") ?? "zQZGX0vGL6OD936fCcP1v6YmpiSdW28oUcezAnb7";

            _enabled = BooleanConverter.ToBoolean(AWS_ENABLED);

            if (_enabled)
            {
                Setup();
            }
        }
예제 #16
0
        public void ReadJson_ValidInput_SuccessResult(string input, JsonToken type, bool expectedResult)
        {
            //Arrange
            var converter      = new BooleanConverter();
            var jsonReaderMock = new Mock <JsonReader>();

            jsonReaderMock.SetupGet(x => x.TokenType).Returns(type);
            jsonReaderMock.SetupGet(x => x.Value).Returns(input);

            //Act
            var result = converter.ReadJson(jsonReaderMock.Object, null, null, null);

            //Arrange
            Assert.Equal(expectedResult, result);
        }
예제 #17
0
        public void ReadJson_InputNotInteger_ExceptionThrown()
        {
            //Arrange
            var converter      = new BooleanConverter();
            var jsonReaderMock = new Mock <JsonReader>();

            jsonReaderMock.SetupGet(x => x.TokenType).Returns(JsonToken.Float);

            //Act
            var ex = Assert.Throws <ArgumentException>(
                () => converter.ReadJson(jsonReaderMock.Object, null, false, null));

            //Arrange
            Assert.Equal(ex.Message, "Unexpected token. Integer or String was expected, got Float");
        }
예제 #18
0
        public void ConvertToStringTest()
        {
            var converter            = new BooleanConverter();
            var typeConverterOptions = new TypeConverterOptions
            {
                CultureInfo = CultureInfo.CurrentCulture
            };

            Assert.AreEqual("True", converter.ConvertToString(typeConverterOptions, true));

            Assert.AreEqual("False", converter.ConvertToString(typeConverterOptions, false));

            Assert.AreEqual("", converter.ConvertToString(typeConverterOptions, null));
            Assert.AreEqual("1", converter.ConvertToString(typeConverterOptions, 1));
        }
예제 #19
0
        public async Task <SearchQualityProfiles> SearchQualityProfilesAsync(bool?defaults = null, string language = null, string project = null, string qualityProfile = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(defaults)]       = BooleanConverter.ToString(defaults),
                [nameof(language)]       = language,
                [nameof(project)]        = project,
                [nameof(qualityProfile)] = qualityProfile
            };

            return(await GetQualityProfilesUrl("search")
                   .SetQueryParams(queryParamValues)
                   .GetJsonAsync <SearchQualityProfiles>()
                   .ConfigureAwait(false));
        }
예제 #20
0
        public async Task <IEnumerable <Tuple <int, string, string, string> > > GetScmSourcesAsync(string key, bool?commitsByLine = null, string from = null, string to = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(key)]       = key,
                ["commits_by_line"] = BooleanConverter.ToString(commitsByLine),
                [nameof(from)]      = from,
                [nameof(to)]        = to
            };

            return(await GetSourcesUrl("scm")
                   .SetQueryParams(queryParamValues)
                   .GetJsonFirstNodeAsync <IEnumerable <Tuple <int, string, string, string> >, TupleFourTypesConverter <int, string, string, string> >()
                   .ConfigureAwait(false));
        }
예제 #21
0
        public async Task <bool> SetProjectBranchAutomaticDeletionProtectionAsync(string project, string branch, bool value)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(project)] = project,
                [nameof(branch)]  = branch,
                [nameof(value)]   = BooleanConverter.ToString(value)
            };

            var response = await GetProjectBranchesUrl("set_automatic_deletion_protection")
                           .SetQueryParams(queryParamValues)
                           .PostAsync(s_emptyHttpContent)
                           .ConfigureAwait(false);

            return(await HandleResponseAsync(response).ConfigureAwait(false));
        }
예제 #22
0
        public void ReadJson_ValidTokenInvalidResult_ExceptionThrown(JsonToken tokenType)
        {
            //Arrange
            var converter      = new BooleanConverter();
            var jsonReaderMock = new Mock <JsonReader>();

            jsonReaderMock.SetupGet(x => x.TokenType).Returns(tokenType);
            jsonReaderMock.SetupGet(x => x.Value).Returns("wrongValue");

            //Act
            var ex = Assert.Throws <ArgumentException>(
                () => converter.ReadJson(jsonReaderMock.Object, null, false, null));

            //Arrange
            Assert.Equal(ex.Message, "wrongValue isn't a number");
        }
예제 #23
0
        public void ConvertToString_SingleBooleanFalseValue_UsesValue()
        {
            var converter     = new BooleanConverter();
            var memberMapData = new MemberMapData(null)
            {
                TypeConverter        = converter,
                TypeConverterOptions =
                {
                    BooleanFalseValues = { "Foo" },
                },
            };

            var value = converter.ConvertToString(false, null, memberMapData);

            Assert.Equal("Foo", value);
        }
예제 #24
0
        public void ReadJson_MoreThan0_ExceptionThrown()
        {
            //Arrange
            var converter      = new BooleanConverter();
            var jsonReaderMock = new Mock <JsonReader>();

            jsonReaderMock.SetupGet(x => x.TokenType).Returns(JsonToken.Integer);
            jsonReaderMock.SetupGet(x => x.Value).Returns(3);

            //Act
            var ex = Assert.Throws <ArgumentException>(
                () => converter.ReadJson(jsonReaderMock.Object, null, false, null));

            //Arrange
            Assert.Equal(ex.Message, "Input value should be 1 or 0");
        }
예제 #25
0
        public void ConvertToString_MultipleBooleanTrueValues_UsesFirstValue()
        {
            var converter     = new BooleanConverter();
            var memberMapData = new MemberMapData(null)
            {
                TypeConverter        = converter,
                TypeConverterOptions =
                {
                    BooleanTrueValues = { "Foo", "Bar" },
                },
            };

            var value = converter.ConvertToString(true, null, memberMapData);

            Assert.Equal("Foo", value);
        }
        public void ShouldConvertToCellValue()
        {
            //Arrange

            //Act
            var converter = new BooleanConverter();
            string value0;
            string value1;
            bool success0 = converter.TryConvertToCellValue(false, out value0);
            bool success1 = converter.TryConvertToCellValue(true, out value1);

            //Assert
            Assert.IsTrue(success0);
            Assert.IsTrue(success1);
            Assert.AreEqual("0", value0);
            Assert.AreEqual("1", value1);
        }
예제 #27
0
 public PayableQueryVM()
 {
     this.WebChannelList = CPApplication.Current.CurrentWebChannelList.ToList <UIWebChannel>();
     this.WebChannelList.Insert(0, new UIWebChannel {
         ChannelName = ResCommonEnum.Enum_All
     });
     this.OrderTypeList               = EnumConverter.GetKeyValuePairs <PayableOrderType>(EnumConverter.EnumAppendItemType.All);
     this.PayStatusList               = EnumConverter.GetKeyValuePairs <PayableStatus>(EnumConverter.EnumAppendItemType.All);
     this.InvoiceStatusList           = EnumConverter.GetKeyValuePairs <InvoiceStatus>(EnumConverter.EnumAppendItemType.All);
     this.PayItemStyleList            = EnumConverter.GetKeyValuePairs <PayItemStyle>(EnumConverter.EnumAppendItemType.All);
     this.POStatusList                = EnumConverter.GetKeyValuePairs <POStatus>(EnumConverter.EnumAppendItemType.All);
     this.POTypeList                  = EnumConverter.GetKeyValuePairs <POType>(EnumConverter.EnumAppendItemType.All);
     this.PayPeriodTypeList           = new List <CodeNamePair>();
     this.VendorSettleOrderStatusList = EnumConverter.GetKeyValuePairs <VendorSettleOrderStatus>(EnumConverter.EnumAppendItemType.All);
     this.YNList = BooleanConverter.GetKeyValuePairs(EnumConverter.EnumAppendItemType.All);
     this.IsOnlyNegativeOrder = this.IsNotInStock = false;
 }
예제 #28
0
        public void ConvertToStringTest()
        {
            var converter = new BooleanConverter();

            var propertyMapData = new MemberMapData(null)
            {
                TypeConverter        = converter,
                TypeConverterOptions = { CultureInfo = CultureInfo.CurrentCulture }
            };

            Assert.AreEqual("True", converter.ConvertToString(true, null, propertyMapData));

            Assert.AreEqual("False", converter.ConvertToString(false, null, propertyMapData));

            Assert.AreEqual("", converter.ConvertToString(null, null, propertyMapData));
            Assert.AreEqual("1", converter.ConvertToString(1, null, propertyMapData));
        }
예제 #29
0
        public async Task <IssuesList> SearchIssuesAsync(AvailableIssueFields[] additionalFields = null, bool?asc  = null, bool?assigned         = null, string[] assignees = null,
                                                         string[] author            = null, string[] componentKeys = null, DateTime?createdAfter = null, DateTime?createdAt = null, DateTime?createdBefore = null, string createdInLast = null,
                                                         string[] cwe               = null, Facets[] facets = null, string[] issues       = null, string[] languages = null, bool?onComponentsOnly = null, OwaspTop10Types[] owaspTop10 = null,
                                                         int?p                      = null, int?ps = null, IssueResolutions[] resolutions = null, bool?resolved      = null, string[] rules = null, IssueSortFields[] s = null,
                                                         SansTop25Types[] sansTop25 = null, Severities[] severities = null, bool?sinceLeakPeriod = null, SonarSourceSecurityTypes[] sonarSourceSecurity = null,
                                                         IssueStatuses[] statuses   = null, string[] tags           = null, IssueTypes[] types = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(additionalFields)] = additionalFields == null ? null : string.Join(",", additionalFields.Select(AvailableIssueFieldsConverter.ToString)),
                [nameof(asc)]              = BooleanConverter.ToString(asc),
                [nameof(assigned)]         = BooleanConverter.ToString(assigned),
                [nameof(assignees)]        = assignees == null ? null : string.Join(",", assignees),
                [nameof(author)]           = author,
                [nameof(componentKeys)]    = componentKeys == null ? null : string.Join(",", componentKeys),
                [nameof(createdAfter)]     = DateTimeToStringConverter.ToString(createdAfter),
                [nameof(createdAt)]        = DateTimeToStringConverter.ToString(createdAt),
                [nameof(createdBefore)]    = DateTimeToStringConverter.ToString(createdBefore),
                [nameof(createdInLast)]    = createdInLast,
                [nameof(cwe)]              = cwe == null ? null : string.Join(",", cwe),
                [nameof(facets)]           = facets == null ? null : string.Join(",", facets.Select(FacetsConverter.ToString)),
                [nameof(issues)]           = issues == null ? null : string.Join(",", issues),
                [nameof(languages)]        = languages == null ? null : string.Join(",", languages),
                [nameof(onComponentsOnly)] = onComponentsOnly,
                [nameof(owaspTop10)]       = owaspTop10 == null ? null : string.Join(",", owaspTop10.Select(OwaspTop10TypesConverter.ToString)),
                [nameof(p)]                   = p,
                [nameof(ps)]                  = ps,
                [nameof(resolutions)]         = resolutions == null ? null : string.Join(",", resolutions.Select(IssueResolutionsConverter.ToString)),
                [nameof(resolved)]            = BooleanConverter.ToString(resolved),
                [nameof(rules)]               = rules,
                [nameof(s)]                   = s,
                [nameof(sansTop25)]           = sansTop25 == null ? null : string.Join(",", sansTop25.Select(SansTop25TypesConverter.ToString)),
                [nameof(severities)]          = severities == null ? null : string.Join(",", severities.Select(SeveritiesConverter.ToString)),
                [nameof(sinceLeakPeriod)]     = BooleanConverter.ToString(sinceLeakPeriod),
                [nameof(sonarSourceSecurity)] = sonarSourceSecurity == null ? null : string.Join(",", sonarSourceSecurity.Select(SonarSourceSecurityTypesConverter.ToString)),
                [nameof(statuses)]            = statuses == null ? null : string.Join(",", statuses.Select(IssueStatusesConverter.ToString)),
                [nameof(tags)]                = tags,
                [nameof(types)]               = types == null ? null : string.Join(",", types.Select(IssueTypesConverter.ToString))
            };

            return(await GetIssuesUrl("search")
                   .SetQueryParams(queryParamValues)
                   .GetJsonAsync <IssuesList>()
                   .ConfigureAwait(false));
        }
예제 #30
0
        /// <summary>
        /// Gets the condition result.
        /// </summary>
        /// <returns>see <see cref="PossibleValues"/> for details of possible result.</returns>
        PossibleValues GetConditionResult(FlowOutputSet flowOutputSet, MemoryEntry evaluatedPart)
        {
            var converter = new BooleanConverter(flowOutputSet.Snapshot);
            var value     = converter.EvaluateToBoolean(evaluatedPart);

            if (value == null)
            {
                return(PossibleValues.Unknown);
            }
            else if (value.Value)
            {
                return(PossibleValues.OnlyTrue);
            }
            else
            {
                return(PossibleValues.OnlyFalse);
            }
        }
예제 #31
0
        public async Task <bool> ActivateQualityProfileRuleAsync(string key, string rule, IDictionary <string, string> parameters = null, bool?reset = null, Severities?severity = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(key)]      = key,
                [nameof(rule)]     = rule,
                ["params"]         = parameters,         // XXX
                [nameof(reset)]    = BooleanConverter.ToString(reset),
                [nameof(severity)] = SeveritiesConverter.ToString(severity)
            };

            var response = await GetQualityProfilesUrl("activate_rule")
                           .SetQueryParams(queryParamValues)
                           .PostAsync(s_emptyHttpContent)
                           .ConfigureAwait(false);

            return(await HandleResponseAsync(response).ConfigureAwait(false));
        }
예제 #32
0
        public async Task <IEnumerable <ProjectComponent> > SearchProjectsAsync(DateTime?analyzedBefore = null, bool?onProvisionedOnly = null, int?p = null, string[] projects = null, int?ps = null, string q = null, ProjectQualifiers[] qualifiers = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(analyzedBefore)]    = DateTimeToStringConverter.ToString(analyzedBefore),
                [nameof(onProvisionedOnly)] = BooleanConverter.ToString(onProvisionedOnly),
                [nameof(p)]          = p,
                [nameof(projects)]   = projects == null ? null : string.Join(",", projects),
                [nameof(ps)]         = ps,
                [nameof(q)]          = q,
                [nameof(qualifiers)] = qualifiers == null ? null : string.Join(",", qualifiers.Select(ProjectQualifiersConverter.ToString)),
            };

            return(await GetProjectsUrl("search")
                   .SetQueryParams(queryParamValues)
                   .GetJsonNamedNodeAsync <IEnumerable <ProjectComponent> >("components")
                   .ConfigureAwait(false));
        }
        public void ConvertFromStringTest()
        {
            var converter = new BooleanConverter();

            var propertyMapData = new CsvPropertyMapData(null);

            propertyMapData.TypeConverterOptions.CultureInfo = CultureInfo.CurrentCulture;

            var mockRow = new Mock <ICsvReaderRow>();

            Assert.IsTrue((bool)converter.ConvertFromString("true", null, propertyMapData));
            Assert.IsTrue((bool)converter.ConvertFromString("True", null, propertyMapData));
            Assert.IsTrue((bool)converter.ConvertFromString("TRUE", null, propertyMapData));
            Assert.IsTrue((bool)converter.ConvertFromString("1", null, propertyMapData));
            Assert.IsTrue((bool)converter.ConvertFromString("yes", null, propertyMapData));
            Assert.IsTrue((bool)converter.ConvertFromString("YES", null, propertyMapData));
            Assert.IsTrue((bool)converter.ConvertFromString("y", null, propertyMapData));
            Assert.IsTrue((bool)converter.ConvertFromString("Y", null, propertyMapData));
            Assert.IsTrue((bool)converter.ConvertFromString(" true ", null, propertyMapData));
            Assert.IsTrue((bool)converter.ConvertFromString(" yes ", null, propertyMapData));
            Assert.IsTrue((bool)converter.ConvertFromString(" y ", null, propertyMapData));

            Assert.IsFalse((bool)converter.ConvertFromString("false", null, propertyMapData));
            Assert.IsFalse((bool)converter.ConvertFromString("False", null, propertyMapData));
            Assert.IsFalse((bool)converter.ConvertFromString("FALSE", null, propertyMapData));
            Assert.IsFalse((bool)converter.ConvertFromString("0", null, propertyMapData));
            Assert.IsFalse((bool)converter.ConvertFromString("no", null, propertyMapData));
            Assert.IsFalse((bool)converter.ConvertFromString("NO", null, propertyMapData));
            Assert.IsFalse((bool)converter.ConvertFromString("n", null, propertyMapData));
            Assert.IsFalse((bool)converter.ConvertFromString("N", null, propertyMapData));
            Assert.IsFalse((bool)converter.ConvertFromString(" false ", null, propertyMapData));
            Assert.IsFalse((bool)converter.ConvertFromString(" 0 ", null, propertyMapData));
            Assert.IsFalse((bool)converter.ConvertFromString(" no ", null, propertyMapData));
            Assert.IsFalse((bool)converter.ConvertFromString(" n ", null, propertyMapData));

            try
            {
                converter.ConvertFromString(null, mockRow.Object, propertyMapData);
                Assert.Fail();
            }
            catch (CsvTypeConverterException)
            {
            }
        }
예제 #34
0
        public void ConvertToExcelTest()
        {
            var converter            = new BooleanConverter();
            var typeConverterOptions = new TypeConverterOptions {
                CultureInfo = CultureInfo.CurrentCulture
            };

            // Valid conversions with default formatting
            Assert.AreEqual("true", converter.ConvertToExcel(typeConverterOptions, true));
            Assert.AreEqual("false", converter.ConvertToExcel(typeConverterOptions, false));

            // Valid conversions with non-default formatting as numbers
            typeConverterOptions.BooleanTrueValues.Clear();
            typeConverterOptions.BooleanTrueValues.Add("1");
            typeConverterOptions.BooleanFalseValues.Clear();
            typeConverterOptions.BooleanFalseValues.Add("0");
            Assert.AreEqual(1, converter.ConvertToExcel(typeConverterOptions, true));
            Assert.AreEqual(0, converter.ConvertToExcel(typeConverterOptions, false));
        }
예제 #35
0
        /// <summary>
        ///   Converts the string value to a boolean. Int32 values are able to be
        ///   parsed.
        /// </summary>
        /// <typeparam name = "T"></typeparam>
        /// <param name = "value"></param>
        /// <returns></returns>
        private static T ConvertToBool <T>(string value)
        {
            // see if an int was used. 0 = false, anything else is true.
            int result;

            if (Int32.TryParse(value, out result))
            {
                return((T)(object)(result != 0));
            }

            // didn't use an int, pass off the the BooleanConverter. The
            // BooleanConverter can't handle numbers and it is faster to check
            // if it is an int than deal with the exception that the
            // BooleanConverter would throw and then deal with converting from
            // int.
            var converter = new BooleanConverter();

            return((T)converter.ConvertFrom(value));
        }
예제 #36
0
        public async Task <ComponentsTree> GetComponentsTreeAsync(string component, bool?asc = null, int?p = null, int?ps = null, string q = null, ComponentQualifiers[] qualifiers = null, string[] s = null, ComponentTreeStrategies?strategy = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(component)]  = component,
                [nameof(asc)]        = BooleanConverter.ToString(asc),
                [nameof(p)]          = p,
                [nameof(ps)]         = ps,
                [nameof(q)]          = q,
                [nameof(qualifiers)] = qualifiers == null ? null : string.Join(",", qualifiers.Select(ComponentQualifiersConverter.ToString)),
                [nameof(s)]          = s == null ? null : string.Join(",", s),
                [nameof(strategy)]   = ComponentTreeStrategiesToStringConverter.ToString(strategy)
            };

            return(await GetComponentsUrl("tree")
                   .SetQueryParams(queryParamValues)
                   .GetJsonAsync <ComponentsTree>()
                   .ConfigureAwait(false));
        }
예제 #37
0
        //*************************************************************************
        //  Method: OnVertexAttributesEditedInGraph()
        //
        /// <summary>
        /// Handles the VertexAttributesEditedInGraph event on ThisWorkbook.
        /// </summary>
        ///
        /// <param name="e">
        /// Standard event argument.
        /// </param>
        //*************************************************************************
        private void OnVertexAttributesEditedInGraph(
            VertexAttributesEditedEventArgs e
            )
        {
            Debug.Assert(e != null);
            AssertValid();

            Microsoft.Office.Interop.Excel.ListObject oVertexTable =
            Vertices.InnerObject;

            // Get a dictionary containing the ID of each row in the table.

            Dictionary<Int32, Int32> oRowIDDictionary;

            if ( !m_oSheets1And2Helper.TryGetAllRowIDs(out oRowIDDictionary) )
            {
            // Nothing can be done without the IDs.

            return;
            }

            Globals.ThisWorkbook.ShowWaitCursor = true;

            // Get the columns that might need to be updated.  These columns are
            // not required.

            Microsoft.Office.Interop.Excel.Range oColorColumnData,
            oShapeColumnData, oRadiusColumnData, oAlphaColumnData,
            oVisibilityColumnData, oLabelPositionColumnData, oLockedColumnData,
            oMarkedColumnData;

            Object [,] aoColorValues = null;
            Object [,] aoShapeValues = null;
            Object [,] aoRadiusValues = null;
            Object [,] aoAlphaValues = null;
            Object [,] aoVisibilityValues = null;
            Object [,] aoLabelPositionValues = null;
            Object [,] aoLockedValues = null;
            Object [,] aoMarkedValues = null;

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Color, out oColorColumnData,
            out aoColorValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Shape, out oShapeColumnData,
            out aoShapeValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Radius, out oRadiusColumnData,
            out aoRadiusValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            CommonTableColumnNames.Alpha, out oAlphaColumnData,
            out aoAlphaValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            CommonTableColumnNames.Visibility, out oVisibilityColumnData,
            out aoVisibilityValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.LabelPosition, out oLabelPositionColumnData,
            out aoLabelPositionValues);

            ExcelUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Locked, out oLockedColumnData,
            out aoLockedValues);

            if ( TryGetMarkedColumnData(out oMarkedColumnData) )
            {
            aoMarkedValues = ExcelUtil.GetRangeValues(oMarkedColumnData);
            }

            ColorConverter2 oColorConverter2 = new ColorConverter2();

            VertexShapeConverter oVertexShapeConverter =
            new VertexShapeConverter();

            VertexVisibilityConverter oVertexVisibilityConverter =
            new VertexVisibilityConverter();

            VertexLabelPositionConverter oVertexLabelPositionConverter =
            new VertexLabelPositionConverter();

            BooleanConverter oBooleanConverter = new BooleanConverter();

            // Loop through the IDs of the vertices whose attributes were edited
            // in the graph.

            EditedVertexAttributes oEditedVertexAttributes =
            e.EditedVertexAttributes;

            foreach (Int32 iID in e.VertexIDs)
            {
            // Look for the row that contains the ID.

            Int32 iRowOneBased;

            if ( !oRowIDDictionary.TryGetValue(iID, out iRowOneBased) )
            {
                continue;
            }

            iRowOneBased -= oVertexTable.Range.Row;

            if (oEditedVertexAttributes.Color.HasValue &&
                aoColorValues != null)
            {
                aoColorValues[iRowOneBased, 1] =
                    oColorConverter2.GraphToWorkbook(
                        oEditedVertexAttributes.Color.Value);
            }

            if (oEditedVertexAttributes.Shape.HasValue &&
                aoShapeValues != null)
            {
                aoShapeValues[iRowOneBased, 1] =
                    oVertexShapeConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Shape.Value);
            }

            if (oEditedVertexAttributes.Radius.HasValue &&
                aoRadiusValues != null)
            {
                aoRadiusValues[iRowOneBased, 1] =
                    oEditedVertexAttributes.Radius.Value.ToString();
            }

            if (oEditedVertexAttributes.Alpha.HasValue &&
                aoAlphaValues != null)
            {
                aoAlphaValues[iRowOneBased, 1] =
                    oEditedVertexAttributes.Alpha.Value.ToString();
            }

            if (oEditedVertexAttributes.Visibility.HasValue &&
                aoVisibilityValues != null)
            {
                aoVisibilityValues[iRowOneBased, 1] =
                    oVertexVisibilityConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Visibility.Value);
            }

            if (oEditedVertexAttributes.LabelPosition.HasValue &&
                aoLabelPositionValues != null)
            {
                aoLabelPositionValues[iRowOneBased, 1] =
                    oVertexLabelPositionConverter.GraphToWorkbook(
                        oEditedVertexAttributes.LabelPosition.Value);
            }

            if (oEditedVertexAttributes.Locked.HasValue &&
                aoLockedValues != null)
            {
                aoLockedValues[iRowOneBased, 1] =
                    oBooleanConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Locked.Value);
            }

            if (oEditedVertexAttributes.Marked.HasValue &&
                aoMarkedValues != null)
            {
                aoMarkedValues[iRowOneBased, 1] =
                    oBooleanConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Marked.Value);
            }
            }

            // Activate this worksheet first, because writing to an inactive
            // worksheet causes problems with the selection in Excel.

            ExcelActiveWorksheetRestorer oExcelActiveWorksheetRestorer =
            GetExcelActiveWorksheetRestorer();

            ExcelActiveWorksheetState oExcelActiveWorksheetState =
            oExcelActiveWorksheetRestorer.ActivateWorksheet(this.InnerObject);

            try
            {
            if (aoColorValues != null)
            {
                oColorColumnData.set_Value(Missing.Value, aoColorValues);
            }

            if (aoShapeValues != null)
            {
                oShapeColumnData.set_Value(Missing.Value, aoShapeValues);
            }

            if (aoRadiusValues != null)
            {
                oRadiusColumnData.set_Value(Missing.Value, aoRadiusValues);
            }

            if (aoAlphaValues != null)
            {
                oAlphaColumnData.set_Value(Missing.Value, aoAlphaValues);
            }

            if (aoVisibilityValues != null)
            {
                oVisibilityColumnData.set_Value(Missing.Value,
                    aoVisibilityValues);
            }

            if (aoLabelPositionValues != null)
            {
                oLabelPositionColumnData.set_Value(Missing.Value,
                    aoLabelPositionValues);
            }

            if (aoLockedValues != null)
            {
                oLockedColumnData.set_Value(Missing.Value, aoLockedValues);
            }

            if (aoMarkedValues != null)
            {
                oMarkedColumnData.set_Value(Missing.Value, aoMarkedValues);
            }
            }
            finally
            {
            oExcelActiveWorksheetRestorer.Restore(oExcelActiveWorksheetState);
            }

            Globals.ThisWorkbook.ShowWaitCursor = false;
        }
        public void ShouldFailToConvertToCellValue()
        {
            //Arrange

            //Act
            var converter = new BooleanConverter();
            string value0;
            string value1;
            bool success0 = converter.TryConvertToCellValue("True", out value0);
            bool success1 = converter.TryConvertToCellValue("bbb", out value1);

            //Assert
            Assert.IsFalse(success0);
            Assert.IsFalse(success1);
        }
 SetUp()
 {
     m_oBooleanConverter = new BooleanConverter();
 }
예제 #40
0
 public void TearDown()
 {
     m_oBooleanConverter = null;
 }
예제 #41
0
        //*************************************************************************
        //  Method: TryGetBoolean()
        //
        /// <summary>
        /// Attempts to get a Boolean value from a worksheet cell.
        /// </summary>
        ///
        /// <param name="oRow">
        /// Row containing the data.
        /// </param>
        ///
        /// <param name="sColumnName">
        /// Name of the column containing the Boolean value.
        /// </param>
        ///
        /// <param name="oBooleanConverter">
        /// Object for converting the Boolean value from a string to a Boolean.
        /// </param>
        ///
        /// <param name="bBoolean">
        /// Where the Boolean value gets stored if true is returned.
        /// </param>
        ///
        /// <returns>
        /// true if the specified cell contains a valid Boolean value.
        /// </returns>
        ///
        /// <remarks>
        /// If the specified cell is empty, false is returned.  If the cell
        /// contains a valid Boolean value, the value gets stored at <paramref
        /// name="bBoolean" /> and true is returned.  If the cell contains an
        /// invalid Boolean, a <see cref="WorkbookFormatException" /> is thrown.
        /// </remarks>
        //*************************************************************************
        protected Boolean TryGetBoolean(
            ExcelTableReader.ExcelTableRow oRow,
            String sColumnName,
            BooleanConverter oBooleanConverter,
            out Boolean bBoolean
            )
        {
            Debug.Assert(oRow != null);
            Debug.Assert( !String.IsNullOrEmpty(sColumnName) );
            Debug.Assert(oBooleanConverter != null);
            AssertValid();

            bBoolean = false;
            String sBoolean;

            if ( !oRow.TryGetNonEmptyStringFromCell(sColumnName, out sBoolean) )
            {
            return (false);
            }

            if ( !oBooleanConverter.TryWorkbookToGraph(sBoolean, out bBoolean) )
            {
            OnWorkbookFormatErrorWithDropDown(oRow, sColumnName, "value");
            }

            return (true);
        }
예제 #42
0
    ThisWorkbook_AttributesEditedInGraph
    (
        Object sender,
        AttributesEditedEventArgs e
    )
    {
        Debug.Assert(e != null);
        AssertValid();

        // The key is the row ID stored in the table's ID column and the value
        // is the one-based row number relative to the worksheet.

        Dictionary<Int32, Int32> oRowIDDictionary;

        if (
            e.EditedVertexAttributes == null
            ||
            !m_oSheets1And2Helper.TableExists
            ||
            !m_oSheets1And2Helper.TryGetAllRowIDs(out oRowIDDictionary)
            )
        {
            return;
        }

        Microsoft.Office.Interop.Excel.ListObject oVertexTable =
            Vertices.InnerObject;

        Globals.ThisWorkbook.ShowWaitCursor = true;

        // Get the columns that might need to be updated.  These columns are
        // not required.

        Microsoft.Office.Interop.Excel.Range oColorColumnData,
            oShapeColumnData, oRadiusColumnData, oAlphaColumnData,
            oVisibilityColumnData, oLabelColumnData, oLabelFillColorColumnData,
            oLabelPositionColumnData, oToolTipColumnData, oLockedColumnData,
            oMarkedColumnData;

        Object [,] aoColorValues = null;
        Object [,] aoShapeValues = null;
        Object [,] aoRadiusValues = null;
        Object [,] aoAlphaValues = null;
        Object [,] aoVisibilityValues = null;
        Object [,] aoLabelValues = null;
        Object [,] aoLabelFillColorValues = null;
        Object [,] aoLabelPositionValues = null;
        Object [,] aoToolTipValues = null;
        Object [,] aoLockedValues = null;
        Object [,] aoMarkedValues = null;

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Color, out oColorColumnData,
            out aoColorValues);

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Shape, out oShapeColumnData,
            out aoShapeValues);

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Radius, out oRadiusColumnData,
            out aoRadiusValues);

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            CommonTableColumnNames.Alpha, out oAlphaColumnData,
            out aoAlphaValues);

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            CommonTableColumnNames.Visibility, out oVisibilityColumnData,
            out aoVisibilityValues);

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Label, out oLabelColumnData,
            out aoLabelValues);

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.LabelFillColor,
            out oLabelFillColorColumnData, out aoLabelFillColorValues);

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.LabelPosition, out oLabelPositionColumnData,
            out aoLabelPositionValues);

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.ToolTip, out oToolTipColumnData,
            out aoToolTipValues);

        ExcelTableUtil.TryGetTableColumnDataAndValues(oVertexTable,
            VertexTableColumnNames.Locked, out oLockedColumnData,
            out aoLockedValues);

        if ( TryGetMarkedColumnData(out oMarkedColumnData) )
        {
            aoMarkedValues = ExcelUtil.GetRangeValues(oMarkedColumnData);
        }

        ColorConverter2 oColorConverter2 = new ColorConverter2();

        VertexShapeConverter oVertexShapeConverter =
            new VertexShapeConverter();

        VertexVisibilityConverter oVertexVisibilityConverter =
            new VertexVisibilityConverter();

        VertexLabelPositionConverter oVertexLabelPositionConverter =
            new VertexLabelPositionConverter();

        BooleanConverter oBooleanConverter = new BooleanConverter();

        // Loop through the IDs of the vertices whose attributes were edited
        // in the graph.

        EditedVertexAttributes oEditedVertexAttributes =
            e.EditedVertexAttributes;

        foreach (Int32 iID in e.VertexIDs)
        {
            // Look for the row that contains the ID.

            Int32 iRowOneBased;

            if ( !oRowIDDictionary.TryGetValue(iID, out iRowOneBased) )
            {
                continue;
            }

            iRowOneBased -= oVertexTable.Range.Row;

            if (oEditedVertexAttributes.Color.HasValue &&
                aoColorValues != null)
            {
                aoColorValues[iRowOneBased, 1] =
                    oColorConverter2.GraphToWorkbook(
                        oEditedVertexAttributes.Color.Value);
            }

            if (oEditedVertexAttributes.Shape.HasValue &&
                aoShapeValues != null)
            {
                aoShapeValues[iRowOneBased, 1] =
                    oVertexShapeConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Shape.Value);
            }

            if (oEditedVertexAttributes.Radius.HasValue &&
                aoRadiusValues != null)
            {
                aoRadiusValues[iRowOneBased, 1] =
                    oEditedVertexAttributes.Radius.Value.ToString();
            }

            if (oEditedVertexAttributes.Alpha.HasValue &&
                aoAlphaValues != null)
            {
                aoAlphaValues[iRowOneBased, 1] =
                    oEditedVertexAttributes.Alpha.Value.ToString();
            }

            if (oEditedVertexAttributes.Visibility.HasValue &&
                aoVisibilityValues != null)
            {
                aoVisibilityValues[iRowOneBased, 1] =
                    oVertexVisibilityConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Visibility.Value);
            }

            if ( !String.IsNullOrEmpty(oEditedVertexAttributes.Label) )
            {
                aoLabelValues[iRowOneBased, 1] = oEditedVertexAttributes.Label;
            }

            if (oEditedVertexAttributes.LabelFillColor.HasValue &&
                aoLabelFillColorValues != null)
            {
                aoLabelFillColorValues[iRowOneBased, 1] =
                    oColorConverter2.GraphToWorkbook(
                        oEditedVertexAttributes.LabelFillColor.Value);
            }

            if (oEditedVertexAttributes.LabelPosition.HasValue &&
                aoLabelPositionValues != null)
            {
                aoLabelPositionValues[iRowOneBased, 1] =
                    oVertexLabelPositionConverter.GraphToWorkbook(
                        oEditedVertexAttributes.LabelPosition.Value);
            }

            if ( !String.IsNullOrEmpty(oEditedVertexAttributes.ToolTip) )
            {
                aoToolTipValues[iRowOneBased, 1] =
                    oEditedVertexAttributes.ToolTip;
            }

            if (oEditedVertexAttributes.Locked.HasValue &&
                aoLockedValues != null)
            {
                aoLockedValues[iRowOneBased, 1] =
                    oBooleanConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Locked.Value);
            }

            if (oEditedVertexAttributes.Marked.HasValue &&
                aoMarkedValues != null)
            {
                aoMarkedValues[iRowOneBased, 1] =
                    oBooleanConverter.GraphToWorkbook(
                        oEditedVertexAttributes.Marked.Value);
            }
        }

        // Activate this worksheet first, because writing to an inactive
        // worksheet causes problems with the selection in Excel.

        ExcelActiveWorksheetRestorer oExcelActiveWorksheetRestorer =
            m_oSheets1And2Helper.GetExcelActiveWorksheetRestorer();

        ExcelActiveWorksheetState oExcelActiveWorksheetState =
            oExcelActiveWorksheetRestorer.ActivateWorksheet(this.InnerObject);

        try
        {
            m_oSheets1And2Helper.SetColumnDataValues(
                oColorColumnData, aoColorValues,
                oShapeColumnData, aoShapeValues,
                oRadiusColumnData, aoRadiusValues,
                oAlphaColumnData, aoAlphaValues,
                oVisibilityColumnData, aoVisibilityValues,
                oLabelColumnData, aoLabelValues,
                oLabelFillColorColumnData, aoLabelFillColorValues,
                oLabelPositionColumnData, aoLabelPositionValues,
                oToolTipColumnData, aoToolTipValues,
                oLockedColumnData, aoLockedValues,
                oMarkedColumnData, aoMarkedValues
                );
        }
        finally
        {
            oExcelActiveWorksheetRestorer.Restore(oExcelActiveWorksheetState);
        }

        Globals.ThisWorkbook.ShowWaitCursor = false;
    }
    ReadLocked
    (
        ExcelTableReader.ExcelTableRow oRow,
        BooleanConverter oBooleanConverter,
        Boolean bLocationSpecified,
        IVertex oVertex
    )
    {
        Debug.Assert(oRow != null);
        Debug.Assert(oBooleanConverter != null);
        Debug.Assert(oVertex != null);
        AssertValid();

        Boolean bLocked;

        if ( !TryGetBoolean(oRow, VertexTableColumnNames.Locked,
            oBooleanConverter, out bLocked) )
        {
            return;
        }

        if (bLocked && !bLocationSpecified)
        {
            Range oInvalidCell = oRow.GetRangeForCell(
                VertexTableColumnNames.Locked);

            OnWorkbookFormatError( String.Format(

                "The cell {0} indicates that the vertex should be locked,"
                + " but the vertex has no X and Y location values.  Either"
                + " clear the lock or specify a vertex location."
                ,
                ExcelUtil.GetRangeAddress(oInvalidCell)
                ),

                oInvalidCell
            );
        }

        oVertex.SetValue(ReservedMetadataKeys.LockVertexLocation, bLocked);
    }
예제 #44
0
 public void SetUp()
 {
     m_oBooleanConverter = new BooleanConverter();
 }
예제 #45
0
 //*************************************************************************
 //  Constructor: BooleanConverterTest()
 //
 /// <summary>
 /// Initializes a new instance of the <see
 /// cref="BooleanConverterTest" /> class.
 /// </summary>
 //*************************************************************************
 public BooleanConverterTest()
 {
     m_oBooleanConverter = null;
 }
    //*************************************************************************
    //  Constructor: ReadWorkbookContext()
    //
    /// <summary>
    /// Initializes a new instance of the <see cref="ReadWorkbookContext" />
    /// class.
    /// </summary>
    //*************************************************************************

    public ReadWorkbookContext()
    {
        m_bIgnoreVertexLocations = true;
        m_bFillIDColumns = false;
        m_bPopulateVertexWorksheet = false;
        m_bReadEdgeWeights = false;
        m_bReadGroups = false;
        m_bReadVertexColorFromGroups = true;
        m_bReadVertexShapeFromGroups = true;
        m_bReadVertexLabels = false;
        m_bReadEdgeLabels = false;
        m_bReadGroupLabels = false;
        m_bReadVertexImages = false;
        m_oDefaultVertexImageSize = new Nullable<Single>();
        m_eDefaultVertexShape = VertexShape.Disk;
        m_bReadAllEdgeAndVertexColumns = false;
        m_oGraphRectangle = Rectangle.FromLTRB(0, 0, 100, 100);
        m_oColorConverter2 = new ColorConverter2();
        m_oBooleanConverter = new BooleanConverter();
        m_oFontSizeConverter = new FontSizeConverter();
        m_oEdgeWidthConverter = new EdgeWidthConverter();
        m_oEdgeStyleConverter = new EdgeStyleConverter();
        m_oVertexRadiusConverter = new VertexRadiusConverter();

        m_oVertexLocationConverter =
            new VertexLocationConverter(m_oGraphRectangle);

        m_oVertexNameDictionary = new Dictionary<String, IVertex>();
        m_oEdgeRowIDDictionary = new Dictionary<Int32, IIdentityProvider>();
        m_oVertexRowIDDictionary = new Dictionary<Int32, IIdentityProvider>();

        AssertValid();
    }
    ReadMarked
    (
        ExcelTableReader.ExcelTableRow oRow,
        BooleanConverter oBooleanConverter,
        IVertex oVertex
    )
    {
        Debug.Assert(oRow != null);
        Debug.Assert(oBooleanConverter != null);
        Debug.Assert(oVertex != null);
        AssertValid();

        Boolean bMarked;

        if ( !TryGetBoolean(oRow, VertexTableColumnNames.IsMarked,
            oBooleanConverter, out bMarked) )
        {
            return;
        }

        oVertex.SetValue(ReservedMetadataKeys.Marked, bMarked);

        return;
    }