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


C# IDataObject.GetPropertyValue方法代码示例

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


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

示例1: Format

        public string Format(IDataObject obj)
        {
            if (obj == null) return string.Empty;

            var cls = _resolver.GetObjectClass(obj.Context.GetInterfaceType(obj));
            var allProps = cls.GetAllProperties();
            var result = new StringBuilder();

            foreach (var prop in allProps.OfType<StringProperty>().OrderBy(p => p.Name))
            {
                var txtVal = obj.GetPropertyValue<string>(prop.Name);
                if (!string.IsNullOrWhiteSpace(txtVal))
                {
                    result.AppendLine(txtVal);
                }
            }

            foreach (var prop in allProps.OfType<EnumerationProperty>().OrderBy(p => p.Name))
            {
                var enumVal = obj.GetPropertyValue<int>(prop.Name);
                var txtVal = prop.Enumeration.GetLabelByValue(enumVal);
                if (!string.IsNullOrWhiteSpace(txtVal))
                {
                    result.AppendLine(txtVal);
                }
            }

            return result.ToString();
        }
开发者ID:daszat,项目名称:zetbox,代码行数:29,代码来源:DataObjectFormatter.cs

示例2: DebugDataObject

        static void DebugDataObject(IDataObject dataObject, string objectTypeName)
        {
            DataObject objDef = ((SampleSQLDataLayer)sampleDL).GetObjectDefinition(objectTypeName);

              foreach (DataProperty prop in objDef.dataProperties)
              {
            string propName = prop.propertyName;
            Console.WriteLine(propName + ": " + Convert.ToString(dataObject.GetPropertyValue(propName)));
              }
        }
开发者ID:iringtools,项目名称:samples,代码行数:10,代码来源:Program.cs

示例3: GetTemplateName

        protected string GetTemplateName(org.iringtools.adapter.datalayer.eb.Template template, DataObject objectDefinition, IDataObject dataObject)
        {
            if ((template.Placeholders == null) || (template.Placeholders.Count() == 0))
              {
            return template.Name;
              }

              template.Placeholders.ToList<Placeholder>().Sort(new PlaceHolderComparer());

              string[] parameters = new string[template.Placeholders.Length];
              int i = 0;

              foreach (Placeholder placeholder in template.Placeholders)
              {
            string propertyName = Utilities.ToPropertyName(placeholder.Value);
            string propertyValue = Convert.ToString(dataObject.GetPropertyValue(propertyName));

            if (string.IsNullOrEmpty(propertyValue))
            {
              _logger.Warn(string.Format("Template holder [{0}] is empty.", placeholder.Value));
            }

            if (!string.IsNullOrEmpty(placeholder.Format))
            {
              if (propertyValue.Length < placeholder.Format.Length)
              {
            propertyValue = placeholder.Format.Substring(0, placeholder.Format.Length - propertyValue.Length) + propertyValue;
              }

              propertyValue = int.Parse(propertyValue).ToString(placeholder.Format);
            }

            parameters[i++] = propertyValue;
              }

              return string.Format(template.Name, parameters);
        }
开发者ID:Vidisha,项目名称:eb,代码行数:37,代码来源:ebDataLayer.cs

示例4: GetDocumentId

 protected int GetDocumentId(IDataObject dataObject)
 {
     return Convert.ToInt32(dataObject.GetPropertyValue("Id"));
 }
开发者ID:Vidisha,项目名称:eb,代码行数:4,代码来源:ebDataLayer.cs

示例5: FormWidget

        private Widget FormWidget(IDataObject dataObject)
        {
            Widget widget = new Widget();

              try
              {
            if (dataObject.GetPropertyValue("Id") != null)
            {
              string identifier = dataObject.GetPropertyValue("Id").ToString();
              int id = 0;
              Int32.TryParse(identifier, out id);
              widget.Id = id;
            }

            if (dataObject.GetPropertyValue("Name") != null)
            {
              widget.Name = dataObject.GetPropertyValue("Name").ToString();
            }

            if (dataObject.GetPropertyValue("Description") != null)
            {
              widget.Description = dataObject.GetPropertyValue("Description").ToString();
            }

            if (dataObject.GetPropertyValue("Material") != null)
            {
              widget.Material = dataObject.GetPropertyValue("Material").ToString();
            }

            if (dataObject.GetPropertyValue("Length") != null)
            {
              string lengthValue = dataObject.GetPropertyValue("Length").ToString();
              double length = 0;
              Double.TryParse(lengthValue, out length);
              widget.Length = length;
            }

            if (dataObject.GetPropertyValue("Width") != null)
            {
              string widthValue = dataObject.GetPropertyValue("Width").ToString();
              double width = 0;
              Double.TryParse(widthValue, out width);
              widget.Width = width;
            }

            if (dataObject.GetPropertyValue("Height") != null)
            {
              string heightValue = dataObject.GetPropertyValue("Height").ToString();
              double height = 0;
              Double.TryParse(heightValue, out height);
              widget.Height = height;
            }

            if (dataObject.GetPropertyValue("Weight") != null)
            {
              string weightValue = dataObject.GetPropertyValue("Weight").ToString();
              double weight = 0;
              Double.TryParse(weightValue, out weight);
              widget.Weight = weight;
            }

            if (dataObject.GetPropertyValue("LengthUOM") != null)
            {
              string lengthUOMValue = dataObject.GetPropertyValue("LengthUOM").ToString();
              LengthUOM lengthUOM = LengthUOM.feet;
              Enum.TryParse<LengthUOM>(lengthUOMValue, out lengthUOM);
              widget.LengthUOM = lengthUOM;
            }

            if (dataObject.GetPropertyValue("WeightUOM") != null)
            {
              string weightUOMValue = dataObject.GetPropertyValue("WeightUOM").ToString();
              WeightUOM weightUOM = WeightUOM.grams;
              Enum.TryParse<WeightUOM>(weightUOMValue, out weightUOM);
              widget.WeightUOM = weightUOM;
            }

            if (dataObject.GetPropertyValue("Color") != null)
            {
              string colorValue = dataObject.GetPropertyValue("Color").ToString();
              Color color = Color.Black;
              Enum.TryParse<Color>(colorValue, out color);
              widget.Color = color;
            }
              }
              catch (Exception ex)
              {
            _logger.ErrorFormat("Error while marshalling a data object into a widget: {1}", ex);
            throw new Exception("Error while marshalling a data object into a widget.", ex);
              }

              return widget;
        }
