/// <summary>
		/// Set the given boolean to either a boolean or integer model property.
		/// </summary>
		public static void SetValueFromBoolean(ISilDataAccess sda, int hvo, int tag, bool newValue)
		{
			if (sda == null) throw new ArgumentNullException("sda");

			if ((CellarPropertyType)sda.MetaDataCache.GetFieldType(tag) == CellarPropertyType.Boolean)
				sda.SetBoolean(hvo, tag, newValue);
			else
				sda.SetInt(hvo, tag, newValue ? 1 : 0);
		}
Esempio n. 2
0
        public void IntProp()
        {
            CheckDisposed();
            int valNew = m_ISilDataAccess.get_IntProp(1115, 2225);

            Assert.AreEqual(0, valNew);
            Assert.IsFalse(m_ISilDataAccess.IsDirty());

            m_ISilDataAccess.SetInt(1115, 2225, int.MaxValue);
            valNew = m_ISilDataAccess.get_IntProp(1115, 2225);
            Assert.AreEqual(int.MaxValue, valNew);
            Assert.IsTrue(m_ISilDataAccess.IsDirty());

            m_ISilDataAccess.SetInt(1115, 2225, int.MinValue);
            valNew = m_ISilDataAccess.get_IntProp(1115, 2225);
            Assert.AreEqual(int.MinValue, valNew);
            Assert.IsTrue(m_ISilDataAccess.IsDirty());

            CheckProp(1115, 2225, int.MinValue, CellarModuleDefns.kcptInteger);
        }
Esempio n. 3
0
        /// <summary>
        /// Set the given boolean to either a boolean or integer model property.
        /// </summary>
        public static void SetValueFromBoolean(ISilDataAccess sda, int hvo, int tag, bool newValue)
        {
            if (sda == null)
            {
                throw new ArgumentNullException("sda");
            }

            if ((CellarPropertyType)sda.MetaDataCache.GetFieldType(tag) == CellarPropertyType.Boolean)
            {
                sda.SetBoolean(hvo, tag, newValue);
            }
            else
            {
                sda.SetInt(hvo, tag, newValue ? 1 : 0);
            }
        }
Esempio n. 4
0
		internal virtual void SetValueOfField(ISilDataAccess sda, int hvoField, int val)
		{
			sda.SetInt(hvoField, m_flidSub, val);
		}
Esempio n. 5
0
		protected virtual void SetBasicPropertyValue(ISilDataAccess sda, int newVal, int hvoOwner)
		{
			int type = m_sda.MetaDataCache.GetFieldType(m_flid);
			if (type == (int)CellarPropertyType.Boolean)
				sda.SetBoolean(hvoOwner, m_flid, newVal != 0);
			else
				sda.SetInt(hvoOwner, m_flid, newVal);
		}
 /// <summary>
 ///
 /// </summary>
 /// <param name="hvo"></param>
 /// <param name="tag"></param>
 /// <param name="n"></param>
 public void SetInt(int hvo, int tag, int n)
 {
     VerifyUpdate(hvo, tag);
     m_sda.SetInt(hvo, tag, n);
 }
Esempio n. 7
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the flids for basic data (bool, string, int, etc.)
        /// </summary>
        /// <param name="thisFlid">The object type flid.</param>
        /// <param name="flidType">The owning flid type.</param>
        /// <param name="hvoSrc">The hvo of the source object.</param>
        /// <param name="hvoNew">The hvo of the new object.</param>
        /// ------------------------------------------------------------------------------------
        private void HandleBasicOrStringFlid(int thisFlid, int flidType, int hvoSrc, int hvoNew)
        {
            // Basic and String properties are copied
            switch (flidType)
            {
            // Basic Properties follow

            case (int)CellarPropertyType.Binary:
                string flidName = m_mdc.GetFieldName(thisFlid);
                if (flidName == "Rules" || flidName == "StyleRules")
                {
                    CopyBinaryAsTextProps(thisFlid, hvoSrc, hvoNew);
                }
                else
                {
                    CopyBinaryAsBinary(thisFlid, hvoSrc, hvoNew);
                }
                break;

            case (int)CellarPropertyType.Boolean:
                // Copy boolean value
                m_sda.SetBoolean(hvoNew, thisFlid, m_sda.get_BooleanProp(hvoSrc, thisFlid));
                break;

            case (int)CellarPropertyType.Guid:
                // Copy guid value
                // These are currently used as the ID for an application, or a version number, or a Scripture Check ID)
                m_sda.SetGuid(hvoNew, thisFlid, m_sda.get_GuidProp(hvoSrc, thisFlid));
                break;

            case (int)CellarPropertyType.GenDate:                     // Fall through, since a GenDate is an int.
            case (int)CellarPropertyType.Integer:
                // Copy integer value
                m_sda.SetInt(hvoNew, thisFlid, m_sda.get_IntProp(hvoSrc, thisFlid));
                break;

            case (int)CellarPropertyType.Time:
                // Copy time value
                m_sda.SetTime(hvoNew, thisFlid, m_sda.get_TimeProp(hvoSrc, thisFlid));
                break;

            // String Properties follow

            case (int)CellarPropertyType.String:
                // Copy string value
                // Review: Please check these next three!
                m_sda.SetString(hvoNew, thisFlid, m_sda.get_StringProp(hvoSrc, thisFlid));
                break;

            case (int)CellarPropertyType.Unicode:
                // Copy Unicode string
                m_sda.set_UnicodeProp(hvoNew, thisFlid, m_sda.get_UnicodeProp(hvoSrc, thisFlid));
                break;

            case (int)CellarPropertyType.MultiString:                     // Fall through
            case (int)CellarPropertyType.MultiUnicode:
                ITsMultiString sMulti = m_sda.get_MultiStringProp(hvoSrc, thisFlid);
                for (int i = 0; i < sMulti.StringCount; i++)
                {
                    int       ws;
                    ITsString tss = sMulti.GetStringFromIndex(i, out ws);
                    m_sda.SetMultiStringAlt(hvoNew, thisFlid, ws, tss);
                }
                break;

            default:
                throw new FDOInvalidFieldTypeException(String.Format("CopyObject: Unsupported field type {0}.", flidType));
            }
        }
Esempio n. 8
0
		protected virtual void SetBasicPropertyValue(ISilDataAccess sda, int newVal, int hvoOwner)
		{
			sda.SetInt(hvoOwner, m_flid, newVal);
		}
Esempio n. 9
0
 /// <summary>
 /// Change an integer property of an object.
 /// The caller should also call PropChanged to notify interested parties,
 /// except where the change is being made to a newly created object.
 ///</summary>
 /// <param name='hvo'> </param>
 /// <param name='tag'> </param>
 /// <param name='n'> </param>
 public virtual void SetInt(int hvo, int tag, int n)
 {
     m_baseSda.SetInt(hvo, tag, n);
 }