Esempio n. 1
0
        /// <summary>
        /// Setup DependencyPaths property
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="cache"></param>
        protected void SetupDependencies(XmlNode configuration, FdoCache cache)
        {
            if (DependencyPaths.Count > 0)
            {
                return;                 // already setup.
            }
            string dependsStr = XmlUtils.GetOptionalAttributeValue(configuration, "depends");

            if (dependsStr == null || cache == null)
            {
                return;
            }
            string[] depends = dependsStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string fieldPath in depends)
            {
                string[]   fieldtree    = fieldPath.Split(new char[] { '.' });
                List <int> tags         = new List <int>(fieldtree.Length);
                string     srcClassName = this.ClassName;
                foreach (string field in fieldtree)
                {
                    int tag = cache.GetFlid(0, srcClassName, field);
                    Debug.Assert(tag > 0, String.Format("Invalid dependency field {0} in field path {1}.", field, fieldPath));
                    if (tag <= 0)
                    {
                        break;
                    }
                    tags.Add(tag);
                    if (tags.Count < fieldtree.Length)
                    {
                        string nextFieldName = fieldtree[tags.Count];
                        // make dst class the source class of next field
                        uint clsidDst = 0;
                        if (field == "OwnerHVO")
                        {
                            // handle the special case where we need the owning class
                            // this is only possible if srcClassName is has a unique owner.
                            // find the first class that owns the given 'classId' and the given fieldName.
                            clsidDst = GetClassOwningClassAndFieldName(cache, srcClassName, nextFieldName);
                        }
                        else
                        {
                            ClassAndPropInfo cpi = cache.GetClassAndPropInfo((uint)tag);
                            if (ClassHasField(cache, cache.GetClassName(cpi.signatureClsid), nextFieldName))
                            {
                                clsidDst = cpi.signatureClsid;
                            }
                            else if (cpi.isAbstract)
                            {
                                // find a subclasses that could refer to the nextFieldName.
                                clsidDst = GetSubclassOwningNextField(cache, tag, nextFieldName);
                            }
                        }
                        srcClassName = cache.GetClassName(clsidDst);
                    }
                }
                m_fieldPaths.Add(tags);
            }
        }
Esempio n. 2
0
		/// <summary>
		/// Setup DependencyPaths property
		/// </summary>
		/// <param name="configuration"></param>
		/// <param name="cache"></param>
		protected void SetupDependencies(XmlNode configuration, FdoCache cache)
		{
			if (DependencyPaths.Count > 0)
				return;	// already setup.
			string dependsStr = XmlUtils.GetOptionalAttributeValue(configuration, "depends");
			if (dependsStr == null || cache == null)
				return;
			string[] depends = dependsStr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
			foreach (string fieldPath in depends)
			{
				string[] fieldtree = fieldPath.Split(new char[] { '.' });
				List<int> tags = new List<int>(fieldtree.Length);
				string srcClassName = this.ClassName;
				foreach (string field in fieldtree)
				{
					int tag = cache.GetFlid(0, srcClassName, field);
					Debug.Assert(tag > 0, String.Format("Invalid dependency field {0} in field path {1}.", field, fieldPath));
					if (tag <= 0)
						break;
					tags.Add(tag);
					if (tags.Count < fieldtree.Length)
					{
						string nextFieldName = fieldtree[tags.Count];
						// make dst class the source class of next field
						uint clsidDst = 0;
						if (field == "OwnerHVO")
						{
							// handle the special case where we need the owning class
							// this is only possible if srcClassName is has a unique owner.
							// find the first class that owns the given 'classId' and the given fieldName.
							clsidDst = GetClassOwningClassAndFieldName(cache, srcClassName, nextFieldName);
						}
						else
						{
							ClassAndPropInfo cpi = cache.GetClassAndPropInfo((uint)tag);
							if (ClassHasField(cache, cache.GetClassName(cpi.signatureClsid), nextFieldName))
							{
								clsidDst = cpi.signatureClsid;
							}
							else if (cpi.isAbstract)
							{
								// find a subclasses that could refer to the nextFieldName.
								clsidDst = GetSubclassOwningNextField(cache, tag, nextFieldName);
							}
						}
						srcClassName = cache.GetClassName(clsidDst);
					}
				}
				m_fieldPaths.Add(tags);
			}
		}