开发者ID:iringtools,项目名称:samples,代码行数:93,代码来源:ObjectDataLayer.cs

示例6: GetRelatedObjects

        public override IList<IDataObject> GetRelatedObjects(IDataObject dataObject, string relatedObjectType, int pageSize, int startIndex)
        {
            string objectType = dataObject.GetType().Name;

            IList<IDataObject> dataObjects = null;

            if (objectType == typeof(GenericDataObject).Name)
            {
                objectType = ((GenericDataObject)dataObject).ObjectType;
            }

            try
            {
                DataObject parentDataObject = _dataDictionary.dataObjects.Find(x => x.objectName.ToUpper() == objectType.ToUpper());

                if (parentDataObject == null)
                    throw new Exception("Parent data object [" + objectType + "] not found.");

                DataObject relatedObjectDefinition = _dataDictionary.dataObjects.Find(x => x.objectName.ToUpper() == relatedObjectType.ToUpper());

                if (relatedObjectDefinition == null)
                    throw new Exception("Related data object [" + relatedObjectType + "] not found.");

                DataRelationship dataRelationship = parentDataObject.dataRelationships.Find(c => c.relatedObjectName.ToLower() == relatedObjectDefinition.objectName.ToLower());
                if (dataRelationship == null)
                    throw new Exception("Relationship between data object [" + objectType + "] and related data object [" + relatedObjectType + "] not found.");

                DataFilter filter = null;
                foreach (PropertyMap propertyMap in dataRelationship.propertyMaps)
                {
                    filter = new DataFilter();
                    string keyFieldValue = Convert.ToString(dataObject.GetPropertyValue(propertyMap.dataPropertyName));

                    Expression expression = new Expression();
                    expression.LogicalOperator = LogicalOperator.And;
                    expression.RelationalOperator = RelationalOperator.EqualTo;

                    expression.PropertyName = propertyMap.relatedPropertyName;
                    expression.Values = new Values() { keyFieldValue };

                    filter.Expressions.Add(expression);
                }

                dataObjects = Get(relatedObjectType, filter, 0, 0);

            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("Error while geting related data objects", ex);
                throw new Exception("Error while geting related data objects", ex);
            }

            return dataObjects;
        }
开发者ID:iringtools,项目名称:rest_dl,代码行数:54,代码来源:RestDataLayer2.cs

示例7: GetRelatedObjects

        public override IList<IDataObject> GetRelatedObjects(IDataObject dataObject, string relatedObjectType, int pageSize, int startIndex)
        {
            string objectType = dataObject.GetType().Name;

            IList<IDataObject> dataObjects = null;

            if (objectType == typeof(GenericDataObject).Name)
            {
                objectType = ((GenericDataObject)dataObject).ObjectType;
            }

            try
            {
                DataObject parentDataObject = _dataDictionary.dataObjects.Find(x => x.objectName.ToUpper() == objectType.ToUpper());

                if (parentDataObject == null)
                    throw new Exception("Parent data object [" + objectType + "] not found.");

                DataObject relatedObjectDefinition = _dataDictionary.dataObjects.Find(x => x.objectName.ToUpper() == relatedObjectType.ToUpper());

                if (relatedObjectDefinition == null)
                    throw new Exception("Related data object [" + relatedObjectType + "] not found.");

                DataRelationship dataRelationship = parentDataObject.dataRelationships.Find(c => c.relatedObjectName.ToLower() == relatedObjectDefinition.objectName.ToLower());
                if (dataRelationship == null)
                    throw new Exception("Relationship between data object [" + objectType + "] and related data object [" + relatedObjectType + "] not found.");

                string pID = Convert.ToString(dataObject.GetPropertyValue(parentDataObject.keyProperties[0].ToString()));

                string url = GenerateReletedUrl(objectType, pID, relatedObjectType, pageSize, startIndex);

                string jsonString = GetJsonResponseFrom(url);
                DataTable dataTable = GetDataTableFrom(jsonString, objectType);
                dataObjects = ToDataObjects(dataTable, objectType);

            }
            catch (Exception ex)
            {
                _logger.ErrorFormat("Error while geting related data objects", ex);
                throw new Exception("Error while geting related data objects", ex);
            }

            return dataObjects;
        }
开发者ID:iringtools,项目名称:rest_dl,代码行数:44,代码来源:RestDataLayer.cs

示例8: GetIdentifier

        private string GetIdentifier(IDataObject dataObject)
        {
            string[] identifierParts = new string[_objectDefinition.keyProperties.Count];

               int i = 0;
               foreach (KeyProperty keyProperty in _objectDefinition.keyProperties)
               {
               identifierParts[i] = dataObject.GetPropertyValue(keyProperty.keyPropertyName).ToString();
               i++;
               }

               return String.Join(_objectDefinition.keyDelimeter, identifierParts);
        }
开发者ID:iringtools,项目名称:rest_dl,代码行数:13,代码来源:Test.cs


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