Esempio n. 1
0
 /// <summary>
 /// Determines whether the specified <see cref="Range"/> is equal to this instance.
 /// </summary>
 /// <param name="other">The <see cref="Range"/> to compare with this instance.</param>
 public bool Equals(Range other)
 {
     return(Begin.Equals(other.Begin) &&
            End.Equals(other.End));
 }
Esempio n. 2
0
 /// <summary>
 /// Get a hash code for this ip address range
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     return((Begin == null ? 0 : Begin.GetHashCode()) + (End == null ? 0 : End.GetHashCode()));
 }
 /// <summary>
 /// Returns a Cidr String if this matches exactly a Cidr subnet
 /// </summary>
 public string ToCidrString()
 {
     return(string.Format("{0}/{1}", Begin.ToString(), GetPrefixLength()));
 }
Esempio n. 4
0
 /// <inheritdoc />
 public override string Print() => Begin == End || End == null
     ? $"{Array?.Print()}[{Begin.Print()}]"
     : $"{Array?.Print()}[{Begin.Print()}..{End.Print()}]";
Esempio n. 5
0
 public override int GetHashCode()
 {
     return(Position.GetHashCode() +
            Begin.GetHashCode() +
            Angle.GetHashCode());
 }
Esempio n. 6
0
        // do NOT use ConfigureAwait(false) on ProcessAsync()
        // often calls events which prints to forms in the UI context
        public async Task <StatusHandler> ProcessAsync(LibraryBook libraryBook)
        {
            Begin?.Invoke(this, libraryBook);

            try
            {
                var aaxFilename = AudibleFileStorage.AAX.GetPath(libraryBook.Book.AudibleProductId);

                if (aaxFilename == null)
                {
                    return new StatusHandler {
                               "aaxFilename parameter is null"
                    }
                }
                ;
                if (!File.Exists(aaxFilename))
                {
                    return new StatusHandler {
                               $"Cannot find AAX file: {aaxFilename}"
                    }
                }
                ;
                if (AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId))
                {
                    return new StatusHandler {
                               "Cannot find decrypt. Final audio file already exists"
                    }
                }
                ;

                var outputAudioFilename = await aaxToM4bConverterDecrypt(aaxFilename, libraryBook);

                // decrypt failed
                if (outputAudioFilename == null)
                {
                    return new StatusHandler {
                               "Decrypt failed"
                    }
                }
                ;

                var destinationDir = moveFilesToBooksDir(libraryBook.Book, outputAudioFilename);

                var config = Configuration.Instance;
                if (config.RetainAaxFiles)
                {
                    var newAaxFilename = FileUtility.GetValidFilename(
                        destinationDir,
                        Path.GetFileNameWithoutExtension(aaxFilename),
                        "aax");

                    File.Move(aaxFilename, newAaxFilename);
                }
                else
                {
                    Dinah.Core.IO.FileExt.SafeDelete(aaxFilename);
                }

                var finalAudioExists = AudibleFileStorage.Audio.Exists(libraryBook.Book.AudibleProductId);
                if (!finalAudioExists)
                {
                    return new StatusHandler {
                               "Cannot find final audio file after decryption"
                    }
                }
                ;

                return(new StatusHandler());
            }
            finally
            {
                Completed?.Invoke(this, libraryBook);
            }
        }
 public bool Equals(IPAddressRange other)
 {
     return(other != null && Begin.Equals(other.Begin) && End.Equals(other.End));
 }
 public virtual void RotateAroundPoint(double ang, Point p = null)
 {
     Begin = Begin.Rotate(ang, p);
     End   = End.Rotate(ang, p);
 }
Esempio n. 9
0
 private void BeginCallback(PrimitiveType type)
 {
     Begin?.Invoke(this, new TessellatorBeginEventArgs(type));
 }
