コード例 #1
0
        public static string GetTranslationValue(this Oms oms, InstanceHandle sourceInstance, InstanceHandle relationshipInstance, InstanceHandle languageInstance, string defaultValue = null)
        {
            InstanceHandle keyTTC = oms.GetRelatedInstance(sourceInstance, relationshipInstance);

            InstanceHandle[] keyTTCValues = oms.GetRelatedInstances(keyTTC, oms.GetInstance(KnownRelationshipGuids.Translatable_Text_Constant__has__Translatable_Text_Constant_Value));
            for (int i = 0; i < keyTTCValues.Length; i++)
            {
                InstanceHandle ihLang = oms.GetRelatedInstance(keyTTCValues[i], oms.GetInstance(KnownRelationshipGuids.Translatable_Text_Constant_Value__has__Language));
                if (ihLang == languageInstance)
                {
                    return(oms.GetAttributeValue(keyTTCValues[i], oms.GetInstance(KnownAttributeGuids.Text.Value), defaultValue));
                }
            }
            return(defaultValue);
        }
コード例 #2
0
        public static string GetInstanceTitle(this Oms oms, InstanceHandle inst)
        {
            InstanceHandle ihParentClass = oms.GetRelatedInstance(inst, oms.GetInstance(KnownRelationshipGuids.Instance__for__Class));

            if (ihParentClass.IsEmpty)
            {
                Console.WriteLine("[mocha warning]: GetInstanceTitle: parent class is empty for inst with UID {0}", oms.GetInstanceID(inst));
                Console.WriteLine("---------------- (using relationship with UID {0}, valid? {1} )", KnownRelationshipGuids.Instance__for__Class, oms.GetInstance(KnownRelationshipGuids.Instance__for__Class));
            }
            InstanceHandle ihTitleString = oms.GetRelatedInstance(ihParentClass, oms.GetInstance(KnownRelationshipGuids.Class__instance_labeled_by__String));

            InstanceHandle[] ihStringComponents = oms.GetRelatedInstances(ihTitleString, oms.GetInstance(KnownRelationshipGuids.String__has__String_Component));

            string value = oms.GetStringValue(ihStringComponents, inst);

            return(value);
        }
コード例 #3
0
 /// <summary>
 /// Gets all instances of the Class instance.
 /// </summary>
 /// <returns>The class instances.</returns>
 /// <param name="oms">The <see cref="Oms" /> to query.</param>
 public static InstanceHandle[] GetClassInstances(this Oms oms)
 {
     return(oms.GetRelatedInstances(oms.GetInstance(KnownInstanceGuids.Classes.Class), oms.GetInstance(KnownRelationshipGuids.Class__has_sub__Class)));
 }