当前位置: 首页>>代码示例>>C#>>正文


C# Application.GetTokenValue方法代码示例

本文整理汇总了C#中iSolutions.iApply.DataContract.Application.GetTokenValue方法的典型用法代码示例。如果您正苦于以下问题:C# Application.GetTokenValue方法的具体用法?C# Application.GetTokenValue怎么用?C# Application.GetTokenValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在iSolutions.iApply.DataContract.Application的用法示例。


在下文中一共展示了Application.GetTokenValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetClassPropertyValueNull

            public void GetClassPropertyValueNull()
            {
                Application application = new Application();

                object value = application.GetTokenValue("ApplicationId");
                Assert.IsNull(value);
            }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:7,代码来源:ApplicationExtensionsTests.cs

示例2: GetDataPropertyValueUnknownToken

            public void GetDataPropertyValueUnknownToken()
            {
                Application application = new Application();

                object value = application.GetTokenValue("Foo");
                Assert.IsNull(value);
            }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:7,代码来源:ApplicationExtensionsTests.cs

示例3: Map

        /// <summary>
        /// Populates <paramref name="target"/> with static and <paramref name="source"/> values
        /// as defined by <paramref name="fieldMap"/>.
        /// </summary>
        /// <param name="source">The application from which to get field values.</param>
        /// <param name="fieldMap">A definition of field mappings.</param>
        /// <param name="target">The target object to populate with mapped key/values.</param>
        internal void Map(Application source, MappedFieldList fieldMap, JObject target)
        {
            foreach (MappedField map in fieldMap)
            {
                switch (map.MapType)
                {
                    case MapType.Value:
                    case MapType.PrivateValue:
                        target.Add(map.Target, map.Source);
                        break;

                    case MapType.Field:
                        object tokenValue = source.GetTokenValue(map.Source);
                        if (tokenValue == null)
                        {
                            target.Add(map.Target, string.Empty);
                        }
                        else if (tokenValue is IEnumerable<object>)
                        {
                            target.Add(map.Target, JArray.FromObject(tokenValue));
                        }
                        else
                        {
                            target.Add(map.Target, tokenValue.ToString());
                        }

                        break;

                    default:
                        throw new InvalidOperationException(string.Format(ExceptionMessages.InvalidMapType, map.MapType));
                }
            }
        }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:40,代码来源:JsonEndpointRequestMapper.cs

示例4: GetDataPropertyValueNull

            public void GetDataPropertyValueNull()
            {
                Application application = new Application();
                application.ApplicationData.Add("Foo", null);

                object value = application.GetTokenValue("Foo");
                Assert.IsNull(value);
            }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:8,代码来源:ApplicationExtensionsTests.cs

示例5: GetDataPropertyValue

            public void GetDataPropertyValue()
            {
                Application application = new Application();
                application.ApplicationData.Add("Foo", "Bar");

                string value = application.GetTokenValue("Foo").ToString();
                Assert.AreEqual("Bar", value);
            }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:8,代码来源:ApplicationExtensionsTests.cs

示例6: GetClassPropertyValue

            public void GetClassPropertyValue()
            {
                Application application = new Application
                {
                    ApplicationId = "GetMe"
                };

                string value = application.GetTokenValue("ApplicationId").ToString();
                Assert.AreEqual("GetMe", value);
            }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:10,代码来源:ApplicationExtensionsTests.cs

示例7: GetClassPropertyValueNested

            public void GetClassPropertyValueNested()
            {
                Application application = new Application
                {
                    CreatedBy = new AuthenticatedApplicationUser
                    {
                        DisplayName = "Foo Bar"
                    }
                };

                string value = application.GetTokenValue("CreatedBy.DisplayName").ToString();
                Assert.AreEqual("Foo Bar", value);
            }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:13,代码来源:ApplicationExtensionsTests.cs