Esempio n. 10
0
        public void Do(ReplaceLogicParam param, IProgress <int> informer)
        {
            //処理対象のファイル一覧
            var targets = new List <string>();

            //ディレクトリを見つけた場合は、一度スタックにつめる
            var directories = new Stack <String>();

            directories.Push(param.RootDir);

            //ディレクトリの中身を確認
            while (directories.Count > 0)
            {
                // ファイルを取得し、ファイル名が処理対象のパターンを満たすか確認
                var directory = directories.Pop();
                foreach (var newFile in Directory.GetFiles(directory))
                {
                    // 隠しファイルは無視するか?
                    if (param.IgnoreHide)
                    {
                        var fileinfo = new FileInfo(newFile);
                        if (fileinfo.Attributes.HasFlag(FileAttributes.Hidden))
                        {
                            continue;
                        }
                    }

                    // パターンのチェック
                    foreach (var filePtnRegex in param.FilePatternRegexes)
                    {
                        if (filePtnRegex.IsMatch(newFile))
                        {
                            // 処理対象
                            targets.Add(newFile);
                            break;
                        }
                    }
                }

                // ディレクトリを取得し、スタックに詰める
                foreach (var newDirectory in Directory.GetDirectories(directory))
                {
                    // 隠しファイルは無視するか?
                    if (param.IgnoreHide)
                    {
                        var dirInfo = new DirectoryInfo(newDirectory);
                        if (dirInfo.Attributes.HasFlag(FileAttributes.Hidden))
                        {
                            continue;
                        }
                    }

                    // 一度スタックにつめる
                    directories.Push(newDirectory);
                }
            }

            // ファイルを1件ずつ置換処理開始
            long index = 1;
            long total = targets.Count;

            foreach (var target in targets)
            {
                try
                {
                    if (Begin != null)
                    {
                        Begin.Invoke(target);
                    }
                    TryReplace(target, param.Encoding, param.Keywords);
                    if (End != null)
                    {
                        End.Invoke();
                    }
                }
                catch (IOException ioe)
                {
                    if (ErrorEnd != null)
                    {
                        ErrorEnd.Invoke(ioe.Message);
                    }
                }

                informer.Report((int)(Int32.MaxValue * index / total));
                ++index;
            }
        }
Esempio n. 11
0
 public void MoveBy(int x, int y)
 {
     Begin = Begin.MovedBy(x, y);
     End   = End.MovedBy(x, y);
 }
Esempio n. 12
0
 public IDiagram MovedBy(int x, int y)
 {
     return(new Line(Begin.MovedBy(x, y), End.MovedBy(x, y)));
 }
Esempio n. 13
0
 public override int GetHashCode()
 {
     return(1903003160 ^ Begin.GetHashCode() ^ End.GetHashCode());
 }
Esempio n. 14
0
 /// <summary>
 /// Returns a Cidr String if this matches exactly a Cidr subnet
 /// </summary>
 public string ToCidrString()
 {
     return(Begin.ToString() + "/" + GetPrefixLength().ToString(CultureInfo.InvariantCulture));
 }
Esempio n. 15
0
 public AboutUs()
 {
     InitializeComponent();
     Begin.Begin();
 }
    private Node sequence(Node end) {
        Node head = null;
        Node tail = null;
        Node node = null;
        for (;;) {
            int ch = peek();
            switch (ch) {
            case '(':
                // Because group handles its own closure,
                // we need to treat it differently
                node = group0();
                // Check for comment or flag group
                if (node == null)
                    continue;
                if (head == null)
                    head = node;
                else
                    tail.next = node;
                // Double return: Tail was returned in root
                tail = root;
                continue;
            case '[':
                node = clazz(true);
                break;
            case '\\':
                ch = nextEscaped();
                if (ch == 'p' || ch == 'P') {
                    boolean oneLetter = true;
                    boolean comp = (ch == 'P');
                    ch = next(); // Consume { if present
                    if (ch != '{') {
                        unread();
                    } else {
                        oneLetter = false;
                    }
                    node = family(oneLetter, comp);
                } else {
                    unread();
                    node = atom();
                }
                break;
            case '^':
                next();
                if (has(MULTILINE)) {
                    if (has(UNIX_LINES))
                        node = new UnixCaret();
                    else
                        node = new Caret();
                } else {
                    node = new Begin();
                }
                break;
            case '$':
                next();
                if (has(UNIX_LINES))
                    node = new UnixDollar(has(MULTILINE));
                else
                    node = new Dollar(has(MULTILINE));
                break;
            case '.':
                next();
                if (has(DOTALL)) {
                    node = new All();
                } else {
                    if (has(UNIX_LINES))
                        node = new UnixDot();
                    else {
                        node = new Dot();
                    }
                }
                break;
            case '|':
            case ')':
                goto end2;
            case ']': // Now interpreting dangling ] and } as literals
            case '}':
                node = atom();
                break;
            case '?':
            case '*':
            case '+':
                next();
                throw error(new String("Dangling meta character '" + ((char)ch) + "'"));
            case 0:
                if (_cursor >= patternLength) {
                    goto end2;
                }
                // Fall through
                node = atom();
                break;
            default:
                node = atom();
                break;
            }
            node = closure(node);
            if (head == null) {
                head = tail = node;
            } else {
                tail.next = node;
                tail = node;
            }
        }
end2:
        if (head == null) {
            return end;
        }
        tail.next = end;
        root = tail;      //double return
        return head;
    }
