Ejemplo n.º 1
0
        public override string[] GetAllBindingNames()
        {
            if (!ReferenceEquals(_bindingObject, null))
            {
                return(_bindingObject.GetOwnProperties().Select(x => x.Key).ToArray());
            }

            return(ArrayExt.Empty <string>());
        }
Ejemplo n.º 2
0
        public string[] GetKeys(string section)
        {
            if (!_ini.ContainsKey(section))
            {
                return(ArrayExt.Empty <string>());
            }

            return(!_ini.ContainsKey(section)
                                ? ArrayExt.Empty <string>()
                                : _ini[section].Keys.ToArray());
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 使用指定的类型转换器初始化 <see cref="ConverterProvider"/> 类的新实例。
 /// </summary>
 /// <param name="converter">类型转换器。</param>
 /// <param name="inputType">类型转换器的输入类型。</param>
 /// <param name="outputType">类型转换器的输出类型。</param>
 public ConverterProvider(Delegate converter, Type inputType, Type outputType)
 {
     Contract.Requires(converter != null && inputType != null && outputType != null);
     originType = inputType;
     toDict     = new Dictionary <Type, Delegate>(1)
     {
         { outputType, converter }
     };
     fromDict    = new Dictionary <Type, Delegate>();
     toDict      = new Dictionary <Type, Delegate>();
     subProvider = ArrayExt.Empty <IConverterProvider>();
 }
Ejemplo n.º 4
0
        public static JsValue[] Skip(this JsValue[] args, int count)
        {
            var newLength = args.Length - count;

            if (newLength <= 0)
            {
                return(ArrayExt.Empty <JsValue>());
            }

            var array = new JsValue[newLength];

            Array.Copy(args, count, array, 0, newLength);
            return(array);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 使用指定的错误消息和对导致此异常的内部异常的引用初始化 <see cref="AggregateSourceException"/> 类的新实例。
 /// </summary>
 /// <param name="message">解释异常原因的错误消息。</param>
 /// <param name="innerException">导致当前异常的异常。</param>
 public AggregateSourceException(string message, SourceException innerException)
     : base(message, innerException)
 {
     if (innerException == null)
     {
         this.innerExps           = ArrayExt.Empty <SourceException>();
         this.innerExpsCollection = ReadOnlyCollection <SourceException> .Empty;
     }
     else
     {
         this.innerExps           = new[] { innerException };
         this.innerExpsCollection = new ReadOnlyCollection <SourceException>(innerExps);
     }
 }
Ejemplo n.º 6
0
        private static byte[] ReadFirstTwoByteOfFile(string fileName)
        {
            byte[] firstTwoByte = ArrayExt.Empty <byte>();
            try
            {
                using (var iniFile = File.OpenRead(fileName))
                {
                    firstTwoByte = new byte[2];
                    iniFile.Read(firstTwoByte, 0, 2);
                }
            }
            catch { /* ignored */ }

            return(firstTwoByte);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 使用指定的错误消息和对导致此异常的内部异常的引用初始化 <see cref="AggregateSourceException"/> 类的新实例。
 /// </summary>
 /// <param name="message">解释异常原因的错误消息。</param>
 /// <param name="innerException">导致当前异常的异常。</param>
 public AggregateSourceException(string message, Exception innerException)
     : base(message, innerException)
 {
     if (innerException == null)
     {
         this.innerExps           = ArrayExt.Empty <SourceException>();
         this.innerExpsCollection = ReadOnlyCollection <SourceException> .Empty;
     }
     else
     {
         SourceException sourceExp = innerException as SourceException;
         if (sourceExp == null)
         {
             throw CommonExceptions.InvalidCast(innerException.GetType(), typeof(SourceException));
         }
         this.innerExps           = new[] { sourceExp };
         this.innerExpsCollection = new ReadOnlyCollection <SourceException>(innerExps);
     }
 }
Ejemplo n.º 8
0
        public JsValue[] RentArray(int size)
        {
            if (size == 0)
            {
                return(ArrayExt.Empty <JsValue>());
            }
            if (size == 1)
            {
                return(_poolArray1.Allocate());
            }
            if (size == 2)
            {
                return(_poolArray2.Allocate());
            }
            if (size == 3)
            {
                return(_poolArray3.Allocate());
            }

            return(new JsValue[size]);
        }
Ejemplo n.º 9
0
        /// <inheritdoc />
        public override string[] GetAllBindingNames()
        {
            int size = _set ? 1 : 0;

            if (!ReferenceEquals(_argumentsBinding.Value, null))
            {
                size += 1;
            }

            if (_dictionary != null)
            {
                size += _dictionary.Count;
            }

            var keys = size > 0 ? new string[size] : ArrayExt.Empty <string>();
            int n    = 0;

            if (_set)
            {
                keys[n++] = _key;
            }

            if (!ReferenceEquals(_argumentsBinding.Value, null))
            {
                keys[n++] = BindingNameArguments;
            }

            if (_dictionary != null)
            {
                foreach (var key in _dictionary.Keys)
                {
                    keys[n++] = key;
                }
            }

            return(keys);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// 使用指定的错误消息初始化 <see cref="AggregateSourceException"/> 类的新实例。
 /// </summary>
 /// <param name="message">解释异常原因的错误消息。</param>
 public AggregateSourceException(string message)
     : base(message)
 {
     this.innerExps           = ArrayExt.Empty <SourceException>();
     this.innerExpsCollection = ReadOnlyCollection <SourceException> .Empty;
 }