示例8: Map

        /// <summary>
        /// Populates <paramref name="target"/> with static and <paramref name="source"/> values
        /// as defined by <paramref name="fieldMap"/>.
        /// </summary>
        /// <param name="source">The application from which to get field values.</param>
        /// <param name="fieldMap">A definition of field mappings.</param>
        /// <param name="target">The target object to populate with mapped key/values.</param>
        internal void Map(Application source, MappedFieldList fieldMap, XmlDocument target)
        {
            XmlNode root = target.FirstChild;
            foreach (MappedField map in fieldMap)
            {
                switch (map.MapType)
                {
                    case MapType.Value:
                    case MapType.PrivateValue:
                        root.AddElement(map.Target, map.Source);
                        break;

                    case MapType.Field:
                        object tokenValue = source.GetTokenValue(map.Source);
                        if (tokenValue == null)
                        {
                            root.AddElement(map.Target, string.Empty);
                        }
                        else
                        {
                            var value = tokenValue as IEnumerable<object>;
                            if (value != null)
                            {
                                this.GetNestedValue(value, map, root);
                            }
                            else
                            {
                                root.AddElement(map.Target, tokenValue.ToString());
                            }
                        }

                        break;

                    default:
                        throw new InvalidOperationException(string.Format(ExceptionMessages.InvalidMapType, map.MapType));
                }
            }
        }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:45,代码来源:XmlEndpointRequestMapper.cs

示例9: TraverseTreeBottom

            public void TraverseTreeBottom()
            {
                Application application = new Application();
                application.ApplicationData.Add("RootChild", "RootChild Value");

                var outerRepeater = new List<Dictionary<string, object>> { new Dictionary<string, object>() };
                var innerRepeater = new List<Dictionary<string, object>> { new Dictionary<string, object>() };

                innerRepeater[0].Add("InnerChild", "InnerChild Value");
                outerRepeater[0].Add("InnerRepeater", innerRepeater.ToArray());
                outerRepeater[0].Add("OuterChild", "OuterChild Value");
                application.ApplicationData.Add("OuterRepeater", outerRepeater.ToArray());

                ApplicationDataPath path = new ApplicationDataPath();
                path.Prepend("InnerRepeater", 0);
                path.Prepend("OuterRepeater", 0);
                string value = application.GetTokenValue("InnerChild", path).ToString();

                Assert.AreEqual("InnerChild Value", value);
            }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:20,代码来源:ApplicationExtensionsTests.cs

示例10: OrderOfPrecedence

            public void OrderOfPrecedence()
            {
                Application application = new Application
                {
                    ApplicationId = "GetMe"
                };
                application.ApplicationData.Add("ApplicationId", "NotMe");

                string value = application.GetTokenValue("ApplicationId").ToString();
                Assert.AreEqual("GetMe", value);
            }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:11,代码来源:ApplicationExtensionsTests.cs

示例11: GetTokenValue

        /// <summary>
        /// Gets the value of a token.
        /// </summary>
        /// <param name="token">The token being replaced.</param>
        /// <param name="application">The application to source data from.</param>
        /// <param name="control">The control.</param>
        /// <param name="path">Specifies the path to the token.</param>
        /// <returns>
        /// The value of the token.
        /// </returns>
        /// <remarks>
        /// Order of precedence: (1) Timestamp; (2) Application URL (3) <paramref name="application" /> object; (4) application data.
        /// </remarks>
        private object GetTokenValue(string token, Application application, Control control, ApplicationDataPath path)
        {
            if (token.StartsWith(FormatterResources.TimestampToken, StringComparison.CurrentCultureIgnoreCase))
            {
                return DateTime.Now;
            }

            if (token.StartsWith(FormatterResources.ApplicationUrlToken, StringComparison.CurrentCultureIgnoreCase))
            {
                string url = string.Format(FormatterResources.ApplicationUrlFormat, this.BaseUrl, application.FormId, application.Id);
                return string.Format(FormatterResources.ApplicationAnchor, url);
            }

            if (application == null)
            {
                return null;
            }

            string valueStr = application.GetTokenValue(token, path) as string;
            if (control is DateControl)
            {
                DateTime dateValue;
                if (valueStr != null && DateTime.TryParseExact(valueStr, DateControl.SYSTEM_FORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue))
                {
                    return dateValue.ToString(DateControl.USER_FORMAT);
                }
            }

            var calculationControl = control as CalculationControl;
            if (calculationControl == null || !calculationControl.FormatAsCurrency || valueStr == null)
            {
                return application.GetTokenValue(token, path);
            }

            decimal decimalVal;
            bool parsed = decimal.TryParse(valueStr, out decimalVal);
            if (parsed)
            {
                return string.Format("{0:C}", decimalVal);
            }

            return application.GetTokenValue(token, path);
        }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:56,代码来源:StringFormatter.cs


注:本文中的iSolutions.iApply.DataContract.Application.GetTokenValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。