Esempio n. 1
0
        static void Main(string[] args)
        {
            IWeapon weapon = null;
            Character JeremyCook = new Character();

            while (true)
            {
                Console.WriteLine("Choose a weapon for JeremyCook! 1 = Sword, 2 = Ax, 3 = Club");
                String input = Console.ReadLine();

                switch (input)
                {
                    case "1":
                        weapon = new Sword();
                        break;
                    case "2":
                        weapon = new Ax();
                        break;
                    case "3":
                        weapon = new Club();
                        break;
                    default:
                        weapon = new Null();
                        break;
                }

                JeremyCook.setWeapon(weapon);
                JeremyCook.Attack();
            }
        }
 public Spec WillThrowInvalidOperationExceptionIfAllreadyLoggedOut(Null input, Null output)
 {
     return
         new Spec()
             .If(UserIsNotLoggedOn)
             .Throws<InvalidOperationException>();
 }
 public static Spec WillThrowInvalidOperationExceptionIfAllreadyLoggedIn(string input, Null output)
 {
     return
         new Spec(() => Ensure.True(User.IsAuthenticated))
             .If(UserIsLoggedOn)
             .Throws<InvalidOperationException>();
 }
 public Spec WillDeauthenticateUserOnSuccessfulLogOut(Null input, Null output)
 {
     return
         new Spec(() => Ensure.False(User.IsAuthenticated))
             .If(UserIsLoggedOn)
             .IfAfter(UserIsNotLoggedOn);
 }
Esempio n. 5
0
File: Null.cs Progetto: 7shi/LLPML
 public static Null New(BlockBase parent)
 {
     var ret = new Null();
     ret.Parent = parent;
     ret.name = "null";
     return ret;
 }
 public static Spec WillUpdateBadLoginCountOnFailedLogin(string input, Null output)
 {
     return 
         new Spec(() => Ensure.Equal(BadLoginCount + 1, User.BadLoginCount))
             .DoBefore(RememberBadLoginCount)
             .IfAfter(UserIsNotLoggedOn);
 }
Esempio n. 7
0
        public void TestIComparable()
        {
            Null <int> nil = null;
            IComparable <Null <int> > a = new Null <int>(5);
            IComparable a1 = new Null <int>(5);
            Null <int>  b1 = 6;

            Assert.IsTrue(a.CompareTo(5) == 0);
            Assert.IsTrue(a.CompareTo(nil) > 0);
            Assert.IsTrue(a.CompareTo(b1) < 0);

            Assert.IsTrue(a1.CompareTo((Null <int>) 5) == 0);
            Assert.IsTrue(a1.CompareTo(nil) > 0);
            Assert.IsTrue(a1.CompareTo(b1) < 0);
        }
Esempio n. 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dr"></param>
        public override void Fill(System.Data.IDataReader dr)
        {
            //Call the base classes fill method to populate base class proeprties
            base.Fill(dr);
            base.FillInternal(dr);

            //TermId = Null.SetNullInteger(dr["TermId"]);
            //Name = Null.SetNullString(dr["Name"]);
            //Description = Null.SetNullString(dr["Description"]);

            TotalTermUsage = Null.SetNullInteger(dr["TotalTermUsage"]);
            MonthTermUsage = Null.SetNullInteger(dr["MonthTermUsage"]);
            WeekTermUsage  = Null.SetNullInteger(dr["WeekTermUsage"]);
            DayTermUsage   = Null.SetNullInteger(dr["DayTermUsage"]);
        }
        public IEnumerable <AnnouncementInfo> GetCurrentAnnouncements(int moduleId, DateTime startDate)
        {
            IEnumerable <AnnouncementInfo> announcements;

            using (IDataContext context = DataContext.Instance())
            {
                var repository = context.GetRepository <AnnouncementInfo>();
                announcements = repository.Find("WHERE ModuleID = @0 " +
                                                "AND ( ((PublishDate >= @1) OR @1 IS NULL) AND (PublishDate <= GETDATE()) ) " +
                                                "AND ( (ExpireDate > GETDATE()) OR (ExpireDate IS NULL) )",
                                                moduleId, Null.GetNull(startDate, DBNull.Value)).OrderBy(
                    a => a.ViewOrder).ThenByDescending(a => a.PublishDate);
            }
            return(announcements);
        }
Esempio n. 10
0
        /// <summary>
        /// Fill the object with data from database.
        /// </summary>
        /// <param name="dr">the data reader.</param>
        public void Fill(IDataReader dr)
        {
            MessageID       = Convert.ToInt32(dr["MessageID"]);
            PortalID        = Null.SetNullInteger(dr["PortalId"]);
            To              = Null.SetNullString(dr["To"]);
            From            = Null.SetNullString(dr["From"]);
            Subject         = Null.SetNullString(dr["Subject"]);
            Body            = Null.SetNullString(dr["Body"]);
            ConversationId  = Null.SetNullInteger(dr["ConversationID"]);
            ReplyAllAllowed = Null.SetNullBoolean(dr["ReplyAllAllowed"]);
            SenderUserID    = Convert.ToInt32(dr["SenderUserID"]);

            //add audit column data
            FillInternal(dr);
        }
Esempio n. 11
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Fills a ModuleControlInfo from a Data Reader.
        /// </summary>
        /// <param name="dr">The Data Reader to use.</param>
        /// -----------------------------------------------------------------------------
        public void Fill(IDataReader dr)
        {
            this.ModuleControlID = Null.SetNullInteger(dr["ModuleControlID"]);
            this.FillInternal(dr);
            this.ModuleDefID    = Null.SetNullInteger(dr["ModuleDefID"]);
            this.ControlTitle   = Null.SetNullString(dr["ControlTitle"]);
            this.IconFile       = Null.SetNullString(dr["IconFile"]);
            this.HelpURL        = Null.SetNullString(dr["HelpUrl"]);
            this.ControlType    = (SecurityAccessLevel)Enum.Parse(typeof(SecurityAccessLevel), Null.SetNullString(dr["ControlType"]));
            this.ViewOrder      = Null.SetNullInteger(dr["ViewOrder"]);
            this.SupportsPopUps = Null.SetNullBoolean(dr["SupportsPopUps"]);

            // Call the base classes fill method to populate base class proeprties
            this.FillInternal(dr);
        }
Esempio n. 12
0
 protected void cmdDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (!Null.IsNull(itemId))
         {
             testController controller = new testController();
             controller.Deletetest(this.ModuleId, itemId);
         }
     }
     catch (Exception ex)
     {
         Exceptions.ProcessModuleLoadException(this, ex);
     }
 }
