Example #1
0
        /// <summary>
        /// Verify that user type is valid
        /// </summary>
        /// <typeparam name="T">type</typeparam>
        /// <param name="name"></param>
        /// <param name="userType"></param>
        /// <param name="allowNull"></param>
        public static void IsValueValid <T>(string name, ICustomType <T> userType, bool allowNull = false)
        {
            Verify.IsNotEmpty(nameof(name), name);
            Verify.Assert <ArgumentNullException>(allowNull || userType != null, name);

            if (userType != null)
            {
                Verify.Assert(userType.IsValueValid(), name);
            }
        }
        //从另一个规格创建
        private ProductSpec(ICustomType ownerProductType, string specName, string workStationName, Dictionary <string, IBasicValue> features)
        {
            _ownerType      = ownerProductType;
            SpecName        = specName;
            WorkStationName = workStationName;

            foreach (var item in features)
            {
                _features.Add(item.Key, item.Value);
            }
        }
Example #3
0
 internal void WriteInternal(ICustomType value)
 {
     for (byte i = 0; i < value.TotalBits; i++)
     {
         var bit      = value.GetBit(i);
         var bitValue = (byte)(bit << (_bitsPosition % 8));
         _pendingByteValue += bitValue;
         _bitsPosition++;
         _hasPendingWrites = true;
         FlushOnByteBoundary();
     }
 }
        // 删除自定义类型
        private static void RemoveCustomType(ICustomType customType)
        {
            try
            {
                TypedCustomTypeCollections[customType.Type].Remove(customType); // 从分类资源池

                CustomTypeCollections.Remove(customType.Name);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        // 增加自定义类型
        public static void AddCustomType(ICustomType customType)
        {
            try
            {
                TypedCustomTypeCollections[customType.Type].Add(customType); // 增加到分类类型池

                CustomTypeCollections.Add(customType.Name, customType);      // 增加到公共类型池
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
        public void Remove(ICustomType item)
        {
            if (item.Type == _strCustomizedType)
            {
                _customizedTypeList.Remove(item.Name);
            }
            else
            {
                var errorMsg = $"往类型池:{item.Type}里删除类型:{item.Name}不匹配";

                throw new Exception(errorMsg);
            }
        }
        //从另一个规格创建
        public TraySpec(ICustomType ownerType, string specName, Dictionary <string, object> Features)
        {
            var trayType = (ProductTrayType)ownerType;

            _ownerType              = ownerType;
            SpecName                = specName;
            ProductCount            = trayType.ProductCount;
            RetentionSecondsSetting = trayType.RetentionSecondsSetting;

            foreach (var feature in Features)
            {
                _features.Add(feature.Key, feature.Value);
            }
        }
        public void Add(ICustomType item)
        {
            if (item.Type == _strCustomizedType)
            {
                _customizedTypeList.Add(item.Name, item);
            }
            else
            {
                var errorMsg = $"往类型池:{item.Type}里添加类型:{item.Name}不匹配";
                //LOG.Error(errorMsg);

                throw new Exception(errorMsg);
            }
        }
        //初始化一个规格
        public ProductSpec(ICustomType ownerProductType, string specName)
        {
            _ownerType = ownerProductType;
            SpecName   = specName;

            var productType = (ProductType)ownerProductType;

            //初始化特征集合
            var features = productType.GetFeatures();

            foreach (var item in features)
            {
                var featureName  = item.Key;
                var featureValue = item.Value;
                _features.Add(featureName, featureValue);
            }
        }
        //初始化一个规格
        public TraySpec(ICustomType OwnerType, string SpecName)
        {
            var trayType = (ProductTrayType)OwnerType;

            _ownerType              = OwnerType;
            this.SpecName           = SpecName;
            ProductCount            = trayType.ProductCount;
            RetentionSecondsSetting = trayType.RetentionSecondsSetting;


            //初始化特征集合
            var features = trayType.GetFeatures();

            foreach (var item in features)
            {
                var featureName  = item.Key;
                var featureValue = item.Value;
                _features.Add(featureName, featureValue);
            }
        }
Example #11
0
 public bool Equals(ICustomType other)
 {
     return(false);
 }