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


C# Asset.EnsureAttribute方法代码示例

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


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

示例1: SetAssetAttribute

 private static void SetAssetAttribute(Asset asset, string attrName, object value) {
     var type = asset.AssetType;
     var def = type.GetAttributeDefinition(attrName);
     
     if (value == null || (value is Oid && value.Equals(Oid.Null))) {
         asset.EnsureAttribute(def);
     } else {
         asset.SetAttributeValue(def, value);
     }
 }
开发者ID:cagatayalkan,项目名称:VersionOne.Client.VisualStudio,代码行数:10,代码来源:AssetFactory.cs

示例2: Validate

        /// <summary>
        /// Validate single Asset attribute. If attribute is not loaded, it is just considered invalid.
        /// </summary>
        /// <param name="asset">Asset to validate</param>
        /// <param name="attributeDefinition">Attribute definition of validated attribute</param>
        /// <returns>Validation result</returns>
        // TODO create separate private method to avoid excessive GetRequiredFields() calls
        public bool Validate(Asset asset, IAttributeDefinition attributeDefinition)
        {
            GetRequiredFields(asset.AssetType);
            asset.EnsureAttribute(attributeDefinition);
            Attribute attribute = asset.GetAttribute(attributeDefinition);
            bool result = attribute != null && !(IsMultiValueAndUnfilled(attribute) || IsSingleValueAndUnfilled(attribute));

            if (!result && attribute != null)
            {
                result = !attribute.HasChanged && !isAttributeUnfilledOnServer(asset, attributeDefinition);
            }

            return result;
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:21,代码来源:RequiredFieldValidator.cs

示例3: ParseAttributeNode

        private static void ParseAttributeNode(Asset asset, IAttributeDefinition attribdef, XmlElement element) {
            var type = element.LocalName;

            asset.EnsureAttribute(attribdef);

            if (type == "Relation") {
                if (attribdef.IsMultiValue) {
                    foreach (XmlElement child in element.ChildNodes) {
                        var add = child.HasAttribute("act") && child.GetAttribute("act") == "add";

                        var token = child.GetAttribute("idref");

                        if(add) {
                            asset.AddAttributeValue(attribdef, token);
                        } else {
                            asset.LoadAttributeValue(attribdef, token);
                        }
                    }
                } else {
                    var token = Oid.Null.Token;

                    if(element.HasChildNodes) {
                        token = ((XmlElement) element.ChildNodes.Item(0)).GetAttribute("idref");
                    }

                    var force = element.HasAttribute("act") && element.GetAttribute("act") == "set";

                    if(force) {
                        asset.ForceAttributeValue(attribdef, token);
                    } else {
                        asset.LoadAttributeValue(attribdef, token);
                    }
                }
            } else {
                if (attribdef.IsMultiValue) {
                    foreach (XmlElement child in element.ChildNodes) {
                        var add = child.HasAttribute("act") && child.GetAttribute("act") == "add";

                        if(add) {
                            asset.AddAttributeValue(attribdef, child.InnerText);
                        } else {
                            asset.LoadAttributeValue(attribdef, child.InnerText);
                        }
                    }
                } else {
                    object v = null;

                    if(!string.IsNullOrEmpty(element.InnerText)) {
                        v = element.InnerText;
                    }

                    var force = element.HasAttribute("act") && element.GetAttribute("act") == "set";

                    if(force) {
                        asset.ForceAttributeValue(attribdef, v);
                    } else {
                        asset.LoadAttributeValue(attribdef, v);
                    }
                }
            }
        }
开发者ID:RedwardsiPipeline,项目名称:VersionOne.SDK.NET.APIClient,代码行数:61,代码来源:Services.cs

示例4: SetupAssetAttributes

 private void SetupAssetAttributes(Asset asset, string typeToken) {
     foreach (var attrInfo in attributesToQuery.Where(attrInfo => attrInfo.Prefix == typeToken)) {
         try {
             var def = dataLayer.Types[attrInfo.Prefix].GetAttributeDefinition(attrInfo.Attr);
             asset.EnsureAttribute(def);
         } catch(MetaException ex) {
             logger.Warn("Problem setting up attribute: " + ex.Message);
         }
     }
 }
开发者ID:cagatayalkan,项目名称:VersionOne.Client.VisualStudio,代码行数:10,代码来源:AssetFactory.cs


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