Example #1
0
        /// <summary>
        /// Construct a resource record from a pointer to a byte array
        /// </summary>
        /// <param name="pointer">the position in the byte array of the record</param>
        internal ResourceRecord(Pointer pointer)
        {
            // extract the domain, question type, question class and Ttl
            _domain   = pointer.ReadDomain();
            _dnsType  = (DnsType)pointer.ReadShort();
            _dnsClass = (DnsClass)pointer.ReadShort();
            _Ttl      = pointer.ReadInt();

            // the next short is the record length, we only use it for unrecognised record types
            int recordLength = pointer.ReadShort();

            // and create the appropriate RDATA record based on the dnsType
            switch (_dnsType)
            {
            case DnsType.NS:        _record = new NSRecord(pointer);        break;

            case DnsType.MX:        _record = new MXRecord(pointer);        break;

            case DnsType.ANAME:     _record = new ANameRecord(pointer);     break;

            case DnsType.SOA:       _record = new SoaRecord(pointer);       break;

            default:
            {
                // move the pointer over this unrecognised record
                pointer += recordLength;
                break;
            }
            }
        }
Example #2
0
        protected void DrawSeverityIcon(RecordBase record)
        {
            string iconName;

            switch (record.severity)
            {
            case RecordSeverity.Error:
                iconName = "d_console.erroricon";
                break;

            case RecordSeverity.Warning:
                iconName = "d_console.warnicon";
                break;

            case RecordSeverity.Info:
                iconName = "d_console.infoicon";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Texture icon     = EditorGUIUtility.FindTexture(iconName);
            Rect    iconArea = EditorGUILayout.GetControlRect(GUILayout.Width(20), GUILayout.Height(20));
            Rect    iconRect = new Rect(iconArea);

            iconRect.width = iconRect.height = 30;
            iconRect.x    -= 5;
            iconRect.y    -= 5;
            GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleAndCrop);
        }
Example #3
0
        private static bool IsDVTPriorRecord(RecordBase rb)
        {
            if (rb is MergedCellsTable || rb is ConditionalFormattingTable)
            {
                return(true);
            }
            short sid = ((Record)rb).Sid;

            switch (sid)
            {
            case WindowTwoRecord.sid:
            case UnknownRecord.SCL_00A0:
            case PaneRecord.sid:
            case SelectionRecord.sid:
            case UnknownRecord.STANDARDWIDTH_0099:
            // MergedCellsTable
            case UnknownRecord.LABELRANGES_015F:
            case UnknownRecord.PHONETICPR_00EF:
            // ConditionalFormattingTable
            case HyperlinkRecord.sid:
            case UnknownRecord.QUICKTIP_0800:
                return(true);
            }
            return(false);
        }
Example #4
0
        /**
         * Finds the index where the sheet validations header record should be inserted
         * @param records the records for this sheet
         *
         * + WINDOW2
         * o SCL
         * o PANE
         * oo SELECTION
         * o STANDARDWIDTH
         * oo MERGEDCELLS
         * o LABELRANGES
         * o PHONETICPR
         * o Conditional Formatting Table
         * o Hyperlink Table
         * o Data Validity Table
         * o SHEETLAYOUT
         * o SHEETPROTECTION
         * o RANGEPROTECTION
         * + EOF
         */
        private static int FindDataValidationTableInsertPos(List <RecordBase> records)
        {
            int i = records.Count - 1;

            if (!(records[i] is EOFRecord))
            {
                throw new InvalidOperationException("Last sheet record should be EOFRecord");
            }
            while (i > 0)
            {
                i--;
                RecordBase rb = records[i];
                if (IsDVTPriorRecord(rb))
                {
                    Record nextRec = (Record)records[i + 1];
                    if (!IsDVTSubsequentRecord(nextRec.Sid))
                    {
                        throw new InvalidOperationException("Unexpected (" + nextRec.GetType().Name
                                                            + ") found after (" + rb.GetType().Name + ")");
                    }
                    return(i + 1);
                }
                Record rec = (Record)rb;
                if (!IsDVTSubsequentRecord(rec.Sid))
                {
                    throw new InvalidOperationException("Unexpected (" + rec.GetType().Name
                                                        + ") while looking for DV Table insert pos");
                }
            }
            return(0);
        }