Esempio n. 13
0
 private void cmdDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (!Null.IsNull(ModuleControlId))
         {
             ModuleControlController.DeleteModuleControl(ModuleControlId);
         }
         Response.Redirect(ReturnURL, true);
     }
     catch (Exception exc)
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
Esempio n. 14
0
 public override void Fill(IDataReader dr)
 {
     base.Fill(dr);
     UserRoleID    = Null.SetNullInteger(dr["UserRoleID"]);
     UserID        = Null.SetNullInteger(dr["UserID"]);
     FullName      = Null.SetNullString(dr["DisplayName"]);
     Email         = Null.SetNullString(dr["Email"]);
     EffectiveDate = Null.SetNullDateTime(dr["EffectiveDate"]);
     ExpiryDate    = Null.SetNullDateTime(dr["ExpiryDate"]);
     IsTrialUsed   = Null.SetNullBoolean(dr["IsTrialUsed"]);
     if (UserRoleID > Null.NullInteger)
     {
         Subscribed = true;
     }
 }
Esempio n. 15
0
        public void Null_Equals_Null()
        {
            object nullLiteral           = null;
            object nullSingletonAsObject = Null.Instance;
            Null   nullSingletonAsTyped  = Null.Instance;

            nullSingletonAsObject.Equals(nullLiteral).Should().BeTrue();
            nullSingletonAsTyped.Equals(nullLiteral).Should().BeTrue();
            nullSingletonAsTyped.Equals(Null.Instance).Should().BeTrue();
            nullSingletonAsTyped.Equals(nullSingletonAsObject).Should().BeTrue();
            nullSingletonAsObject.Equals(nullSingletonAsTyped).Should().BeTrue();

            (nullSingletonAsObject == nullLiteral).Should().BeFalse();
            (nullSingletonAsTyped == nullLiteral).Should().BeTrue();
        }
        string GetDisciplinesString()
        {
            if (!Null.IsNull(EduProgramProfile.EduProgramProfileID))
            {
                var disciplines = Employee.Disciplines
                                  .FirstOrDefault(d => d.EduProgramProfileID == EduProgramProfile.EduProgramProfileID);

                if (disciplines != null)
                {
                    return(disciplines.Disciplines);
                }
            }

            return(string.Empty);
        }
        /// <summary>
        /// Handles Load event for a control
        /// </summary>
        /// <param name="e">Event args.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try {
                var now = HttpContext.Current.Timestamp;
                if (Settings.Mode == EmployeeDirectoryMode.Search)
                {
                    if (!IsPostBack)
                    {
                        if (!string.IsNullOrWhiteSpace(SearchText) || !Null.IsNull(SearchDivision))
                        {
                            // restore current search
                            textSearch.Text           = SearchText;
                            checkTeachersOnly.Checked = SearchTeachersOnly;

                            if (Null.IsNull(SearchDivision))
                            {
                                // select first node
                                if (treeDivisions.Nodes.Count > 0)
                                {
                                    treeDivisions.Nodes [0].Selected = true;
                                }
                            }
                            else
                            {
                                treeDivisions.SelectAndExpandByValue(SearchDivision.ToString());
                            }

                            // perform search
                            if (SearchParamsOK(SearchText, SearchDivision, false))
                            {
                                DoSearch(SearchText, SearchDivision, SearchTeachersOnly);
                            }
                        }
                    }
                }
                else if (Settings.Mode == EmployeeDirectoryMode.Teachers)
                {
                    repeaterEduProgramProfiles.DataSource = GetViewModel().EduProgramProfiles
                                                            .Where(epp => epp.IsPublished(now) || IsEditable);
                    repeaterEduProgramProfiles.DataBind();
                }
            }
            catch (Exception ex) {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
 private void BindData()
 {
     if (Request.QueryString["ScheduleID"] != null)
     {
         ViewState["ScheduleID"] = Request.QueryString["ScheduleID"];
         ScheduleItem scheduleItem = SchedulingProvider.Instance().GetSchedule(Convert.ToInt32(Request.QueryString["ScheduleID"]));
         txtFriendlyName.Text = scheduleItem.FriendlyName;
         txtType.Text         = scheduleItem.TypeFullName;
         chkEnabled.Checked   = scheduleItem.Enabled;
         if (!Null.IsNull(scheduleItem.ScheduleStartDate))
         {
             startScheduleDatePicker.SelectedDate = scheduleItem.ScheduleStartDate;
         }
         txtTimeLapse.Text = Convert.ToString(scheduleItem.TimeLapse);
         if (ddlTimeLapseMeasurement.FindItemByValue(scheduleItem.TimeLapseMeasurement) != null)
         {
             ddlTimeLapseMeasurement.FindItemByValue(scheduleItem.TimeLapseMeasurement).Selected = true;
         }
         txtRetryTimeLapse.Text = scheduleItem.RetryTimeLapse == Null.NullInteger ? string.Empty : Convert.ToString(scheduleItem.RetryTimeLapse);
         if (ddlRetryTimeLapseMeasurement.FindItemByValue(scheduleItem.RetryTimeLapseMeasurement) != null)
         {
             ddlRetryTimeLapseMeasurement.FindItemByValue(scheduleItem.RetryTimeLapseMeasurement).Selected = true;
         }
         if (ddlRetainHistoryNum.FindItemByValue(Convert.ToString(scheduleItem.RetainHistoryNum)) != null)
         {
             ddlRetainHistoryNum.FindItemByValue(Convert.ToString(scheduleItem.RetainHistoryNum)).Selected = true;
         }
         else
         {
             string scheduleItemRetainHistoryNum = scheduleItem.RetainHistoryNum.ToString();
             ddlRetainHistoryNum.AddItem(scheduleItemRetainHistoryNum, scheduleItemRetainHistoryNum);
             ddlRetainHistoryNum.FindItemByValue(Convert.ToString(scheduleItem.RetainHistoryNum)).Selected = true;
         }
         if (ddlAttachToEvent.FindItemByValue(scheduleItem.AttachToEvent) != null)
         {
             ddlAttachToEvent.FindItemByValue(scheduleItem.AttachToEvent).Selected = true;
         }
         chkCatchUpEnabled.Checked  = scheduleItem.CatchUpEnabled;
         txtObjectDependencies.Text = scheduleItem.ObjectDependencies;
         txtServers.Text            = scheduleItem.Servers.Trim(',');
     }
     else
     {
         cmdDelete.Visible = false;
         cmdRun.Visible    = false;
         txtType.Enabled   = true;
     }
 }
Esempio n. 19
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetDates gets the expiry/effective Dates of a Users Role membership
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="UserId">The Id of the User</param>
        /// <param name="RoleId">The Id of the Role</param>
        /// <history>
        ///     [cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        ///     [cnurse]    01/20/2006  Added support for Effective Date
        /// </history>
        /// -----------------------------------------------------------------------------
        private void GetDates(int UserId, int RoleId)
        {
            DateTime?expiryDate    = null;
            DateTime?effectiveDate = null;

            var          objRoles    = new RoleController();
            UserRoleInfo objUserRole = objRoles.GetUserRole(PortalId, UserId, RoleId);

            if (objUserRole != null)
            {
                if (Null.IsNull(objUserRole.EffectiveDate) == false)
                {
                    effectiveDate = objUserRole.EffectiveDate;
                }
                if (Null.IsNull(objUserRole.ExpiryDate) == false)
                {
                    expiryDate = objUserRole.ExpiryDate;
                }
            }
            else //new role assignment
            {
                RoleInfo objRole = TestableRoleController.Instance.GetRole(PortalId, r => r.RoleID == RoleId);

                if (objRole.BillingPeriod > 0)
                {
                    switch (objRole.BillingFrequency)
                    {
                    case "D":
                        expiryDate = DateTime.Now.AddDays(objRole.BillingPeriod);
                        break;

                    case "W":
                        expiryDate = DateTime.Now.AddDays(objRole.BillingPeriod * 7);
                        break;

                    case "M":
                        expiryDate = DateTime.Now.AddMonths(objRole.BillingPeriod);
                        break;

                    case "Y":
                        expiryDate = DateTime.Now.AddYears(objRole.BillingPeriod);
                        break;
                    }
                }
            }
            effectiveDatePicker.SelectedDate = effectiveDate;
            expiryDatePicker.SelectedDate    = expiryDate;
        }
Esempio n. 20
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/21/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdCancel.Click += OnCancelClick;
            cmdDelete.Click += OnDeleteClick;
            cmdSend.Click   += OnSendClick;
            cmdUpdate.Click += OnUpdateClick;

            if ((Request.QueryString["VendorId"] != null))
            {
                VendorId = Int32.Parse(Request.QueryString["VendorId"]);
            }

            if ((Request.QueryString["AffilId"] != null))
            {
                AffiliateId = Int32.Parse(Request.QueryString["AffilId"]);
            }

            if (Page.IsPostBack == false)
            {
                var affiliateController = new AffiliateController();
                if (AffiliateId != Null.NullInteger)
                {
                    //Obtain a single row of banner information
                    var affiliate = affiliateController.GetAffiliate(AffiliateId, VendorId, PortalId);
                    if (affiliate != null)
                    {
                        StartDatePicker.SelectedDate = Null.IsNull(affiliate.StartDate) ? (DateTime?)null : affiliate.StartDate;
                        EndDatePicker.SelectedDate   = Null.IsNull(affiliate.EndDate) ? (DateTime?)null : affiliate.EndDate;

                        txtCPC.Text = affiliate.CPC.ToString("#0.0####");
                        txtCPA.Text = affiliate.CPA.ToString("#0.0####");
                    }
                    else //security violation attempt to access item not related to this Module
                    {
                        Response.Redirect(EditUrl("VendorId", VendorId.ToString()), true);
                    }
                }
                else
                {
                    txtCPC.Text = 0.ToString("#0.0####");
                    txtCPA.Text = 0.ToString("#0.0####");

                    cmdDelete.Visible = false;
                }
            }
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetDates gets the expiry/effective Dates of a Users Role membership
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="UserId">The Id of the User</param>
        /// <param name="RoleId">The Id of the Role</param>
        /// <history>
        ///     [cnurse]	9/10/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        ///     [cnurse]    01/20/2006  Added support for Effective Date
        /// </history>
        /// -----------------------------------------------------------------------------
        private void GetDates(int UserId, int RoleId)
        {
            string strExpiryDate    = "";
            string strEffectiveDate = "";

            var          objRoles    = new RoleController();
            UserRoleInfo objUserRole = objRoles.GetUserRole(PortalId, UserId, RoleId);

            if (objUserRole != null)
            {
                if (Null.IsNull(objUserRole.EffectiveDate) == false)
                {
                    strEffectiveDate = objUserRole.EffectiveDate.ToShortDateString();
                }
                if (Null.IsNull(objUserRole.ExpiryDate) == false)
                {
                    strExpiryDate = objUserRole.ExpiryDate.ToShortDateString();
                }
            }
            else //new role assignment
            {
                RoleInfo objRole = objRoles.GetRole(RoleId, PortalId);

                if (objRole.BillingPeriod > 0)
                {
                    switch (objRole.BillingFrequency)
                    {
                    case "D":
                        strExpiryDate = DateTime.Now.AddDays(objRole.BillingPeriod).ToShortDateString();
                        break;

                    case "W":
                        strExpiryDate = DateTime.Now.AddDays(objRole.BillingPeriod * 7).ToShortDateString();
                        break;

                    case "M":
                        strExpiryDate = DateTime.Now.AddMonths(objRole.BillingPeriod).ToShortDateString();
                        break;

                    case "Y":
                        strExpiryDate = DateTime.Now.AddYears(objRole.BillingPeriod).ToShortDateString();
                        break;
                    }
                }
            }
            txtEffectiveDate.Text = strEffectiveDate;
            txtExpiryDate.Text    = strExpiryDate;
        }
Esempio n. 22
0
 /// <summary>
 /// Fill the object with data from database.
 /// </summary>
 /// <param name="dr">the data reader.</param>
 public void Fill(IDataReader dr)
 {
     MessageID       = Convert.ToInt32(dr["MessageID"]);
     To              = Null.SetNullString(dr["To"]);
     From            = Null.SetNullString(dr["From"]);
     Subject         = Null.SetNullString(dr["Subject"]);
     Body            = Null.SetNullString(dr["Body"]);
     ConversationId  = Null.SetNullInteger(dr["ConversationID"]);
     ReplyAllAllowed = Null.SetNullBoolean(dr["ReplyAllAllowed"]);
     SenderUserID    = Convert.ToInt32(dr["SenderUserID"]);
     RowNumber       = Convert.ToInt32(dr["RowNumber"]);
     AttachmentCount = Convert.ToInt32(dr["AttachmentCount"]);
     NewThreadCount  = Convert.ToInt32(dr["NewThreadCount"]);
     ThreadCount     = Convert.ToInt32(dr["ThreadCount"]);
     _createdOnDate  = Null.SetNullDateTime(dr["CreatedOnDate"]);
 }
 /// <summary>
 /// Fill the object with data from database.
 /// </summary>
 /// <param name="dr">the data reader.</param>
 public void Fill(IDataReader dr)
 {
     this.MessageID       = Convert.ToInt32(dr["MessageID"]);
     this.To              = Null.SetNullString(dr["To"]);
     this.From            = Null.SetNullString(dr["From"]);
     this.Subject         = Null.SetNullString(dr["Subject"]);
     this.Body            = HtmlUtils.ConvertToHtml(Null.SetNullString(dr["Body"]));
     this.ConversationId  = Null.SetNullInteger(dr["ConversationID"]);
     this.ReplyAllAllowed = Null.SetNullBoolean(dr["ReplyAllAllowed"]);
     this.SenderUserID    = Convert.ToInt32(dr["SenderUserID"]);
     this.RowNumber       = Convert.ToInt32(dr["RowNumber"]);
     this.AttachmentCount = Convert.ToInt32(dr["AttachmentCount"]);
     this.NewThreadCount  = Convert.ToInt32(dr["NewThreadCount"]);
     this.ThreadCount     = Convert.ToInt32(dr["ThreadCount"]);
     this._createdOnDate  = Null.SetNullDateTime(dr["CreatedOnDate"]);
 }
Esempio n. 24
0
 public void Fill(IDataReader dr)
 {
     MenuId      = Convert.ToInt32(dr["MenuId"]);
     Identifier  = dr["Identifier"].ToString();
     ModuleName  = dr["ModuleName"].ToString();
     FolderName  = Null.SetNullString(dr["FolderName"]);
     Controller  = dr["Controller"].ToString();
     ResourceKey = dr["ResourceKey"].ToString();
     Path        = dr["Path"].ToString();
     Link        = dr["Link"].ToString();
     CssClass    = dr["CssClass"].ToString();
     AllowHost   = Convert.ToBoolean(dr["AllowHost"]);
     Enabled     = Convert.ToBoolean(dr["Enabled"]);
     ParentId    = Null.SetNullInteger(dr["ParentId"]);
     Order       = Null.SetNullInteger(dr["Order"]);
 }
Esempio n. 25
0
        /// <summary>
        /// Fill the object with data from database.
        /// </summary>
        /// <param name="dr">the data reader.</param>
        public void Fill(IDataReader dr)
        {
            NotificationID     = Convert.ToInt32(dr["MessageID"]);
            NotificationTypeID = Convert.ToInt32(dr["NotificationTypeID"]);
            To                   = Null.SetNullString(dr["To"]);
            From                 = Null.SetNullString(dr["From"]);
            Subject              = Null.SetNullString(dr["Subject"]);
            Body                 = Null.SetNullString(dr["Body"]);
            Context              = Null.SetNullString(dr["Context"]);
            SenderUserID         = Convert.ToInt32(dr["SenderUserID"]);
            ExpirationDate       = Null.SetNullDateTime(dr["ExpirationDate"]);
            IncludeDismissAction = Null.SetNullBoolean(dr["IncludeDismissAction"]);

            //add audit column data
            FillInternal(dr);
        }
Esempio n. 26
0
        public void Fill(IDataReader dr)
        {
            base.FillInternal(dr);

            PortalAliasID = Null.SetNullInteger(dr["PortalAliasID"]);
            PortalID      = Null.SetNullInteger(dr["PortalID"]);
            HTTPAlias     = Null.SetNullString(dr["HTTPAlias"]);
            IsPrimary     = Null.SetNullBoolean(dr["IsPrimary"]);
            var browserType = Null.SetNullString(dr["BrowserType"]);

            BrowserType = String.IsNullOrEmpty(browserType) || browserType.ToLowerInvariant() == "normal"
                              ? BrowserTypes.Normal
                              : BrowserTypes.Mobile;
            CultureCode = Null.SetNullString(dr["CultureCode"]);
            Skin        = Null.SetNullString(dr["Skin"]);
        }
Esempio n. 27
0
 protected override IDisposable Run(IObserver <TSource> observer, IDisposable cancel, Action <IDisposable> setSink)
 {
     // LINQ to Objects makes this distinction in order to make [Max|Max] of an empty collection of reference type objects equal to null.
     if (default(TSource) == null)
     {
         var sink = new Null(_comparer, observer, cancel);
         setSink(sink);
         return(_source.SubscribeSafe(sink));
     }
     else
     {
         var sink = new NonNull(_comparer, observer, cancel);
         setSink(sink);
         return(_source.SubscribeSafe(sink));
     }
 }
 public override void Fill(IDataReader dr)
 {
     base.Fill(dr);
     Title               = Convert.ToString(Null.SetNull(dr["Title"], Title));
     ConferenceId        = Convert.ToInt32(Null.SetNull(dr["ConferenceId"], ConferenceId));
     SessionDateAndTime  = (DateTime)(Null.SetNull(dr["SessionDateAndTime"], SessionDateAndTime));
     SessionEnd          = (DateTime)(Null.SetNull(dr["SessionEnd"], SessionEnd));
     DisplayName         = Convert.ToString(Null.SetNull(dr["DisplayName"], DisplayName));
     Email               = Convert.ToString(Null.SetNull(dr["Email"], Email));
     Company             = Convert.ToString(Null.SetNull(dr["Company"], Company));
     AttCode             = Convert.ToString(Null.SetNull(dr["AttCode"], AttCode));
     SessionAttendeeName = Convert.ToString(Null.SetNull(dr["SessionAttendeeName"], SessionAttendeeName));
     ReviewStars         = Convert.ToInt32(Null.SetNull(dr["ReviewStars"], ReviewStars));
     CreatedByUser       = Convert.ToString(Null.SetNull(dr["CreatedByUser"], CreatedByUser));
     LastModifiedByUser  = Convert.ToString(Null.SetNull(dr["LastModifiedByUser"], LastModifiedByUser));
 }
Esempio n. 29
0
            private static string ParsePart(string[] parts, int index)
            {
                if (index >= parts.Length)
                {
                    return(null);
                }

                var value = parts[index];

                if (Null.Equals(value, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(null);
                }

                return(value);
            }
Esempio n. 30
0
        /// <summary>
        /// Fill the object with data from database.
        /// </summary>
        /// <param name="dr">the data reader.</param>
        public void Fill(IDataReader dr)
        {
            NotificationTypeId = Convert.ToInt32(dr["NotificationTypeID"]);
            Name        = dr["Name"].ToString();
            Description = Null.SetNullString(dr["Description"]);
            var timeToLive = Null.SetNullInteger(dr["TTL"]);

            if (timeToLive != Null.NullInteger)
            {
                TimeToLive = new TimeSpan(0, timeToLive, 0);
            }
            DesktopModuleId = Null.SetNullInteger(dr["DesktopModuleID"]);

            //add audit column data
            FillInternal(dr);
        }
Esempio n. 31
0
 public virtual void Fill(IDataReader dr)
 {
     FillAuditFields(dr);
     SlotId       = Convert.ToInt32(Null.SetNull(dr["SlotId"], SlotId));
     ConferenceId = Convert.ToInt32(Null.SetNull(dr["ConferenceId"], ConferenceId));
     if (dr["Start"] != DBNull.Value)
     {
         Start = (TimeSpan)dr["Start"];
     }
     DurationMins = Convert.ToInt32(Null.SetNull(dr["DurationMins"], DurationMins));
     SlotType     = Convert.ToInt32(Null.SetNull(dr["SlotType"], SlotType));
     Title        = Convert.ToString(Null.SetNull(dr["Title"], Title));
     Description  = Convert.ToString(Null.SetNull(dr["Description"], Description));
     DayNr        = Convert.ToInt32(Null.SetNull(dr["DayNr"], DayNr));
     LocationId   = Convert.ToInt32(Null.SetNull(dr["LocationId"], LocationId));
 }
Esempio n. 32
0
 protected void cmdDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (!Null.IsNull(itemId))
         {
             DateTimeCalcController controller = new DateTimeCalcController();
             controller.DeleteDateTimeCalc(this.ModuleId, itemId);
             Response.Redirect(Globals.NavigateURL(), true);
         }
     }
     catch (Exception ex)
     {
         Exceptions.ProcessModuleLoadException(this, ex);
     }
 }