Esempio n. 17
0
 internal ListenerSession(ListenerConnection connection, Begin begin)
     : base(connection, begin)
 {
 }
Esempio n. 18
0
        protected override void BeginProcessing()
        {
            // convert scripts to strings
            _Script = Script.ToString();
            if (Begin != null)
            {
                _Begin = Begin.ToString();
            }
            if (End != null)
            {
                _End = End.ToString();
            }
            if (Finally != null)
            {
                _Finally = Finally.ToString();
            }

            // Count
            if (_Count <= 0)
            {
                _Count = Environment.ProcessorCount;
            }

            // MaxQueue after Count
            if (MaxLoad < int.MaxValue / _Count)
            {
                MaxQueue = _Count * MaxLoad;
            }

            // to import modules
            if (Module != null)
            {
                _iss.ImportPSModule(Module);
            }

            // import variables
            _iss.Variables.Add(new SessionStateVariableEntry("LogEngineLifeCycleEvent", false, string.Empty));             // whole log disabled
            _iss.Variables.Add(new SessionStateVariableEntry("LogProviderLifeCycleEvent", false, string.Empty));           // start is still logged
            if (Variable != null)
            {
                foreach (var name in Variable)
                {
                    _iss.Variables.Add(new SessionStateVariableEntry(name, GetVariableValue(name), string.Empty));
                }
            }

            // import functions
            if (Function != null)
            {
                foreach (var name in Function)
                {
                    var function = (FunctionInfo)SessionState.InvokeCommand.GetCommand(name, CommandTypes.Function);
                    _iss.Commands.Add(new SessionStateFunctionEntry(name, function.Definition));
                }
            }

            // import configurations
            if (Configuration != null)
            {
                foreach (var name in Configuration)
                {
                    var configuration = (ConfigurationInfo)SessionState.InvokeCommand.GetCommand(name, CommandTypes.Configuration);
                    _iss.Commands.Add(new SessionStateFunctionEntry(name, configuration.Definition));
                }
            }

            // verbose state
            object parameter;

            if (MyInvocation.BoundParameters.TryGetValue("Verbose", out parameter))
            {
                _verbose = ((SwitchParameter)parameter).ToBool();
            }
            else
            {
                // #12 VerbosePreference value can be anything
                ActionPreference preference;
                if (LanguagePrimitives.TryConvertTo <ActionPreference>(GetVariableValue("VerbosePreference"), out preference))
                {
                    _verbose = preference != ActionPreference.SilentlyContinue;
                }
            }
        }
Esempio n. 19
0
 public int CompareTo(Content other) => Begin.CompareTo(other.Begin);
Esempio n. 20
0
 public void EnqueuePing(Packet packet)
 {
     Begin.Set();
     PingQueue.Enqueue(packet);
 }
Esempio n. 21
0
 void UpdateHandleTable(Begin begin)
 {
     this.settings.HandleMax = Math.Min(this.settings.HandleMax(), begin.HandleMax());
     this.linksByLocalHandle.SetMaxHandle(this.settings.HandleMax.Value);
     this.linksByRemoteHandle.SetMaxHandle(this.settings.HandleMax.Value);
 }
Esempio n. 22
0
 void SendBegin(Begin begin)
 {
     this.connection.SendCommand(this.channel, begin);
 }
Esempio n. 23
0
 Error Negotiate(Begin begin)
 {
     this.outgoingChannel.OnBegin(begin);
     this.UpdateHandleTable(begin);
     return(null);
 }
        public void WaitForCompletion(int?timeout = null)
        {
            int  delta     = WebBackgroundJobsManager.CheckInterval;
            long timeoutMs = 1000;

            if (timeout == null)
            {
                delta = 0;
            }
            else
            {
                timeoutMs = (long)(timeout * 1000);
            }

            long current = 0;

            do
            {
                System.Threading.Thread.Sleep(WebBackgroundJobsManager.CheckInterval);
                current += delta;
            } while (current < timeoutMs && State == WebBackgroundJobStateImpl.Active);

            System.IO.TextWriter logWriter;

            if (State == WebBackgroundJobStateImpl.Failed)
            {
                logWriter = AspNetLog.Open();
                string logStr = ErrorInfo.ModuleName + "`n"
                                + ErrorInfo.LineNumber + "`n"
                                + ErrorInfo.Description + "`n"
                                + ErrorInfo.DetailedDescription;
                AspNetLog.Write(logWriter, logStr);
                AspNetLog.Close(logWriter);

                throw (new Exception("Фоновое задание завершились с ошибкой."));
            }

            if (State == WebBackgroundJobStateImpl.Completed)
            {
                return;
            }

            string exceptionString = "Timeout expires for job: ";

            exceptionString += "start date: " + Begin.ToString() + " ";
            exceptionString += "method: " + MethodName + " ";

            if (Description != null)
            {
                exceptionString += "description: " + Description + " ";
            }
            if (Key != null)
            {
                exceptionString += "key: " + Description + " ";
            }

            logWriter = AspNetLog.Open();
            AspNetLog.Write(logWriter, exceptionString);
            AspNetLog.Close(logWriter);

            throw (new Exception(exceptionString));
        }