Example #5
0
        internal ResourceRecord(Pointer pointer)
        {
            Domain = pointer.ReadDomain();
            Type   = pointer.ReadType();
            Class  = (DnsClass)pointer.ReadShort();
            Ttl    = pointer.ReadInt();

            int recordLength = pointer.ReadShort();

            switch (Type)
            {
            case DnsType.ANAME: Record = new ANameRecord(pointer); break;

            case DnsType.AAAA: Record = new AAAARecord(pointer); break;

            case DnsType.NS: Record = new NSRecord(pointer); break;

            case DnsType.MX: Record = new MXRecord(pointer, Ttl); break;

            case DnsType.SOA: Record = new SoaRecord(pointer); break;

            default:
            {
                pointer.Seek(recordLength);
                break;
            }
            }
        }
Example #6
0
 private static bool IsGutsPriorRecord(RecordBase rb)
 {
     if (rb is Record)
     {
         Record record = (Record)rb;
         switch (record.Sid)
         {
         case BOFRecord.sid:
         case IndexRecord.sid:
         // calc settings block
         case UncalcedRecord.sid:
         case CalcCountRecord.sid:
         case CalcModeRecord.sid:
         case PrecisionRecord.sid:
         case RefModeRecord.sid:
         case DeltaRecord.sid:
         case IterationRecord.sid:
         case DateWindow1904Record.sid:
         case SaveRecalcRecord.sid:
         // end calc settings
         case PrintHeadersRecord.sid:
         case PrintGridlinesRecord.sid:
         case GridsetRecord.sid:
             return(true);
             // DefaultRowHeightRecord.sid is next
         }
     }
     return(false);
 }
Example #7
0
        private IEnumerable <IRecord> ExecutePeopleSearch(AuthenticationData auth, IDictionary <string, object> runtimeParams)
        {
            WebClient client = GetWebClient();

            if (runtimeParams.ContainsKey("Search"))
            {
                Search = (String)runtimeParams["Search"];
            }
            if (String.IsNullOrEmpty(Search))
            {
                throw new Exception("This method requires a Search parameter");
            }
            String url = String.Format(URL_PEOPLE_SEARCH, HttpUtility.UrlEncode(Search));

            url = AddAuthentication(url, auth);
            if (MaximumResults != null)
            {
                url += String.Format("&count={0}", MaximumResults);
            }
            String    data = Encoding.UTF8.GetString(client.DownloadData(url));
            XDocument xml  = XDocument.Parse(data);

            foreach (XElement personNode in xml.Descendants("person"))
            {
                yield return(RecordBase.CreateRecord(new LinkedinPerson(personNode)));
            }
        }
Example #8
0
        private IEnumerable <IRecord> ExecuteCompanySharesSearch(AuthenticationData auth, IDictionary <string, object> runtimeParams)
        {
            WebClient client = GetWebClient();

            // we still call the parameter "LinkedInUser" so we can use the same client-side code as with the user profile mashup
            if (runtimeParams.ContainsKey("LinkedInUser"))
            {
                LinkedInUser = (String)runtimeParams["LinkedInUser"];
            }
            if (String.IsNullOrEmpty(LinkedInUser))
            {
                throw new Exception("This method requires a LinkedInUser parameter");
            }

            // fetch the profile first, because it is used to decorate the returned updates
            IRecord profileRecord = ExecuteBusinessProfileSearch(auth, runtimeParams).FirstOrDefault();

            String url = String.Format(URL_COMPANY_SHARES_API, HttpUtility.UrlEncode(LinkedInUser));

            url  = AddAuthentication(url, auth);
            url += String.Format("&count={0}", MaximumResults ?? LINKEDIN_DEFAULT_MAXRESULTS);
            String    data = Encoding.UTF8.GetString(client.DownloadData(url));
            XDocument xml  = XDocument.Parse(data);

            foreach (XElement updateNode in xml.Descendants("update"))
            {
                LinkedinCompanyShare rec = LinkedinCompanyShare.MakeRecord(updateNode, profileRecord);
                if (rec != null)
                {
                    rec.Icon = "LinkedIn_Logo16px.png";
                    yield return(RecordBase.CreateRecord(rec));
                }
            }
        }
Example #9
0
        /// <summary>
        /// Construct a resource record from a pointer to a byte array
        /// </summary>
        /// <param name="pointer">the position in the byte array of the record</param>
        internal ResourceRecord(Pointer pointer)
        {
            // extract the domain, question type, question class and Ttl
            this._domain   = pointer.ReadDomain();
            this._dnsType  = (DnsType)pointer.ReadShort();
            this._dnsClass = (DnsClass)pointer.ReadShort();
            this._Ttl      = pointer.ReadInt();

            // the next short is the record length, we only use it for unrecognised record types
            int recordLength = pointer.ReadShort();

            // and create the appropriate RDATA record based on the dnsType
            switch (this._dnsType)
            {
            case DnsType.SRV:
                this._record = new SRVRecord(pointer);
                break;

            default:
            {
                // move the pointer over this unrecognised record
                pointer.Position += recordLength;
                break;
            }
            }
        }
Example #10
0
 private static bool IsPageBreakPriorRecord(RecordBase rb)
 {
     if (rb is Record)
     {
         Record record = (Record)rb;
         switch (record.Sid)
         {
         case BOFRecord.sid:
         case IndexRecord.sid:
         // calc settings block
         case UncalcedRecord.sid:
         case CalcCountRecord.sid:
         case CalcModeRecord.sid:
         case PrecisionRecord.sid:
         case RefModeRecord.sid:
         case DeltaRecord.sid:
         case IterationRecord.sid:
         case DateWindow1904Record.sid:
         case SaveRecalcRecord.sid:
         // end calc settings
         case PrintHeadersRecord.sid:
         case PrintGridlinesRecord.sid:
         case GridsetRecord.sid:
         case DefaultRowHeightRecord.sid:
         case UnknownRecord.SHEETPR_0081:
             return(true);
             // next is the 'Worksheet Protection Block'
         }
     }
     return(false);
 }
Example #11
0
 public void VisitCellsForRow(int rowIndex, RecordVisitor rv)
 {
     CellValueRecordInterface[] rowCells = records[rowIndex];
     if (rowCells == null)
     {
         throw new ArgumentException("Row [" + rowIndex + "] is empty");
     }
     for (int i = 0; i < rowCells.Length; i++)
     {
         RecordBase cvr = (RecordBase)rowCells[i];
         if (cvr == null)
         {
             continue;
         }
         int nBlank = CountBlanks(rowCells, i);
         if (nBlank > 1)
         {
             rv.VisitRecord(CreateMBR(rowCells, i, nBlank));
             i += nBlank - 1;
         }
         else if (cvr is RecordAggregate)
         {
             RecordAggregate agg = (RecordAggregate)cvr;
             agg.VisitContainedRecords(rv);
         }
         else
         {
             rv.VisitRecord((Record)cvr);
         }
     }
 }
Example #12
0
        /// <summary>
        ///     Construct a resource record from a pointer to a byte array
        /// </summary>
        /// <param name="pointer"> the position in the byte array of the record </param>
        protected ResourceRecord(Pointer pointer)
        {
            // the next short is the record length, we only use it for unrecognised record types
            int recordLength = pointer.ReadShort();

            // and create the appropriate RDATA record based on the dnsType
            switch ((DnsType)pointer.ReadShort())
            {
            case DnsType.NS:
                this._record = new NSRecord(pointer);
                break;

            case DnsType.MX:
                this._record = new MXRecord(pointer);
                break;

            case DnsType.ANAME:
                this._record = new ANameRecord(pointer);
                break;

            case DnsType.SOA:
                this._record = new SoaRecord(pointer);
                break;

            default:
            {
                // move the pointer over this unrecognised record
                pointer += recordLength;
                break;
            }
            }
        }
 /// <summary>
 /// Create record to represent a twitter status.
 /// The result is returned as a normalized "StatusUpdateRecord" (the same record type is used for the different social network providers, to
 /// make the mashups easier to write and consume)
 /// </summary>
 /// <param name="search"></param>
 /// <returns></returns>
 private static IRecord CreateStatusRecord(LinqToTwitter.Status status)
 {
     if (String.IsNullOrEmpty(status.User.ScreenName))
     {
         status.User.ScreenName = status.User.Identifier.ScreenName;
     }
     if (String.IsNullOrEmpty(status.User.UserID))
     {
         status.User.UserID = status.User.Identifier.UserID;
     }
     return(RecordBase.CreateRecord(new StatusUpdateRecord
     {
         User = new SocialProfileRecord
         {
             UserID = status.User.UserID,
             Description = status.User.Description,
             LastName = status.User.Name,
             FirstName = "",
             ScreenName = "@" + status.User.ScreenName,
             PictureUrl = String.IsNullOrEmpty(status.User.ProfileImageUrlHttps) ? status.User.ProfileImageUrl : status.User.ProfileImageUrlHttps,
             //ProfileUrl = status.User.Url ?? ("https://twitter.com/" + status.User.ScreenName)
             // per Twitter guidelines we actually need this one to go to the Twitter profile, not their specified URL
             ProfileUrl = "https://twitter.com/" + status.User.ScreenName
         },
         Favorited = status.Favorited,
         Retweeted = status.Retweeted,
         StatusID = status.StatusID,
         Text = Twitterize(status.Text),
         CreatedAt = status.CreatedAt,
         Icon = "tweet.ico",
         StatusUrl = String.Format(TWITTER_STATUS_URL, status.User.ScreenName, status.StatusID),
         SocialNetwork = "Twitter"
     }));
 }
