コード例 #1
0
ファイル: PDateTime.cs プロジェクト: videoai/papillon-swig
 public PDateTime(PDate date, PTime time) : this(PapillonPINVOKE.new_PDateTime__SWIG_2(PDate.getCPtr(date), PTime.getCPtr(time)), true)
 {
     if (PapillonPINVOKE.SWIGPendingException.Pending)
     {
         throw PapillonPINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #2
0
        bool Clear(ref PObject plist)
        {
            if (Type != null)
            {
                switch (Type.ToLowerInvariant())
                {
                case "string": plist = new PString(string.Empty); break;

                case "array": plist = new PArray(); break;

                case "dict": plist = new PDictionary(); break;

                case "bool": plist = new PBoolean(false); break;

                case "real": plist = new PReal(0); break;

                case "integer": plist = new PNumber(0); break;

                case "date": plist = new PDate(DateTime.Now); break;

                case "data": plist = new PData(new byte[1]); break;

                default:
                    Log.LogError(7045, null, $"Unrecognized Type: {Type}");
                    return(false);
                }
            }
            else
            {
                plist = PObject.Create(plist.Type);
            }

            return(true);
        }
コード例 #3
0
ファイル: PDate.cs プロジェクト: videoai/papillon-swig
 public PDate(PDate other) : this(PapillonPINVOKE.new_PDate__SWIG_1(PDate.getCPtr(other)), true)
 {
     if (PapillonPINVOKE.SWIGPendingException.Pending)
     {
         throw PapillonPINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #4
0
ファイル: PDate.cs プロジェクト: videoai/papillon-swig
    public int Compare(PDate other)
    {
        int ret = PapillonPINVOKE.PDate_Compare(swigCPtr, PDate.getCPtr(other));

        if (PapillonPINVOKE.SWIGPendingException.Pending)
        {
            throw PapillonPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
コード例 #5
0
ファイル: PDate.cs プロジェクト: videoai/papillon-swig
    public int GetDaysTo(PDate d)
    {
        int ret = PapillonPINVOKE.PDate_GetDaysTo(swigCPtr, PDate.getCPtr(d));

        if (PapillonPINVOKE.SWIGPendingException.Pending)
        {
            throw PapillonPINVOKE.SWIGPendingException.Retrieve();
        }
        return(ret);
    }
コード例 #6
0
ファイル: CDate.cs プロジェクト: bittercoder/Machete
        public override IObject Construct(IEnvironment environment, IArgs args)
        {
            var r = new NDate(environment);

            r.Class      = "Date";
            r.Extensible = true;
            r.Prototype  = environment.DatePrototype;

            var    argCount  = args.Count;
            double timeValue = 0.0;

            if (argCount == 0)
            {
                timeValue = (DateTime.UtcNow - _utcStart).TotalMilliseconds;
            }
            else if (argCount == 1)
            {
                var value = args[0].ConvertToPrimitive(null);
                if (value.TypeCode == LanguageTypeCode.String)
                {
                    timeValue = Parse(environment, args).ConvertToNumber().BaseValue;
                }
                else
                {
                    timeValue = value.ConvertToNumber().BaseValue;
                }
            }
            else
            {
                var year    = args[0].ConvertToNumber().ConvertToInteger().BaseValue;
                var month   = args[1].ConvertToNumber().BaseValue;
                var date    = argCount > 2 ? args[2].ConvertToNumber().BaseValue : 1.0;
                var hours   = argCount > 3 ? args[3].ConvertToNumber().BaseValue : 0.0;
                var minutes = argCount > 4 ? args[4].ConvertToNumber().BaseValue : 0.0;
                var seconds = argCount > 5 ? args[5].ConvertToNumber().BaseValue : 0.0;
                var ms      = argCount > 6 ? args[6].ConvertToNumber().BaseValue : 0.0;

                if (!double.IsNaN(year) && year >= 0.0 && year <= 99)
                {
                    year = 1900.0 + year;
                }

                var dayPortion  = PDate.MakeDay(year, month, date);
                var timePortion = PDate.MakeTime(hours, minutes, seconds, ms);
                var dateValue   = PDate.MakeDate(dayPortion, timePortion);

                timeValue = PDate.TimeClip(PDate.UTC(dateValue));
            }

            r.PrimitiveValue = environment.CreateNumber(PDate.TimeClip(timeValue));
            return(r);
        }
コード例 #7
0
            public int Compare(PObject x, PObject y)
            {
                var   profileX = (PDictionary)x;
                var   profileY = (PDictionary)y;
                PDate ctimeX, ctimeY;

                if (!profileX.TryGetValue("CreationDate", out ctimeX))
                {
                    ctimeX = new PDate(DateTime.UtcNow);
                }

                if (!profileY.TryGetValue("CreationDate", out ctimeY))
                {
                    ctimeX = new PDate(DateTime.UtcNow);
                }

                return(ctimeX.Value.CompareTo(ctimeY.Value));
            }
コード例 #8
0
    static int DayNo(PDate pd)
    {
        int retValue = 0;

        int n = 0;

        if (pd.month < 7)
        {
            n = (pd.month - 1) * 31 + pd.day;
        }
        else
        {
            n = 186 + (((pd.month - 7) * 30) + pd.day);
        }
        retValue = n;

        return(retValue);
    }
コード例 #9
0
ファイル: CDate.cs プロジェクト: bittercoder/Machete
        internal static IDynamic Utc(IEnvironment environment, IArgs args)
        {
            var argCount = args.Count;
            var year     = args[0].ConvertToNumber().ConvertToInteger().BaseValue;
            var month    = args[1].ConvertToNumber().BaseValue;
            var date     = argCount > 2 ? args[2].ConvertToNumber().BaseValue : 1.0;
            var hours    = argCount > 3 ? args[3].ConvertToNumber().BaseValue : 0.0;
            var minutes  = argCount > 4 ? args[4].ConvertToNumber().BaseValue : 0.0;
            var seconds  = argCount > 5 ? args[5].ConvertToNumber().BaseValue : 0.0;
            var ms       = argCount > 6 ? args[6].ConvertToNumber().BaseValue : 0.0;

            if (!double.IsNaN(year) && year >= 0.0 && year <= 99)
            {
                year = 1900.0 + year;
            }

            var dayPortion  = PDate.MakeDay(year, month, date);
            var timePortion = PDate.MakeTime(hours, minutes, seconds, ms);
            var dateValue   = PDate.MakeDate(dayPortion, timePortion);

            return(environment.CreateNumber(PDate.TimeClip(dateValue)));
        }
コード例 #10
0
ファイル: Environment.cs プロジェクト: bittercoder/Machete
        public Environment()
        {
            Output    = new Output();
            EmptyArgs = new SArgs(this);
            True      = new LBoolean(this, true);
            False     = new LBoolean(this, false);
            Undefined = new LUndefined(this);
            Null      = new LNull(this);

            GlobalObject              = new BGlobal(this);
            GlobalEnvironment         = new SLexicalEnvironment(this, new SObjectEnvironmentRecord(this, GlobalObject, false), null);
            MathObject                = new BMath(this);
            JsonObject                = new BJson(this);
            ObjectConstructor         = new CObject(this);
            FunctionConstructor       = new CFunction(this);
            ArrayConstructor          = new CArray(this);
            StringConstructor         = new CString(this);
            BooleanConstructor        = new CBoolean(this);
            NumberConstructor         = new CNumber(this);
            DateConstructor           = new CDate(this);
            RegExpConstructor         = new CRegExp(this);
            ErrorConstructor          = new CError(this);
            EvalErrorConstructor      = new CEvalError(this);
            RangeErrorConstructor     = new CRangeError(this);
            ReferenceErrorConstructor = new CReferenceError(this);
            SyntaxErrorConstructor    = new CSyntaxError(this);
            TypeErrorConstructor      = new CTypeError(this);
            UriErrorConstructor       = new CUriError(this);
            ObjectPrototype           = new PObject(this);
            FunctionPrototype         = new PFunction(this);
            ArrayPrototype            = new PArray(this);
            StringPrototype           = new PString(this);
            BooleanPrototype          = new PBoolean(this);
            NumberPrototype           = new PNumber(this);
            DatePrototype             = new PDate(this);
            RegExpPrototype           = new PRegExp(this);
            ErrorPrototype            = new PError(this);
            EvalErrorPrototype        = new PEvalError(this);
            RangeErrorPrototype       = new PRangeError(this);
            ReferenceErrorPrototype   = new PReferenceError(this);
            SyntaxErrorPrototype      = new PSyntaxError(this);
            TypeErrorPrototype        = new PTypeError(this);
            UriErrorPrototype         = new PUriError(this);

            GlobalObject.Initialize();
            MathObject.Initialize();
            JsonObject.Initialize();
            ObjectConstructor.Initialize();
            FunctionConstructor.Initialize();
            ArrayConstructor.Initialize();
            StringConstructor.Initialize();
            BooleanConstructor.Initialize();
            NumberConstructor.Initialize();
            DateConstructor.Initialize();
            RegExpConstructor.Initialize();
            ErrorConstructor.Initialize();
            EvalErrorConstructor.Initialize();
            RangeErrorConstructor.Initialize();
            ReferenceErrorConstructor.Initialize();
            SyntaxErrorConstructor.Initialize();
            TypeErrorConstructor.Initialize();
            UriErrorConstructor.Initialize();
            ObjectPrototype.Initialize();
            FunctionPrototype.Initialize();
            ArrayPrototype.Initialize();
            StringPrototype.Initialize();
            BooleanPrototype.Initialize();
            NumberPrototype.Initialize();
            DatePrototype.Initialize();
            RegExpPrototype.Initialize();
            ErrorPrototype.Initialize();
            EvalErrorPrototype.Initialize();
            RangeErrorPrototype.Initialize();
            ReferenceErrorPrototype.Initialize();
            SyntaxErrorPrototype.Initialize();
            TypeErrorPrototype.Initialize();
            UriErrorPrototype.Initialize();
        }
コード例 #11
0
        bool CreateValue(string type, string text, out PObject value)
        {
            DateTime date    = DateTime.Now;
            bool     boolean = false;
            double   real    = 0;
            int      integer = 0;

            value = null;

            switch (type.ToLowerInvariant())
            {
            case "string":
                value = new PString(text);
                return(true);

            case "array":
                value = new PArray();
                return(true);

            case "dict":
                value = new PDictionary();
                return(true);

            case "bool":
                if (text == null || !bool.TryParse(text, out boolean))
                {
                    boolean = false;
                }

                value = new PBoolean(boolean);
                return(true);

            case "real":
                if (text != null && !double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out real))
                {
                    Log.LogError(7045, null, "Unrecognized Real Format");
                    return(false);
                }

                value = new PReal(real);
                return(true);

            case "integer":
                if (text != null && !int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out integer))
                {
                    Log.LogError(7045, null, "Unrecognized Integer Format");
                    return(false);
                }

                value = new PNumber(integer);
                return(true);

            case "date":
                if (text != null && !DateTime.TryParse(text, CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
                {
                    Log.LogError(7045, null, "Unrecognized Date Format");
                    return(false);
                }

                value = new PDate(date);
                return(true);

            case "data":
                if (text != null)
                {
                    value = new PData(Encoding.UTF8.GetBytes(Value));
                }
                else
                {
                    value = new PData(new byte[0]);
                }
                return(true);

            default:
                Log.LogError(7045, null, $"Unrecognized Type: {type}");
                value = null;
                return(false);
            }
        }
コード例 #12
0
ファイル: PDate.cs プロジェクト: videoai/papillon-swig
    public PDate AddMonths(int nmonths)
    {
        PDate ret = new PDate(PapillonPINVOKE.PDate_AddMonths(swigCPtr, nmonths), true);

        return(ret);
    }
コード例 #13
0
ファイル: PDate.cs プロジェクト: videoai/papillon-swig
    public PDate AddDays(int ndays)
    {
        PDate ret = new PDate(PapillonPINVOKE.PDate_AddDays(swigCPtr, ndays), true);

        return(ret);
    }
コード例 #14
0
ファイル: PDateTime.cs プロジェクト: videoai/papillon-swig
    public PDate GetDate()
    {
        PDate ret = new PDate(PapillonPINVOKE.PDateTime_GetDate(swigCPtr), true);

        return(ret);
    }
コード例 #15
0
ファイル: PDate.cs プロジェクト: videoai/papillon-swig
    public PDate AddYears(int nyears)
    {
        PDate ret = new PDate(PapillonPINVOKE.PDate_AddYears(swigCPtr, nyears), true);

        return(ret);
    }
コード例 #16
0
        static PDictionary OpenIndex()
        {
            PDictionary plist;

            try {
                plist = PDictionary.FromFile(IndexFileName);

                if (Directory.Exists(MobileProvision.ProfileDirectory))
                {
                    var mtime = Directory.GetLastWriteTimeUtc(MobileProvision.ProfileDirectory);

                    if (VersionChanged(plist, IndexVersion))
                    {
                        plist = CreateIndex();
                    }
                    else if (LastModifiedChanged(plist, mtime))
                    {
                        var    table = new Dictionary <string, PDictionary> ();
                        PArray profiles;

                        if (plist.TryGetValue("ProvisioningProfiles", out profiles))
                        {
                            foreach (var profile in profiles.OfType <PDictionary> ())
                            {
                                PString fileName;

                                if (!profile.TryGetValue("FileName", out fileName))
                                {
                                    continue;
                                }

                                table[fileName.Value] = profile;
                            }
                        }
                        else
                        {
                            plist.Add("ProvisioningProfiles", profiles = new PArray());
                        }

                        foreach (var fileName in Directory.EnumerateFiles(MobileProvision.ProfileDirectory))
                        {
                            if (!fileName.EndsWith(".mobileprovision", StringComparison.Ordinal) && !fileName.EndsWith(".provisionprofile", StringComparison.Ordinal))
                            {
                                continue;
                            }

                            bool        unknown = false;
                            PDictionary profile;

                            if (table.TryGetValue(Path.GetFileName(fileName), out profile))
                            {
                                // remove from our lookup table (any leftover key/valie pairs will be used to determine deleted files)
                                table.Remove(Path.GetFileName(fileName));

                                // check if the file has changed since our last resync
                                mtime = File.GetLastWriteTimeUtc(fileName);

                                if (LastModifiedChanged(profile, mtime))
                                {
                                    // remove the old record
                                    profile.Remove();

                                    // treat this provisioning profile as if it is unknown
                                    unknown = true;
                                }
                            }
                            else
                            {
                                unknown = true;
                            }

                            if (unknown)
                            {
                                // unknown provisioning profile; add it to our ProvisioningProfiles array
                                try {
                                    profile = CreateIndexRecord(fileName);
                                    profiles.Add(profile);
                                } catch (Exception ex) {
                                    LoggingService.LogWarning("Error reading provisioning profile '{0}': {1}", fileName, ex);
                                }
                            }
                        }

                        // remove provisioning profiles which have been deleted from the file system
                        foreach (var record in table)
                        {
                            record.Value.Remove();
                        }

                        plist["LastModified"] = new PDate(Directory.GetLastWriteTimeUtc(MobileProvision.ProfileDirectory));
                        plist["Version"]      = new PNumber(IndexVersion);

                        profiles.Sort(CreationDateComparer);

                        Save(plist);
                    }
                }
                else
                {
                    try {
                        File.Delete(IndexFileName);
                    } catch (Exception ex) {
                        LoggingService.LogWarning("Failed to delete stale index '{0}': {1}", IndexFileName, ex);
                    }

                    plist.Clear();
                }
            } catch {
                plist = CreateIndex();
            }

            return(plist);
        }
コード例 #17
0
ファイル: PDate.cs プロジェクト: videoai/papillon-swig
    public static PDate Current()
    {
        PDate ret = new PDate(PapillonPINVOKE.PDate_Current(), true);

        return(ret);
    }
コード例 #18
0
ファイル: PDate.cs プロジェクト: videoai/papillon-swig
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PDate obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }