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


C# IProduct.GetProperty方法代码示例

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


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

示例1: GetValue

        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        /// <param name="product"></param>
        /// <param name="mb"></param>
        /// <param name="delivery"></param>
        /// <param name="part"></param>
        /// <param name="name"></param>
        /// <param name="spliter"></param>
        /// <returns></returns>
        public static string GetValue(Session session, 
                                                    IProduct product, 
                                                    IMB mb, 
                                                    Delivery delivery, 
                                                    IPart part,
                                                    string name, char spliter)
        {
            int index = name.IndexOf(spliter);
            if (index < 1)
            {
                throw new Exception("wrong method name : " + name);
            }

            string objName = name.Substring(0, index).ToUpper();
            string objMethod = name.Substring(index + 1).Trim();

            if (objName == "PRODUCTINFO")
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "ProductInfo" });
                }
                return product.ProductInfoes
                                            .Where(x => x.InfoType == objMethod)
                                            .Select(y => y.InfoValue).FirstOrDefault();
            }

            if (objName == "MODELINFO")
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }
                return product.ModelObj.Attributes
                                            .Where(x => x.Name == objMethod)
                                            .Select(y => y.Value).FirstOrDefault();
            }

            if (objName == "FAMILYINFO")
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }
                string family = product.Family;
               
                IList<FamilyInfoDef> familyInfoList = familyRep.GetExistFamilyInfo(new FamilyInfoDef { family = family, name = objMethod });

                if (familyInfoList == null || familyInfoList.Count == 0)
                {
                    throw new FisException("CHK1036", new List<string> { family, objMethod });
                }

                return familyInfoList[0].value;
            }

            if (objName == "PRODUCT")
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }
                string value = (string)product.GetProperty(objMethod);
                if (string.IsNullOrEmpty(value))
                {
                    throw new FisException("not exists property name:" + name);
                }
                return value;
            }

            if (objName == "PCB")
            {
                if (mb == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "PCB" });
                }
                string value = (string)mb.GetProperty(objMethod);
                if (string.IsNullOrEmpty(value))
                {
                    throw new FisException("not exists property name:" + name);
                }
                return value;
            }

            if (objName == "PCBINFO")
            {
                if (mb == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "PCB" });
//.........这里部分代码省略.........
开发者ID:wra222,项目名称:testgit,代码行数:101,代码来源:ResolveValue.cs

示例2: GetValue

        /// <summary>
        /// 
        /// </summary>       
        /// <param name="product"></param>
        /// <param name="mb"></param>
        /// <param name="delivery"></param>
        /// <param name="part"></param>
        /// <param name="name"></param>
        /// <param name="spliter"></param>
        /// <returns></returns>
        public static string GetValue(IProduct product, IMB mb, Delivery delivery, Part part,
                                                    string name, char spliter)
        {
            int index = name.IndexOf(spliter);
            if (index < 1)
            {
                throw new Exception("wrong method name : " + name);
            }

            string objName = name.Substring(0, index).ToUpper();
            string objMethod = name.Substring(index + 1).Trim();

            if (objName == GlobalConstName.ResolveValue.PRODUCTINFO)
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }
                if (product.ProductInfoes == null || 
                    !product.ProductInfoes.Any(x => x.InfoType == objMethod))
                {
                     throw new FisException("CHK1036", new List<string> { product.ProId, name });
                }
                return product.ProductInfoes
                                            .Where(x => x.InfoType == objMethod)
                                            .Select(y => y.InfoValue).FirstOrDefault().Trim();
            }


            if (objName == GlobalConstName.ResolveValue.PRODUCTATTR)
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }
                if (product.ProductAttributes == null ||
                    !product.ProductAttributes.Any(x => x.AttributeName == objMethod))
                {
                    throw new FisException("CHK1036", new List<string> { product.ProId, name });
                }
                return product.ProductAttributes
                                            .Where(x => x.AttributeName == objMethod)
                                            .Select(y => y.AttributeValue).FirstOrDefault().Trim();
            }

            if (objName == GlobalConstName.ResolveValue.MODELINFO)
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }

                if (product.ModelObj ==null||
                    product.ModelObj.Attributes == null ||
                    !product.ModelObj.Attributes.Any(x => x.Name == objMethod))
                {
                     throw new FisException("CHK1036", new List<string> { product.Model, name });
                }

                return product.ModelObj.Attributes
                                            .Where(x => x.Name == objMethod)
                                            .Select(y => y.Value).FirstOrDefault().Trim();
            }

            if (objName == GlobalConstName.ResolveValue.FAMILYINFO)
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }
                string family = product.Family;
                //IFamilyRepository familyRep = RepositoryFactory.GetInstance().GetRepository<IFamilyRepository>();
                IList<FamilyInfoDef> familyInfoList = familyRep.GetExistFamilyInfo(new FamilyInfoDef { family = family, name = objMethod });

                if (familyInfoList == null || familyInfoList.Count == 0)
                {
                    throw new FisException("CHK1036", new List<string> { family, name });
                }

                return familyInfoList[0].value.Trim();
            }

            if (objName == GlobalConstName.ResolveValue.PRODUCT)
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }
                string value = (string)product.GetProperty(objMethod);
                if (string.IsNullOrEmpty(value))
//.........这里部分代码省略.........
开发者ID:wra222,项目名称:testgit,代码行数:101,代码来源:ResolveValue.cs