Example #14
0
 private void Send(RecordBase rec)
 {
     foreach (var seg in rec.GetBytes())
     {
         Socket.Send(seg.Array, seg.Offset, seg.Count, SocketFlags.None);
     }
 }
        protected override void AddReceivedRecord(RecordBase rec)
        {
            base.AddReceivedRecord(rec);

            switch (rec.RecordType)
            {
            case RecordType.FCGIParams:
                if (Params.IsComplete)
                {
                    OwinContext.AddParams(Params);
                }
                break;

            case RecordType.FCGIStdin:
                // Only respond if the last empty stdin was received
                if (!Stdin.IsComplete)
                {
                    break;
                }

                var onApplicationDone = ProcessRequest();
                onApplicationDone.ContinueWith(t => {
                    // This task _CANNOT_ fail
                    if (ApplicationMustCloseConnection)
                    {
                        this.Dispose();
                    }
                });
                break;
            }
        }
		/// <summary>
		/// Construct a resource record from a pointer to a byte array
		/// </summary>
		/// <param name="pointer">the position in the byte array of the record</param>
		internal ResourceRecord(Pointer pointer) {
			// extract the domain, question type, question class and Ttl
			_domain = pointer.ReadDomain();
			_dnsType = (DnsType)pointer.ReadShort();
			_dnsClass = (DnsClass)pointer.ReadShort();
			_Ttl = pointer.ReadInt();

			// the next short is the record length, we only use it for unrecognised record types
			int recordLength = pointer.ReadShort();

			// and create the appropriate RDATA record based on the dnsType
			switch(_dnsType) {
				case DnsType.NS:
					_record = new NSRecord(pointer);
					break;
				case DnsType.MX:
					_record = new MXRecord(pointer);
					break;
				case DnsType.ANAME:
					_record = new ANameRecord(pointer);
					break;
				case DnsType.SOA:
					_record = new SoaRecord(pointer);
					break;
				default:
					{
						// move the pointer over this unrecognised record
						pointer += recordLength;
						break;
					}
			}
		}
        /// <summary>
        /// Whenever you want to send a record to the other side, call this base method to do some book keeping for you before you
        /// actually send the record.
        /// </summary>
        /// <param name="rec">The record to send.</param>
        protected virtual void Send(RecordBase rec)
        {
            if (rec == null)
            {
                throw new ArgumentNullException("rec");
            }

            if (rec.RecordType != RecordType.FCGIBeginRequest)
            {
                if (rec.RequestId != RequestId)
                {
                    throw new ArgumentException("The record's RequestId is different from this Request's");
                }
            }
            else
            {
                if (BeginRequestSent)
                {
                    throw new InvalidOperationException("A BeginRequest has already been sent for this Request");
                }

                BeginRequestSent = true;
            }

            if (rec.RecordType == RecordType.FCGIEndRequest)
            {
                if (EndRequestSent)
                {
                    throw new InvalidOperationException("An EndRequest has already been sent for this Request");
                }

                EndRequestSent = true;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AriesFrameworkException"/> class.
 /// </summary>
 /// <param name="errorCode">The error code.</param>
 /// <param name="message">The message.</param>
 /// <param name="contextRecord"></param>
 /// <param name="connectionRecord"></param>
 public AriesFrameworkException(ErrorCode errorCode, string message, RecordBase contextRecord, ConnectionRecord connectionRecord) :
     base(message)
 {
     ErrorCode        = errorCode;
     ContextRecord    = contextRecord;
     ConnectionRecord = connectionRecord;
 }
Example #19
0
        private Dictionary <string, string> GetTags(RecordBase record)
        {
            Type         recordType = record.GetType();
            PropertyInfo pi         = recordType.GetProperty("Tags", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetProperty);

            return(pi.GetValue(record, null) as Dictionary <string, string>);
        }
Example #20
0
        /// <summary>
        ///     Construct a resource record from a pointer to a byte array
        /// </summary>
        /// <param name="pointer"> the position in the byte array of the record </param>
        protected ResourceRecord(Pointer pointer)
        {
            // the next short is the record length, we only use it for unrecognised record types
            int recordLength = pointer.ReadShort();

            // and create the appropriate RDATA record based on the dnsType
            switch ((DnsType)pointer.ReadShort())
            {
                case DnsType.NS:
                    this._record = new NSRecord(pointer);
                    break;
                case DnsType.MX:
                    this._record = new MXRecord(pointer);
                    break;
                case DnsType.ANAME:
                    this._record = new ANameRecord(pointer);
                    break;
                case DnsType.SOA:
                    this._record = new SoaRecord(pointer);
                    break;
                default:
                    {
                        // move the pointer over this unrecognised record
                        pointer += recordLength;
                        break;
                    }
            }
        }
Example #21
0
        public ConfigurationBuilder AddDefault()
        {
            Assembly   ass    = Assembly.GetEntryAssembly();
            Stream     stream = ass.LoadStream("HakeQuick.default.json");
            RecordBase record = Converter.ReadJson(stream);

            stream.Dispose();

            if (record is SetRecord set)
            {
                if (values == null)
                {
                    values = set;
                }
                else
                {
                    values.Combine(set);
                }
            }
            else
            {
                throw new Exception("invalid configuration format");
            }

            return(this);
        }
 private static IRecord CreateRecord(object item, System.Collections.Generic.IList <string> aliases)
 {
     System.Collections.ICollection collection = item as System.Collections.ICollection;
     if (collection != null)
     {
         System.Collections.Generic.List <object> list = collection.Cast <object>().ToList <object>();
         if (aliases != null && aliases.Count != list.Count)
         {
             aliases = null;
         }
         if (list.Count != 1)
         {
             int counter             = 0;
             DictionaryRecord record = new DictionaryRecord();
             list.ForEach(delegate(object obj)
             {
                 record.SetValue((aliases != null) ? aliases[counter++] : ("Value" + ++counter), obj);
             });
             return(record);
         }
         if (aliases != null)
         {
             aliases[0] = Pluralizer.ToSingular(aliases[0]);
         }
         item = list[0];
     }
     if (aliases == null || aliases.Count != 1)
     {
         return(RecordBase.CreateRecord(item));
     }
     return(RecordBase.CreateRecord(item, aliases[0]));
 }
Example #23
0
        private void SetCreatedAtUtc(RecordBase record)
        {
            Type         recordType = record.GetType();
            PropertyInfo pi         = recordType.GetProperty("CreatedAtUtc", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty);

            //pi = recordType.GetProperties()[11];
            pi.SetValue(record, DateTime.UtcNow);
        }
Example #24
0
        public void Day04_ParseRecordTest(string s, string expectedDateTimeString, int expectedGuardId, States expectedState)
        {
            var record = Records.FromRecordBases(new[] { RecordBase.FromString(s), }).Single();

            Assert.Equal(DateTime.Parse(expectedDateTimeString), record.DateTime);
            Assert.True(record.GuardId == default || record.GuardId == expectedGuardId);
            Assert.Equal(expectedState, record.State);
        }
Example #25
0
        /// <summary>
        /// Sends a record over the wire. This method could throw if the connection has been closed prematurely by the other side or if the socket
        /// is in the process of being closed by your code or is already closed.
        /// </summary>
        /// <exception cref="System.ObjectDisposedException">If the Socket was disposed.</exception>
        /// <exception cref="System.SocketException">If the Socket was prematurely closed by the other side or was in the process of being closed.</exception>
        protected override void Send(RecordBase rec)
        {
            base.Send(rec);

            foreach (var arrSegment in rec.GetBytes())
            {
                Socket.Send(arrSegment.Array, arrSegment.Offset, arrSegment.Count, SocketFlags.None);
            }
        }
Example #26
0
        /// <summary>
        /// Asynchronously writes a record to this <c>CsvWriter</c>.
        /// </summary>
        /// <remarks>
        /// All values within <paramref name="record"/> are written in the order they appear.
        /// </remarks>
        /// <param name="record">
        /// The record to write.
        /// </param>
        /// <returns>
        /// A <see cref="Task"/> representing the asynchronous operation.
        /// </returns>
        public async Task WriteRecordAsync(RecordBase record)
        {
            Debug.Assert(this.bufferBuilder.Length == 0, "Expecting buffer to be empty.");

            this.EnsureNotDisposed();
            record.AssertNotNull("record");
            this.WriteRecordToBuffer(record);
            await this.FlushBufferToTextWriterAsync().ConfigureAwait(false);
        }
Example #27
0
 protected virtual void DrawRecordCheckbox(RecordBase record)
 {
     EditorGUI.BeginChangeCheck();
     record.selected = EditorGUILayout.ToggleLeft(new GUIContent(""), record.selected, GUILayout.Width(12));
     if (EditorGUI.EndChangeCheck())
     {
         OnSelectionChanged();
     }
 }
Example #28
0
        private static void ConfirmSerializedSize(RecordBase cirAgg)
        {
            int estimatedSize = cirAgg.RecordSize;

            byte[] buf            = new byte[estimatedSize];
            int    serializedSize = cirAgg.Serialize(0, buf);

            Assert.AreEqual(estimatedSize, serializedSize);
        }
Example #29
0
        private void DrawRecordButtons(RecordBase record)
        {
            using (UIHelpers.Horizontal(UIHelpers.panelWithBackground))
            {
                AddShowButtonIfPossible(record);

                AssetRecord assetRecord = record as AssetRecord;
                if (assetRecord != null)
                {
                    if (GUILayout.Button(new GUIContent("Reveal", "Reveals item in system default File Manager like Explorer on Windows or Finder on Mac."), UIHelpers.recordButton))
                    {
                        EditorUtility.RevealInFinder(assetRecord.path);
                    }

                    if (GUILayout.Button("More ...", UIHelpers.recordButton))
                    {
                        GenericMenu menu = new GenericMenu();
                        if (!string.IsNullOrEmpty(assetRecord.path))
                        {
                            menu.AddItem(new GUIContent("Ignore/Add path to ignores"), false, () =>
                            {
                                if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Cleaner.pathIgnores, assetRecord.assetDatabasePath))
                                {
                                    MaintainerSettings.Save();
                                    MaintainerWindow.ShowNotification("Ignore added: " + assetRecord.assetDatabasePath);
                                    CleanerIgnoresWindow.Refresh();
                                }
                                else
                                {
                                    MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                }
                            });

                            DirectoryInfo dir = Directory.GetParent(assetRecord.assetDatabasePath);
                            if (dir.Name != "Assets")
                            {
                                menu.AddItem(new GUIContent("Ignore/Add parent directory to ignores"), false, () =>
                                {
                                    if (CSArrayTools.AddIfNotExists(ref MaintainerSettings.Cleaner.pathIgnores, dir.ToString()))
                                    {
                                        MaintainerSettings.Save();
                                        MaintainerWindow.ShowNotification("Ignore added: " + dir);
                                        CleanerIgnoresWindow.Refresh();
                                    }
                                    else
                                    {
                                        MaintainerWindow.ShowNotification("Such item already added to the ignores!");
                                    }
                                });
                            }
                        }
                        menu.ShowAsContext();
                    }
                }
            }
        }