Esempio n. 25
0
        /// <summary>
        /// Compares two RegularRegularHourss for equality.
        /// </summary>
        /// <param name="RegularRegularHours">A RegularRegularHours to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(RegularHours RegularRegularHours)

        => Weekday.Equals(RegularRegularHours.Weekday) &&
        Begin.Equals(RegularRegularHours.Begin) &&
        End.Equals(RegularRegularHours.End);
Esempio n. 26
0
 public override int GetHashCode()
 {
     return(unchecked (Begin.GetHashCode() ^ End.GetHashCode()));
 }
Esempio n. 27
0
 // begin
 public static ushort RemoteChannel(this Begin begin)
 {
     return(begin.RemoteChannel == null ? (ushort)0 : begin.RemoteChannel.Value);
 }
Esempio n. 28
0
 /// <summary>
 /// Returns the range in the format "begin-end", or
 /// as a single address if End is the same as Begin.
 /// </summary>
 /// <returns>String</returns>
 public override string ToString()
 {
     return(Equals(Begin, End) ? Begin.ToString() : string.Format("{0}/{1}", Begin, End));
 }
Esempio n. 29
0
 public static uint HandleMax(this Begin begin)
 {
     return(begin.HandleMax == null ? uint.MaxValue : begin.HandleMax.Value);
 }
Esempio n. 30
0
 /// <summary>
 /// Returns the range in the format "begin[sep]end", or
 /// as a single address if End is the same as Begin.
 /// </summary>
 /// <param name="separator">Separator</param>
 /// <returns>String</returns>
 public string ToString(char separator)
 {
     return(Equals(Begin, End) ? Begin.ToString() : string.Format("{0}{1}{2}", Begin, separator, End));
 }
Esempio n. 31
0
 public static uint IncomingWindow(this Begin begin)
 {
     return(begin.IncomingWindow == null ? uint.MaxValue : begin.IncomingWindow.Value);
 }
Esempio n. 32
0
 void Awake()
 {
     multipleLoader = LHighway.instance;
     _instance = this;
 }
Esempio n. 33
0
        private void HandleBeginFrame(Begin begin)
        {
            if (State != SessionStateEnum.UNMAPPED && State != SessionStateEnum.BEGIN_SENT)
                throw new AmqpException(ErrorCode.IllegalState, $"Received Begin frame but session state is {State.ToString()}.");

            nextOutgoingId = InitialOutgoingId; // our next id
            incomingWindow = DefaultWindowSize; // our incoming window

            nextIncomingId = begin.NextOutgoingId; // their next id
            outgoingWindow = remoteIncomingWindow = begin.IncomingWindow; // their incoming window (and now our outgoing window)
            remoteOutgoingWindow = begin.OutgoingWindow; // their advertized outgoing window

            sessionMaxHandle = Math.Min(DefaultMaxHandle, begin.HandleMax ?? DefaultMaxHandle);

            if (State == SessionStateEnum.BEGIN_SENT)
            {
                if (begin.RemoteChannel == null)
                {
                    throw new AmqpException(ErrorCode.InvalidField, "Expecting to receive RemoteChannel");
                }
                RemoteChannelNumber = begin.RemoteChannel.Value;
                State = SessionStateEnum.MAPPED;
                return;
            }
            else
            {
                State = SessionStateEnum.BEGIN_RCVD;

                // reset values and send back the frame
                begin.RemoteChannel = RemoteChannelNumber;
                begin.NextOutgoingId = nextOutgoingId;
                begin.IncomingWindow = incomingWindow;
                begin.OutgoingWindow = outgoingWindow;
                begin.HandleMax = sessionMaxHandle;
                Connection.SendFrame(begin, ChannelNumber);

                State = SessionStateEnum.MAPPED;
                return;
            }
        }