示例3: GetValue

        /// <summary>
        /// 
        /// </summary>
        /// <param name="session"></param>
        /// <param name="product"></param>
        /// <param name="mb"></param>
        /// <param name="delivery"></param>
        /// <param name="part"></param>
        /// <param name="name"></param>
        /// <param name="spliter"></param>
        /// <returns></returns>
        public static string GetValue(Session session, 
                                                    IProduct product, 
                                                    IMB mb, 
                                                    Delivery delivery, 
                                                    IPart part,
                                                    string name, char spliter)
        {
            int index = name.IndexOf(spliter);
            if (index < 1)
            {
                throw new Exception("wrong method name : " + name);
            }

            string objName = name.Substring(0, index).ToUpper();
            string objMethod = name.Substring(index + 1).Trim();

            if (objName == GlobalConstName.ResolveValue.PRODUCTINFO)
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }
                return product.ProductInfoes
                                            .Where(x => x.InfoType == objMethod)
                                            .Select(y => y.InfoValue).FirstOrDefault();
            }
            if (objName == GlobalConstName.ResolveValue.PRODUCTATTR)
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }
                if (product.ProductAttributes == null ||
                    !product.ProductAttributes.Any(x => x.AttributeName == objMethod))
                {
                    throw new FisException("CHK1036", new List<string> { product.ProId, name });
                }
                return product.ProductAttributes
                                            .Where(x => x.AttributeName == objMethod)
                                            .Select(y => y.AttributeValue).FirstOrDefault().Trim();
            }

            if (objName == GlobalConstName.ResolveValue.MODEL)
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });                   
                }

                if (product.ModelObj == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product.ModelObj" });
                }

                object value = product.ModelObj.GetProperty(objMethod);
                if (value == null)
                {
                    return null;
                }
                return value.ToString().Trim();

            }

            if (objName == GlobalConstName.ResolveValue.MODELINFO)
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }

                if (product.ModelObj == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product.ModelObj" });
                }

                return product.ModelObj.Attributes
                                            .Where(x => x.Name == objMethod)
                                            .Select(y => y.Value).FirstOrDefault();
            }

            if (objName == GlobalConstName.ResolveValue.FAMILYINFO)
            {
                if (product == null)
                {
                    throw new FisException("CQCHK0006", new List<string> { "Product" });
                }
                string family = product.Family;
                //IFamilyRepository familyRep = RepositoryFactory.GetInstance().GetRepository<IFamilyRepository>();
                IList<FamilyInfoDef> familyInfoList = familyRep.GetExistFamilyInfo(new FamilyInfoDef { family = family, name = objMethod });
//.........这里部分代码省略.........
开发者ID:wra222,项目名称:testgit,代码行数:101,代码来源:ResolveValue.cs

示例4: getValueInner

        private static string getValueInner(Session session, IProduct product, IMB mb, Delivery delivery, IPart part,
                                                            string name, char spliter, bool isThrowError)
        {
            int index = name.IndexOf(spliter);
            if (index < 1)
            {
                throw new Exception("wrong method name : " + name);
            }

            string objName = name.Substring(0, index);
            string objMethod = name.Substring(index + 1).Trim();

            if (string.Compare(objName, GlobalConstName.ResolveValue.PRODUCTINFO, true) == 0)
            {
                if (product == null)
                {
                    if (isThrowError)
                    {
                        throw new FisException("CQCHK0006", new List<string> { "Product" });
                    }
                    else
                    {
                        return null;
                    }
                }
                if (product.ProductInfoes == null ||
                   !product.ProductInfoes.Any(x => x.InfoType == objMethod))
                {
                    if (isThrowError)
                    {
                        throw new FisException("CHK1036", new List<string> { product.ProId, name });
                    }
                    else
                    {
                        return null;
                    }
                }

                return product.ProductInfoes
                                            .Where(x => x.InfoType == objMethod)
                                            .Select(y => y.InfoValue).FirstOrDefault();
            }
            if (string.Compare(objName, GlobalConstName.ResolveValue.PRODUCTATTR, true) == 0)
            {
                if (product == null)
                {
                    if (isThrowError)
                    {
                        throw new FisException("CQCHK0006", new List<string> { "Product" });
                    }
                    else
                    {
                        return null;
                    }
                }
                if (product.ProductAttributes == null ||
                    !product.ProductAttributes.Any(x => x.AttributeName == objMethod))
                {
                    if (isThrowError)
                    {
                        throw new FisException("CHK1036", new List<string> { product.ProId, name });
                    }
                    else
                    {
                        return null;
                    }
                }
                return product.ProductAttributes
                                            .Where(x => x.AttributeName == objMethod)
                                            .Select(y => y.AttributeValue).FirstOrDefault().Trim();
            }

            if (string.Compare(objName, GlobalConstName.ResolveValue.MODEL,true) == 0)
            {
                if (product == null)
                {
                    if (isThrowError)
                    {
                        throw new FisException("CQCHK0006", new List<string> { "Product" });
                    }
                    else
                    {
                        return null;
                    }
                }

                if (product.ModelObj == null)
                {
                    if (isThrowError)
                    {
                        throw new FisException("CQCHK0006", new List<string> { "Product.ModelObj" });
                    }
                    else
                    {
                        return null;
                    }                    
                }

                object value = product.ModelObj.GetProperty(objMethod);
                if (value == null)
//.........这里部分代码省略.........
开发者ID:wra222,项目名称:testgit,代码行数:101,代码来源:ResolveValue.cs


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