Example #30
0
        protected void DrawExpandCollapseButton(RecordBase record)
        {
            var r = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight, GUILayout.Width(12));

            EditorGUI.BeginChangeCheck();
            record.compactMode = !EditorGUI.Foldout(r, !record.compactMode, GUIContent.none, UIHelpers.richFoldout);
            if (EditorGUI.EndChangeCheck())
            {
                var index = Array.IndexOf(filteredRecords, record);
                GetState().compaction[index] = record.compactMode;
            }
        }
Example #31
0
        protected virtual void DrawRecordCheckbox(RecordBase record)
        {
            EditorGUI.BeginChangeCheck();
            record.selected = EditorGUILayout.ToggleLeft(new GUIContent(""), record.selected, GUILayout.Width(12));
            if (EditorGUI.EndChangeCheck())
            {
                var index = Array.IndexOf(filteredRecords, record);
                GetState().selection[index] = record.selected;

                OnSelectionChanged();
            }
        }
Example #32
0
        protected override void AddReceivedRecord(RecordBase rec)
        {
            base.AddReceivedRecord(rec);

            var beginRec = rec as BeginRequestRecord;

            if (beginRec != null)
            {
                Role = beginRec.Role;
                ApplicationMustCloseConnection = beginRec.ApplicationMustCloseConnection;
            }
        }
        public void TestFromJson()
        {
            decimal      d      = 1234;
            long         v      = (long)d;
            Stream       file   = File.OpenRead("data.json");
            RecordBase   record = Converter.ReadJson(file);
            ScalerRecord scaler = (ScalerRecord)record.RecordFromPath("[5].abc");
            long         value  = scaler.ReadAs <long>();

            file.Dispose();
            string json = record.Json();
        }
