コード例 #1
0
        public static uint FromDateTime(DateTime dateTime)
        {
            PscxArgumentOutOfRangeException.ThrowIf("dateTime", (dateTime < UnixEraBegin),
                                                    "DateTime too small for unix time");
            PscxArgumentOutOfRangeException.ThrowIf("dateTime", (dateTime > UnixEraEnd),
                                                    "DateTime too big for unix time");

            return((uint)(dateTime - UnixEraBegin).TotalSeconds);
        }
コード例 #2
0
ファイル: Attributes.cs プロジェクト: modulexcite/pash-1
        public VersionFieldAttribute(uint componentCount, TypeCode componentType)
        {
            PscxArgumentOutOfRangeException.ThrowIf("componentCount",
                                                    componentCount < 1 || componentCount > 4);
            PscxArgumentOutOfRangeException.ThrowIf("componentType",
                                                    componentType <TypeCode.SByte || componentType> TypeCode.UInt64);

            this.type  = componentType;
            this.count = componentCount;
        }
コード例 #3
0
        private Delegate CreateDelegate(Type type)
        {
            if (type.IsAbstract)
            {
                PscxArgumentOutOfRangeException.Throw("Type {0} is abstract.", type.Name);
            }
            // need a target for delegate
            PscxArgumentException.ThrowIf(this._arguments.Length == 0,
                                          "Please supply a ScriptBlock as an argument.");

            // must be a scriptblock
            ScriptBlock target = this._arguments[0] as ScriptBlock;

            PscxArgumentException.ThrowIfIsNull(target, "The only argument in ArgumentList must be a ScriptBlock.");

            Delegate invoker = GetScriptBlockDelegate(target, type);

            return(invoker);
        }