Esempio n. 33
0
        public void Fill(IDataReader dr)
        {
            this.FillInternal(dr);

            this.PortalAliasID = Null.SetNullInteger(dr["PortalAliasID"]);
            this.PortalID      = Null.SetNullInteger(dr["PortalID"]);
            this.HTTPAlias     = Null.SetNullString(dr["HTTPAlias"]);
            this.IsPrimary     = Null.SetNullBoolean(dr["IsPrimary"]);
            var browserType = Null.SetNullString(dr["BrowserType"]);

            this.BrowserType = string.IsNullOrEmpty(browserType) || browserType.Equals("normal", StringComparison.OrdinalIgnoreCase)
                              ? BrowserTypes.Normal
                              : BrowserTypes.Mobile;
            this.CultureCode = Null.SetNullString(dr["CultureCode"]);
            this.Skin        = Null.SetNullString(dr["Skin"]);
        }
Esempio n. 34
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                // Determine ItemId of DnnTest to Update
                if ((Request.QueryString["ItemId"] != null))
                {
                    ItemId = Int32.Parse(Request.QueryString["ItemId"]);
                }

                // If this is the first visit to the page, bind the role data to the datalist
                if (Page.IsPostBack == false)
                {
                    cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");

                    if (!Null.IsNull(ItemId))
                    {
                        // get content
                        DnnTestController objDnnTests = new DnnTestController();
                        DnnTestInfo       objDnnTest  = objDnnTests.GetDnnTest(ModuleId, ItemId);
                        if ((objDnnTest != null))
                        {
                            lblTitle1.Text         = objDnnTest.Title;
                            lblContent1.Text       = objDnnTest.Content;
                            ctlAudit.CreatedByUser = objDnnTest.CreatedByUserName;
                            ctlAudit.CreatedDate   = objDnnTest.CreatedDate.ToString();
                        }
                        else
                        {
                            // security violation attempt to access item not related to this Module
                            Response.Redirect(Globals.NavigateURL(), true);
                        }
                    }
                    else
                    {
                        cmdDelete.Visible = false;
                        ctlAudit.Visible  = false;
                    }
                }
            }

            catch (Exception exc)
            {
                //Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Esempio n. 35
0
        public int AddTab(TabInfo objTab, bool AddAllTabsModules)
        {
            int intTabId;

            objTab.TabPath = Globals.GenerateTabPath(objTab.ParentId, objTab.TabName);
            intTabId       = DataProvider.Instance().AddTab(objTab.PortalID, objTab.TabName, objTab.IsVisible, objTab.DisableLink, objTab.ParentId, objTab.IconFile, objTab.Title, objTab.Description, objTab.KeyWords, objTab.Url, objTab.SkinSrc, objTab.ContainerSrc, objTab.TabPath, objTab.StartDate, objTab.EndDate, objTab.RefreshInterval, objTab.PageHeadText);

            TabPermissionController objTabPermissionController = new TabPermissionController();

            if (objTab.TabPermissions != null)
            {
                TabPermissionCollection objTabPermissions = objTab.TabPermissions;

                foreach (TabPermissionInfo objTabPermission in objTabPermissions)
                {
                    objTabPermission.TabID = intTabId;
                    if (objTabPermission.AllowAccess)
                    {
                        objTabPermissionController.AddTabPermission(objTabPermission);
                    }
                }
            }
            if (!(Null.IsNull(objTab.PortalID)))
            {
                UpdatePortalTabOrder(objTab.PortalID, intTabId, objTab.ParentId, 0, 0, objTab.IsVisible, true);
            }
            else // host tab
            {
                ArrayList arrTabs = GetTabsByParentId(objTab.ParentId, objTab.PortalID);
                UpdateTabOrder(objTab.PortalID, intTabId, (arrTabs.Count * 2) - 1, 1, objTab.ParentId);
            }

            if (AddAllTabsModules)
            {
                ModuleController objmodules = new ModuleController();
                ArrayList        arrMods    = objmodules.GetAllTabsModules(objTab.PortalID, true);

                foreach (ModuleInfo objModule in arrMods)
                {
                    objmodules.CopyModule(objModule.ModuleID, objModule.TabID, intTabId, "", true);
                }
            }

            ClearCache(objTab.PortalID);

            return(intTabId);
        }
Esempio n. 36
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["ItemId"] != null)
                {
                    itemId = Int32.Parse(Request.QueryString["ItemId"]);
                }

                if (!IsPostBack)
                {
                    //load the data into the control the first time
                    //we hit this page


                    cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");

                    //check we have an item to lookup
                    if (!Null.IsNull(itemId))
                    {
                        //load the item
                        DateTimeCalcController controller = new DateTimeCalcController();
                        DateTimeCalcInfo       item       = controller.GetDateTimeCalc(this.ModuleId, itemId);

                        if (item != null)
                        {
                            txtContent.Text        = item.Content;
                            ctlAudit.CreatedByUser = item.CreatedByUserName;
                            ctlAudit.CreatedDate   = item.CreatedDate.ToLongDateString();
                        }
                        else
                        {
                            Response.Redirect(Globals.NavigateURL(), true);
                        }
                    }
                    else
                    {
                        cmdDelete.Visible = false;
                        ctlAudit.Visible  = false;
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Esempio n. 37
0
        /// <summary>Used to create correct variable type object for the specified encoded type</summary>
        /// <param name="asnType">ASN.1 type code</param>
        /// <returns>A new object matching type supplied or null if type was not recognized.</returns>
        public static AsnType GetSyntaxObject(SMIDataTypeCode asnType)
        {
            AsnType obj = null;
            if (asnType == SMIDataTypeCode.Integer)
                obj = new Integer32 ();
            else if (asnType == SMIDataTypeCode.Counter32)
                obj = new Counter32 ();
            else if (asnType == SMIDataTypeCode.Gauge32)
                obj = new Gauge32 ();
            else if (asnType == SMIDataTypeCode.Counter64)
                obj = new Counter64 ();
            else if (asnType == SMIDataTypeCode.TimeTicks)
                obj = new TimeTicks ();
            else if (asnType == SMIDataTypeCode.OctetString)
                obj = new OctetString ();
            else if (asnType == SMIDataTypeCode.Opaque)
                obj = new Opaque ();
            else if (asnType == SMIDataTypeCode.IPAddress)
                obj = new IpAddress ();
            else if (asnType == SMIDataTypeCode.ObjectId)
                obj = new Oid ();
            else if (asnType == SMIDataTypeCode.PartyClock)
                obj = new V2PartyClock ();
            else if (asnType == SMIDataTypeCode.NoSuchInstance)
                obj = new NoSuchInstance ();
            else if (asnType == SMIDataTypeCode.NoSuchObject)
                obj = new NoSuchObject ();
            else if (asnType == SMIDataTypeCode.EndOfMibView)
                obj = new EndOfMibView ();
            else if (asnType == SMIDataTypeCode.Null)
            {
                obj = new Null ();
            }

            return obj;
        }
Esempio n. 38
0
 public static bool op_Implicit(Null self) {
     Debug.Assert(self == null);
     return false;
 }
        /// <summary> Parse a mapping </summary>
        public Mapping(ParseStream stream)
            : base("tag:yaml.org,2002:map", NodeType.Mapping)
        {
            // Mapping with eplicit key, (implicit mappings are threaded
            // in Node.cs)
            if (stream.Char == '?')
            {
                // Parse recursively
                do {
                    Node key, val;

                    // Skip over '?'
                    stream.Next ();
                    stream.SkipSpaces ();

                    // Parse recursively. The false param avoids
                    // looking recursively for implicit mappings.
                    stream.StopAt (new char [] {':'});
                    stream.Indent ();
                    key = Parse (stream, false);
                    stream.UnIndent ();
                    stream.DontStop ();

                    // Parse recursively. The false param avoids
                    // looking for implit nodes
                    if (stream.Char == ':')
                    {
                        // Skip over ':'
                        stream.Next ();
                        stream.SkipSpaces ();

                        // Parse recursively
                        stream.Indent ();
                        val = Parse (stream);
                        stream.UnIndent ();
                    }
                    else
                        val = new Null ();

                    AddMappingNode (key, val);

                    // Skip possible newline
                    // NOTE: this can't be done by the drop-newline
                    // method since this is not the end of a block
                    if (stream.Char == '\n')
                        stream.Next ();
                }
                while ( ! stream.EOF && stream.Char == '?');
            }
            // Inline mapping
            else if (stream.Char == '{')
            {
                // Override the parent's stop chars, never stop
                stream.StopAt (new char [] { });

                // Skip '{'
                stream.Next ();

                do {
                    Node key, val;

                    // Skip '?'
                    // (NOTE: it's not obligated to use this '?',
                    // especially because this is an inline mapping)
                    if (stream.Char == '?')
                    {
                        stream.Next ();
                        stream.SkipSpaces ();
                    }

                    // Parse recursively the key
                    stream.StopAt (new char [] {':', ',', '}'});
                    stream.Indent ();
                        key = Parse (stream, false);
                    stream.UnIndent ();
                    stream.DontStop ();

                    // Value
                    if (stream.Char == ':')
                    {
                        // Skip colon
                        stream.Next ();
                        stream.SkipSpaces ();

                        // Parse recursively the value
                        stream.StopAt (new char [] {'}', ','});
                        stream.Indent ();
                            val = Parse (stream, false);
                        stream.UnIndent ();
                        stream.DontStop ();
                    }
                    else
                        val = new Null ();

                    AddMappingNode (key, val);

                    // Skip comma (key sepatator)
                    if (stream.Char != '}' && stream.Char != ',')
                    {
                        stream.DontStop ();
                        throw new ParseException (stream, "Comma expected in inline sequence");
                    }

                    if (stream.Char == ',')
                    {
                        stream.Next ();
                        stream.SkipSpaces ();
                    }
                }
                while ( ! stream.EOF && stream.Char != '}' );

                // Re-accept the parent's stop chars
                stream.DontStop ();

                // Skip '}'
                if (stream.Char == '}')
                    stream.Next ();
                else
                    throw new ParseException (stream, "Inline mapping not closed");
            }
        }
Esempio n. 40
0
 public void Visit(Null x)
 {
 }
Esempio n. 41
0
 public static Expression CompileNull(Null nil, Scope scope)
 {
     return Expression.Default(ObjectType);
 }
Esempio n. 42
0
 public bool Equals(Null other)
 {
     return !ReferenceEquals(null, other);
 }
Esempio n. 43
0
 /// <summary>Constructor</summary>
 /// <param name="second">Irrelevant. Nothing to copy</param>
 public Null(Null second)
     : this()
 {
 }
Esempio n. 44
0
        /// <summary>
        /// Return SNMP type object of the type specified by name. Supported variable types are:
        /// <see cref="Integer32"/>, <see cref="Counter32"/>, <see cref="Gauge32"/>, <see cref="Counter64"/>,
        /// <see cref="TimeTicks"/>, <see cref="OctetString"/>, <see cref="IpAddress"/>, <see cref="Oid"/>, and
        /// <see cref="Null"/>.
        /// 
        /// Type names are the same as support class names compared without case sensitivity (e.g. Integer == INTEGER).
        /// </summary>
        /// <param name="name">Name of the object type (not case sensitive)</param>
        /// <returns>New <see cref="AsnType"/> object.</returns>
        public static AsnType GetSyntaxObject(string name)
        {
            AsnType obj = null;
            if (name.ToUpper ().Equals ("INTEGER32") || name.ToUpper ().Equals ("INTEGER"))
                obj = new Integer32 ();
            else if (name.ToUpper ().Equals ("COUNTER32"))
                obj = new Counter32 ();
            else if (name.ToUpper ().Equals ("GAUGE32"))
                obj = new Gauge32 ();
            else if (name.ToUpper ().Equals ("COUNTER64"))
                obj = new Counter64 ();
            else if (name.ToUpper ().Equals ("TIMETICKS"))
                obj = new TimeTicks ();
            else if (name.ToUpper ().Equals ("OCTETSTRING"))
                obj = new OctetString ();
            else if (name.ToUpper ().Equals ("IPADDRESS"))
                obj = new IpAddress ();
            else if (name.ToUpper ().Equals ("OID"))
                obj = new Oid ();
            else if (name.ToUpper ().Equals ("NULL"))
                obj = new Null ();
            else
                throw new ArgumentException ("Invalid value type name");

            return obj;
        }
 protected override Null VisitNull(Null node)
 {
     visitedNull = true;
     Assert.IsTrue(node.Value == "null");
     return base.VisitNull(node);
 }
Esempio n. 46
0
        /// <summary>Used to create correct variable type object for the specified encoded type</summary>
        /// <param name="asnType">ASN.1 type code</param>
        /// <returns>A new object matching type supplied or null if type was not recognized.</returns>
        public static AsnType GetSyntaxObject(byte asnType)
        {
            AsnType obj = null;
            if (asnType == SnmpConstants.SMI_INTEGER)
                obj = new Integer32();
            else if (asnType == SnmpConstants.SMI_COUNTER32)
                obj = new Counter32();
            else if (asnType == SnmpConstants.SMI_GAUGE32)
                obj = new Gauge32();
            else if (asnType == SnmpConstants.SMI_COUNTER64)
                obj = new Counter64();
            else if (asnType == SnmpConstants.SMI_TIMETICKS)
                obj = new TimeTicks();
            else if (asnType == SnmpConstants.SMI_STRING)
                obj = new OctetString();
            else if (asnType == SnmpConstants.SMI_OPAQUE)
                obj = new Opaque();
            else if (asnType == SnmpConstants.SMI_IPADDRESS)
                obj = new IpAddress();
            else if (asnType == SnmpConstants.SMI_OBJECTID)
                obj = new Oid();
            else if (asnType == SnmpConstants.SMI_PARTY_CLOCK)
                obj = new V2PartyClock();
            else if (asnType == SnmpConstants.SMI_NOSUCHINSTANCE)
                obj = new NoSuchInstance();
            else if (asnType == SnmpConstants.SMI_NOSUCHOBJECT)
                obj = new NoSuchObject();
            else if (asnType == SnmpConstants.SMI_ENDOFMIBVIEW)
                obj = new EndOfMibView();
            else if (asnType == SnmpConstants.SMI_NULL)
            {
                obj = new Null();
            }

            return obj;
        }
Esempio n. 47
0
        public Expression TypeCheck(Null nullLiteral, Scope scope)
        {
            var Position = nullLiteral.Position;

            return new Null(Position, NamedType.Nullable.MakeGenericType(TypeVariable.CreateGeneric()));
        }
Esempio n. 48
0
        /// <summary> Internal parse method </summary>
        /// <param name="parseImplicitMappings">
        ///   Avoids ethernal loops while parsing implicit mappings. Implicit mappings are
        ///   not rocognized by a leading character. So while trying to parse the key of
        ///   something we think that could be a mapping, we're sure that if it is a mapping,
        ///   the key of this implicit mapping is not a mapping itself.
        ///
        ///   NOTE: Implicit mapping still belong to unstable code and require the UNSTABLE and
        ///         IMPLICIT_MAPPINGS preprocessor flags.
        /// </param>
        /// <param name="stream"></param>
        protected static Node Parse(ParseStream stream, bool parseImplicitMappings)
        {
            // ----------------
            // Skip Whitespace
            // ----------------
            if (!stream.EOF)
            {
                // Move the firstindentation pointer after the whitespaces of this line
                stream.SkipSpaces();
                while (stream.Char == '\n' && !stream.EOF)
                {
                    // Skip newline and next whitespaces
                    stream.Next();
                    stream.SkipSpaces();
                }
            }

            // -----------------
            // No remaining chars (Null/empty stream)
            // -----------------
            if (stream.EOF)
                return new Null();

            // -----------------
            // Explicit type
            // -----------------

#if SUPPORT_EXPLICIT_TYPES
			stream.BuildLookaheadBuffer ();

			char a = '\0', b = '\0';

			a = stream.Char; stream.Next ();
			b = stream.Char; stream.Next ();

			// Starting with !!
			if (a == '!' && b == '!' && ! stream.EOF)
			{
				stream.DestroyLookaheadBuffer ();

				// Read the tagname
				string tag = "";

				while (stream.Char != ' ' && stream.Char != '\n' && ! stream.EOF)
				{
					tag += stream.Char;
					stream.Next ();
				}

				// Skip Whitespace
				if (! stream.EOF)
				{
					stream.SkipSpaces ();
					while (stream.Char == '\n' && ! stream.EOF)
					{
						stream.Next ();
						stream.SkipSpaces ();
					}
				}

				// Parse
				Node n;
				switch (tag)
				{
					// Mappings and sequences
					// NOTE:
					// - sets are mappings without values
					// - Ordered maps are ordered sequence of key: value
					//   pairs without duplicates.
					// - Pairs are ordered sequence of key: value pairs
					//   allowing duplicates.

					// TODO: Create new datatypes for omap and pairs
					//   derived from sequence with a extra duplicate
					//   checking.

					case "seq":       n = new Sequence  (stream); break;
					case "map":       n = new Mapping   (stream); break;
					case "set":       n = new Mapping   (stream); break;
					case "omap":      n = new Sequence  (stream); break;
					case "pairs":     n = new Sequence  (stream); break;

					// Scalars
					//
					// TODO: do we have to move this to Scalar.cs
					// in order to get the following working:
					//
					// !!str "...": "..."
					// !!str "...": "..."

					case "timestamp": n = new Timestamp (stream); break;
					case "binary":    n = new Binary    (stream); break;
					case "null":      n = new Null      (stream); break;
					case "float":     n = new Float     (stream); break;
					case "int":       n = new Integer   (stream); break;
					case "bool":      n = new Boolean   (stream); break;
					case "str":       n = new String    (stream); break;

					// Unknown data type
					default:
						throw  new Exception ("Incorrect tag '!!" + tag + "'");
				}

				return n;
			}
			else
			{
				stream.RewindLookaheadBuffer ();
				stream.DestroyLookaheadBuffer ();
			}
#endif
            // -----------------
            // Sequence
            // -----------------

            if (stream.Char == '-' || stream.Char == '[')
                return new Sequence(stream);

            // -----------------
            // Mapping
            // -----------------

            if (stream.Char == '?' || stream.Char == '{')
                return new Mapping(stream);

            // -----------------
            // Try implicit mapping
            // -----------------

            // This are mappings which are not preceded by a question
            // mark. The keys have to be scalars.

#if (UNSTABLE && SUPPORT_IMPLICIT_MAPPINGS)

			// NOTE: This code can't be included in Mapping.cs
			// because of the way we are using to rewind the buffer.

			Node key, val;

			if (parseImplicitMappings)
			{
				// First Key/value pair

				stream.BuildLookaheadBuffer ();

				stream.StopAt (new char [] {':'});

				// Keys of implicit mappings can't be sequences, or other mappings
				// just look for scalars
				key = Scalar.Parse (stream, false); 
				stream.DontStop ();

Console.WriteLine ("key: " + key);

				// Followed by a colon, so this is a real mapping
				if (stream.Char == ':')
				{
					stream.DestroyLookaheadBuffer ();

					Mapping mapping = new Mapping ();

					// Skip colon and spaces
					stream.Next ();
					stream.SkipSpaces ();

					// Parse the value
Console.Write ("using  buffer: " + stream.UsingBuffer ());
					stream.Indent ();
Console.Write ("using  buffer: " + stream.UsingBuffer ());
//					val = Parse (stream, false);
Console.Write ("<<");
while (!stream.EOF) {Console.Write (stream.Char);stream.Next (true);}
Console.Write (">>");

val = new  String (stream);


Console.Write ("using  buffer: " + stream.UsingBuffer ());
					stream.UnIndent ();
Console.Write ("using  buffer: " + stream.UsingBuffer ());

Console.Write ("<<");
while (!stream.EOF) {Console.Write (stream.Char);stream.Next (true);}
Console.Write (">>");




Console.WriteLine ("val: " + val);
					mapping.AddMappingNode (key, val);

					// Skip possible newline
					// NOTE: this can't be done by the drop-newline
					// method since this is not the end of a block
					while (stream.Char == '\n')
						stream.Next (true);

					// Other key/value pairs
					while (! stream.EOF)
					{
						stream.StopAt (new char [] {':'} );
						stream.Indent ();
						key = Scalar.Parse (stream);
						stream.UnIndent ();
						stream.DontStop ();

Console.WriteLine ("key 2: " + key);
						if (stream.Char == ':')
						{
							// Skip colon and spaces
							stream.Next ();
							stream.SkipSpaces ();

							// Parse the value
							stream.Indent ();
							val = Parse (stream);
							stream.UnIndent ();

Console.WriteLine ("val 2: " + val);
							mapping.AddMappingNode (key, val);
						}
						else // TODO: Is this an error?
						{
							// NOTE: We can't recover from this error,
							// the last buffer has been destroyed, so
							// rewinding is impossible.
							throw new ParseException (stream,
								"Implicit mapping without value node");
						}

						// Skip possible newline
						while (stream.Char == '\n')
							stream.Next ();
					}

					return mapping;
				}

				stream.RewindLookaheadBuffer ();
				stream.DestroyLookaheadBuffer ();
			}

#endif
            // -----------------
            // No known data structure, assume this is a scalar
            // -----------------

            Scalar scalar = Scalar.Parse(stream);

            // Skip trash
            while (!stream.EOF)
                stream.Next();


            return scalar;
        }
Esempio n. 49
0
 public void TestEqual()
 {
     var left = new Null();
     var right = new Null();
     Assert.AreEqual(left, right);
 }
 protected virtual Null VisitNull(Null node)
 {
     return VisitSyntaxNode(node) as Null;
 }
Esempio n. 51
0
        /// <summary>
        /// Return SNMP type object of the type specified by name. Supported variable types are:
        /// * <see cref="Integer32"/>
        /// * <see cref="Counter32"/>
        /// * <see cref="Gauge32"/>
        /// * <see cref="Counter64"/>
        /// * <see cref="TimeTicks"/>
        /// * <see cref="OctetString"/>
        /// * <see cref="IpAddress"/>
        /// * <see cref="Oid"/>
        /// * <see cref="Null"/>
        /// </summary>
        /// <param name="name">Name of the object type</param>
        /// <returns>New <see cref="AsnType"/> object.</returns>
        public static AsnType GetSyntaxObject(string name)
        {
            AsnType obj = null;
            if (name == "Integer32")
                obj = new Integer32();
            else if (name == "Counter32")
                obj = new Counter32();
            else if (name == "Gauge32")
                obj = new Gauge32();
            else if (name == "Counter64")
                obj = new Counter64();
            else if (name == "TimeTicks")
                obj = new TimeTicks();
            else if (name == "OctetString")
                obj = new OctetString();
            else if (name == "IpAddress")
                obj = new IpAddress();
            else if (name == "Oid")
                obj = new Oid();
            else if (name == "Null")
                obj = new Null();
            else
                throw new ArgumentException("Invalid value type name");

            return obj;
        }
 public static Spec WillNotAuthenticateUserWithBadLoginCountOfThreeOrHigher(string input, Null output)
 {
     return
         new Spec(() => Ensure.False(User.IsAuthenticated))
             .If(() => User.BadLoginCount >= 3);
 }
Esempio n. 53
0
        /// <summary>
        ///   Parses a scalar
        ///   <list type="bullet">
        ///     <item>Integer</item>
        ///     <item>String</item>
        ///     <item>Boolean</item>
        ///     <item>Null</item>
        ///     <item>Timestamp</item>
        ///     <item>Float</item>
        ///     <item>Binary</item>
        ///   </list>
        /// </summary>
        /// <remarks>
        ///   Binary is only parsed behind an explicit !!binary tag (in Node.cs)
        /// </remarks>
        public static new Scalar Parse(ParseStream stream)
        {
            // -----------------
            // Parse scalars
            // -----------------

            stream.BuildLookaheadBuffer();

            // Try Null
#if SUPPORT_NULL_NODES
			try
			{
				Scalar s = new Null (stream);
				stream.DestroyLookaheadBuffer ();
				return s;
			} catch { }
#endif
            // Try boolean
#if SUPPORT_BOOLEAN_NODES
			stream.RewindLookaheadBuffer ();
			try
			{
				Scalar scalar = new Boolean (stream);
				stream.DestroyLookaheadBuffer ();
				return scalar;
			} 
			catch { }
#endif
            // Try integer
#if SUPPORT_INTEGER_NODES
			stream.RewindLookaheadBuffer ();
			try
			{
				Scalar scalar = new Integer (stream);
				stream.DestroyLookaheadBuffer ();
				return scalar;
			} catch { }
#endif
            // Try Float
#if SUPPORT_FLOAT_NODES
			stream.RewindLookaheadBuffer ();
			try
			{
				Scalar scalar = new Float (stream);
				stream.DestroyLookaheadBuffer ();
				return scalar;
			} 
			catch { }
#endif
            // Try timestamp
#if SUPPORT_TIMESTAMP_NODES
			stream.RewindLookaheadBuffer ();
			try {
				Scalar scalar = new Timestamp (stream);
				stream.DestroyLookaheadBuffer ();
				return scalar;
			} catch { }
#endif
            // Other scalars are strings
            stream.RewindLookaheadBuffer();
            stream.DestroyLookaheadBuffer();

            return new String(stream);
        }
Esempio n. 54
0
 public override bool Send(Null request)
 {
     return Items.Any(MessageFunc<bool>.Response);
 }
 public static Spec WillNotUpdateLoginDateOnFailedLogin(string input, Null output)
 {
     return 
         new Spec(() => Ensure.NotEqual(SystemTime.Now(), User.LastLogin))
             .IfAfter(UserIsNotLoggedOn);
 }
Esempio n. 56
0
		public NullTransform (Null algo, bool encryption, byte[] key, byte[] iv)
			: base (algo, encryption, iv)
		{
			_block = 0;
			_debug = (Environment.GetEnvironmentVariable ("MONO_DEBUG") != null);
			if (_debug) {
				Console.WriteLine ("Mode: {0}", encryption ? "encryption" : "decryption");
				Console.WriteLine ("Key:  {0}", BitConverter.ToString (key));
				Console.WriteLine ("IV:   {0}", BitConverter.ToString (iv));
			}
		}