Example #34
0
        /// <summary>
        /// Writes a record to this <c>CsvWriter</c>.
        /// </summary>
        /// <remarks>
        /// All values within <paramref name="record"/> are written in the order they appear.
        /// </remarks>
        /// <param name="record">
        /// The record to write.
        /// </param>
        public void WriteRecord(RecordBase record)
        {
            Debug.Assert(this.bufferBuilder.Length == 0, "Expecting buffer to be empty.");

            this.EnsureNotDisposed();
            //record.AssertNotNull("record");
            this.WriteRecordToBuffer(record);
            this.FlushBufferToTextWriter();
        }
Example #35
0
        public void write_records_writes_records_to_text_writer()
        {
            using (var stringWriter = new StringWriter())
            {
                using (var writer = new CsvWriter(stringWriter))
                {
                    var buffer = new RecordBase[]
                    {
                        new DataRecord(null, new string[] { "one", "two", "three" }),
                        new DataRecord(null, new string[] { "four", "five", "six" }),
                        new DataRecord(null, new string[] { "seven", "eight", "nine", "ten" })
                    };

                    writer.WriteRecords(buffer, 0, buffer.Length);
                }

                var expectedCsv = @"one,two,three
four,five,six
seven,eight,nine,ten
";

                Assert.Equal(expectedCsv, stringWriter.ToString());
            }
        }
Example #36
0
        public async Task write_records_async_throws_if_any_included_record_within_the_buffer_is_null()
        {
            using (var writer = new CsvWriter(new MemoryStream()))
            {
                var buffer = new RecordBase[]
                {
                    new HeaderRecord(),
                    new HeaderRecord(),
                    new HeaderRecord(),
                    null,
                    new HeaderRecord()
                };

                writer.WriteRecords(buffer, 0, 3);

                await Assert.ThrowsAsync<ArgumentException>(() => writer.WriteRecordsAsync(buffer, 0, 4));
            }
        }
Example #37
0
        public async Task write_records_async_writes_only_specified_records_to_text_writer()
        {
            using (var stringWriter = new StringWriter())
            {
                using (var writer = new CsvWriter(stringWriter))
                {
                    var buffer = new RecordBase[]
                    {
                        new DataRecord(null, new string[] { "one", "two", "three" }),
                        new DataRecord(null, new string[] { "four", "five", "six" }),
                        new DataRecord(null, new string[] { "seven", "eight", "nine" }),
                        new DataRecord(null, new string[] { "ten" })
                    };

                    await writer.WriteRecordsAsync(buffer, 1, 2);
                }

                var expectedCsv = @"four,five,six
seven,eight,nine
";

                Assert.Equal(expectedCsv, stringWriter.ToString());
            }
        }
Example #38
0
        public async Task write_records_async_increments_record_number()
        {
            using (var writer = new CsvWriter(new MemoryStream()))
            {
                var buffer = new RecordBase[]
                {
                    new DataRecord(null, new string[] { "one", "two", "three" }),
                    new DataRecord(null, new string[] { "four", "five", "six" }),
                    new DataRecord(null, new string[] { "seven", "eight", "nine", "ten" })
                };

                await writer.WriteRecordsAsync(buffer, 0, buffer.Length);
                Assert.Equal(3, writer.RecordNumber);
            }
        }
Example #39
0
 public void LogInvalidRecordReceived(RecordBase invalidRecord)
 {
     //throw new NotImplementedException ();
 }
Example #40
0
 public static void Enqueue(RecordBase record)
 {
     _queue.Enqueue(record);
 }
Example #41
0
 internal override void OnRecordBuilt(FosRequest req, RecordBase rec)
 {
     req.ApplicationPipelineEntry = OwinPipelineEntry;
     req.FlushPeriodically = FlushPeriodically;
 }
Example #42
0
		protected override void Send(RecordBase rec)
		{
            try
            {
                base.Send(rec);
            }
            catch (ObjectDisposedException)
            {
            }
            catch (SocketException e)
            {
                if (!SocketHelper.IsConnectionAbortedByTheOtherSide(e))
                    throw;
                
                CancellationSource.Cancel();
            }
		}
Example #43
0
 internal abstract void OnRecordBuilt(FosRequest req, RecordBase rec);
Example #44
0
        protected override void AddReceivedRecord(RecordBase rec)
        {
            base.AddReceivedRecord(rec);

            switch (rec.RecordType)
            {
                case RecordType.FCGIParams:
                    if (Params.IsComplete)
                        OwinContext.AddParams(Params);
                    break;

                case RecordType.FCGIStdin:
                    // Only respond if the last empty stdin was received
                    if (!Stdin.IsComplete)
                        break;

                    var onApplicationDone = ProcessRequest();
                    onApplicationDone.ContinueWith(t => {
                        // This task _CANNOT_ fail
                        if (ApplicationMustCloseConnection)
                        {
                            this.Dispose();
                        }
                    });
                    break;
            }
        }
Example #45
0
        /// <summary>
        /// Asynchronously writes <paramref name="length"/> records to this <c>CsvWriter</c>.
        /// </summary>
        /// <remarks>
        /// When writing a lot of data, it is possible that better performance can be achieved by using this method.
        /// </remarks>
        /// <param name="buffer">
        /// The buffer containing the records to be written.
        /// </param>
        /// <param name="offset">
        /// The offset into <paramref name="buffer"/> from which the first record will be obtained.
        /// </param>
        /// <param name="length">
        /// The number of records to write.
        /// </param>
        /// <returns>
        /// A <see cref="Task"/> representing the asynchronous operation.
        /// </returns>
        public async Task WriteRecordsAsync(RecordBase[] buffer, int offset, int length)
        {
            Debug.Assert(this.bufferBuilder.Length == 0, "Expecting buffer to be empty.");

            this.EnsureNotDisposed();
            buffer.AssertNotNull("buffer");
            exceptionHelper.ResolveAndThrowIf(offset < 0 || offset >= buffer.Length, "invalidOffset");
            exceptionHelper.ResolveAndThrowIf(offset + length > buffer.Length, "invalidLength");

            for (var i = offset; i < offset + length; ++i)
            {
                var record = buffer[i];
                exceptionHelper.ResolveAndThrowIf(record == null, "recordNull");
                this.WriteRecordToBuffer(record);
            }

            // we only flush once, when all records have been written
            await this.FlushBufferToTextWriterAsync().ConfigureAwait(false);
        }
 public void LogInvalidRecordReceived(RecordBase invalidRecord)
 {
 }